コード例 #1
0
ファイル: WikiEngine.cs プロジェクト: ztcyun/CommunityServer
        public Page SavePage(Page page)
        {
            using (var dao = GetPageDao())
            {
                var saved = dao.SavePage(page);
                FactoryIndexer <WikiWrapper> .IndexAsync(page);

                if (saved != null)
                {
                    var subscriptionProvider = WikiNotifySource.Instance.GetSubscriptionProvider();
                    var amAsRecipient        = (IDirectRecipient)WikiNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());

                    subscriptionProvider.Subscribe(
                        Constants.EditPage,
                        PageNameUtil.ReplaceSpaces(page.PageName),
                        amAsRecipient
                        );

                    if (saved.Version == 1)
                    {
                        NotifyPageCreated(saved);
                    }
                    else
                    {
                        NotifyPageEdited(saved);
                    }
                }

                return(saved);
            }
        }
コード例 #2
0
ファイル: WikiEngine.cs プロジェクト: ztcyun/CommunityServer
 private void NotifyCommentCreated(Page page, Comment comment)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.ReplaceSpaces(page.PageName),
         null,
         GetNotifyTags(page.PageName, "new wiki page comment", comment));
 }
コード例 #3
0
ファイル: WikiEngine.cs プロジェクト: ztcyun/CommunityServer
 private void NotifyPageEdited(Page page)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.ReplaceSpaces(page.PageName),
         null,
         GetNotifyTags(page.PageName, "edit wiki page", null));
 }
コード例 #4
0
ファイル: WikiEngine.cs プロジェクト: julthep/CommunityServer
        private void NotifyCommentCreated(Page page, Comment comment)
        {
            var mentionedUsers   = MentionProvider.GetMentionedUsers(comment.Body);
            var mentionedUserIds = mentionedUsers.Select(u => u.ID.ToString());

            var provider = WikiNotifySource.Instance.GetSubscriptionProvider();

            var authorID = SecurityContext.CurrentAccount.ID.ToString();
            var objectID = PageNameUtil.ReplaceSpaces(page.PageName);

            var recipients = provider
                             .GetRecipients(Constants.EditPage, objectID)
                             .Where(r => !mentionedUserIds.Contains(r.ID))
                             .ToArray();

            var tags = GetNotifyTags(page.PageName, "new wiki page comment", comment);

            WikiNotifyClient.SendNoticeToAsync(authorID, Constants.EditPage, objectID, recipients, tags);

            if (mentionedUsers.Length > 0)
            {
                WikiNotifyClient.SendNoticeToAsync(authorID, Constants.MentionForWikiComment, objectID, mentionedUsers, tags);
            }
        }