Exemplo n.º 1
0
        public async Task Email(ForumEmail model)
        {
            var projectEmailEnabled = model.GetEmailEnabled();

            if (!projectEmailEnabled)
            {
                return;
            }
            var recipients = model.GetRecipients();

            if (!recipients.Any())
            {
                return;
            }

            await SendEmail(recipients, $"{model.ProjectName}: тема на форуме {model.ForumThread.Header}",
                            $@"Добрый день, {MailGunExts.MailGunRecipientName},
На форуме появилось новое сообщение: 

{model.Text.Contents}

{model.Initiator.DisplayName}

Чтобы ответить на комментарий, перейдите на страницу обсуждения: {_uriService.Get(model.ForumThread.CommentDiscussion)}
", model.Initiator.ToRecipient());
        }
Exemplo n.º 2
0
        public async Task <int> CreateThread(int projectId, int characterGroupId, string header, string commentText, bool hideFromUser, bool emailEverybody)
        {
            var group = await LoadProjectSubEntityAsync <CharacterGroup>(projectId, characterGroupId);

            group.RequestMasterAccess(CurrentUserId);
            var forumThread = new ForumThread()

            {
                CharacterGroupId  = characterGroupId,
                ProjectId         = projectId,
                Header            = Required(header),
                CreatedAt         = Now,
                ModifiedAt        = Now,
                AuthorUserId      = CurrentUserId,
                IsVisibleToPlayer = !hideFromUser,
                CommentDiscussion = new CommentDiscussion()
                {
                    ProjectId = projectId
                }
            };

            forumThread.CommentDiscussion.Comments.Add(new Comment()
            {
                CommentId         = -1,
                ProjectId         = projectId,
                AuthorUserId      = CurrentUserId,
                IsVisibleToPlayer = !hideFromUser,
                CommentText       = new CommentText()
                {
                    CommentId = -1,
                    Text      = new MarkdownString(commentText)
                },
                CreatedAt = Now,
            });

            group.ForumThreads.Add(forumThread);
            await UnitOfWork.SaveChangesAsync();

            if (emailEverybody)
            {
                var groups  = GetChildrenGroupIds(group);
                var players = hideFromUser ? new User[] {} :
                (await ClaimsRepository.GetClaimsForGroups(projectId, ClaimStatusSpec.Approved, groups)).Select(
                    claim => claim.Player);
                var masters = forumThread.Project.ProjectAcls.Select(acl => acl.User);

                var fe = new ForumEmail()
                {
                    ForumThread = forumThread,
                    ProjectName = forumThread.Project.ProjectName,
                    Initiator   = await UserRepository.GetById(CurrentUserId),
                    Recipients  = players.Union(masters).ToList(),
                    Text        = new MarkdownString(commentText),
                };

                await EmailService.Email(fe);
            }
            return(forumThread.ForumThreadId);
        }
Exemplo n.º 3
0
        public void GenerateSubjectTest()
        {
            ForumEmail mail     = new ForumEmail();
            string     actual   = mail.GenerateSubject("Re: &quot;http://", new System.Collections.Hashtable(), ForumContentTypeID.POST);
            string     expected = "Re: \"http://";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public async Task Email(ForumEmail model)
        {
            await MessageService.SendEmail(model, $"{model.ProjectName}: тема на форуме {model.ForumThread.Header}",
                                           StandartGreeting() + $@"
На форуме появилось новое сообщение: 

{model.Text.Contents}

{model.Initiator.GetDisplayName()}

Чтобы ответить на комментарий, перейдите на страницу обсуждения: {
                        _uriService.Get(model.ForumThread.CommentDiscussion)
                    }
");
        }