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); } }
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)); }
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)); }
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); } }