コード例 #1
0
        private static void SendCommentUpdates(Comment c, Bookmark b)
        {
            if (c == null || b == null)
            {
                return;
            }
            var url  = ModifyBookmarkUrl(b);
            var tags = new[] {
                new TagValue(BookmarkSubscriptionConstants.BookmarkTitle, b.Name),
                new TagValue(BookmarkSubscriptionConstants.BookmarkUrl, url),
                new TagValue(BookmarkSubscriptionConstants.UserURL,
                             BookmarkingBusinessUtil.RenderProfileLink(c.UserID)),
                new TagValue(BookmarkSubscriptionConstants.Date, c.Datetime.ToShortString()),
                new TagValue(BookmarkSubscriptionConstants.CommentBody, c.Content)
            };

            var mentionedUsers   = MentionProvider.GetMentionedUsers(c.Content);
            var mentionedUserIds = mentionedUsers.Select(u => u.ID.ToString());

            var provider = BookmarkingNotifySource.Instance.GetSubscriptionProvider();

            var objectID = b.ID.ToString(CultureInfo.InvariantCulture);

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

            SendBookmarkNoticeToAsync(BookmarkingBusinessConstants.NotifyActionNewComment, objectID, recipients, tags);

            if (mentionedUsers.Length > 0)
            {
                SendBookmarkNoticeToAsync(BookmarkingBusinessConstants.NotifyActionMentionForBookmarkComment, objectID, mentionedUsers, tags);
            }
        }
コード例 #2
0
        private void NotifyNewComment(FeedComment comment, Feed feed)
        {
            var feedType = feed.FeedType == FeedType.Poll ? "poll" : "feed";

            var tags = new ITagValue[]
            {
                new TagValue(NewsConst.TagFEED_TYPE, feedType),
                //new TagValue(NewsConst.TagAnswers, feed.Variants.ConvertAll<string>(v => v.Name)),
                new TagValue(NewsConst.TagCaption, feed.Caption),
                new TagValue("CommentBody", HtmlUtility.GetFull(comment.Comment)),
                new TagValue(NewsConst.TagDate, comment.Date.ToShortString()),
                new TagValue(NewsConst.TagURL, CommonLinkUtility.GetFullAbsolutePath("~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                new TagValue("CommentURL", CommonLinkUtility.GetFullAbsolutePath("~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id + "#container_" + comment.Id.ToString(CultureInfo.InvariantCulture))),
                new TagValue(NewsConst.TagUserName, DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                new TagValue(NewsConst.TagUserUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID)))
            };

            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.Creator, ""));

            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);

                var mentionedUsers   = MentionProvider.GetMentionedUsers(comment.Comment);
                var mentionedUserIds = mentionedUsers.Select(u => u.ID.ToString());

                var provider = NewsNotifySource.Instance.GetSubscriptionProvider();

                var objectID = feed.Id.ToString(CultureInfo.InvariantCulture);

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

                NewsNotifyClient.NotifyClient.SendNoticeToAsync(NewsConst.NewComment, objectID, recipients, false, tags);

                if (mentionedUsers.Length > 0)
                {
                    NewsNotifyClient.NotifyClient.SendNoticeToAsync(NewsConst.MentionForFeedComment, objectID, mentionedUsers, false, tags);
                }
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        public void SaveComment(Comment comment, Post post)
        {
            CommunitySecurity.DemandPermissions(post, Constants.Action_AddComment);
            SaveComment(comment);

            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.UserID.ToString(), ""));

            try
            {
                NotifyClient.BeginSingleRecipientEvent("asc_blog_c");
                NotifyClient.AddInterceptor(initiatorInterceptor);

                var tags = new ITagValue[]
                {
                    new TagValue(Constants.TagPostSubject, post.Title),
                    new TagValue(Constants.TagPostPreview, post.GetPreviewText(500)),
                    new TagValue(Constants.TagUserName, DisplayUserSettings.GetFullUserName(comment.UserID)),
                    new TagValue(Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(comment.UserID))),
                    new TagValue(Constants.TagDate, string.Format("{0:d} {0:t}", comment.Datetime)),
                    new TagValue(Constants.TagCommentBody, comment.Content),
                    new TagValue(Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(Constants.ViewBlogPageUrl + "?blogid=" + post.ID.ToString())),
                    new TagValue(Constants.TagCommentURL, CommonLinkUtility.GetFullAbsolutePath(Constants.ViewBlogPageUrl + "?blogid=" + post.ID.ToString() + "#container_" + comment.ID.ToString()))
                };

                var mentionedUsers   = MentionProvider.GetMentionedUsers(comment.Content);
                var mentionedUserIds = mentionedUsers.Select(u => u.ID.ToString());

                var provider = _notifySource.GetSubscriptionProvider();

                var objectID = post.ID.ToString();

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

                NotifyClient.SendNoticeToAsync(Constants.NewComment, objectID, recipients, false, tags);

                if (mentionedUsers.Length > 0)
                {
                    NotifyClient.SendNoticeToAsync(Constants.MentionForPostComment, objectID, mentionedUsers, false, tags);
                }

                NotifyClient.EndSingleRecipientEvent("asc_blog_c");
            }
            finally
            {
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            var subscriptionProvider = NotifySource.GetSubscriptionProvider();

            if (!subscriptionProvider.IsUnsubscribe((IDirectRecipient)NotifySource.GetRecipientsProvider().
                                                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), Constants.NewComment, post.ID.ToString()))
            {
                subscriptionProvider.Subscribe(
                    Constants.NewComment,
                    post.ID.ToString(),
                    NotifySource.GetRecipientsProvider().
                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString())
                    );
            }
        }