Exemplo n.º 1
0
 public void DeletePost(Post post)
 {
     CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost);
     _storage.GetPostDao().DeletePost(post.ID);
     NotifySource.GetSubscriptionProvider().UnSubscribe(
         Constants.NewComment,
         post.ID.ToString()
         );
 }
Exemplo n.º 2
0
 public void DeletePost(Post post)
 {
     CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost);
     _storage.GetPostDao().DeletePost(post.ID);
     BlogUserActivityPublisher.DeletePost(post, CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID));
     NotifySource.GetSubscriptionProvider().UnSubscribe(
         Constants.NewComment,
         post.ID.ToString()
         );
 }
Exemplo n.º 3
0
        public void DeletePost(Post post)
        {
            CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost);
            _storage.GetPostDao().DeletePost(post.ID);
            NotifySource.GetSubscriptionProvider().UnSubscribe(
                Constants.NewComment,
                post.ID.ToString()
                );

            AscCache.Default.Remove("communityScreen" + TenantProvider.CurrentTenantID);
        }
Exemplo n.º 4
0
        public void SaveComment(Comment comment, Post post)
        {
            CommunitySecurity.DemandPermissions(post, ASC.Blogs.Core.Constants.Action_AddComment);
            SaveComment(comment);

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

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

                List <ITagValue> tags = new List <ITagValue>
                {
                    new TagValue(ASC.Blogs.Core.Constants.TagPostSubject, post.Title),
                    new TagValue(ASC.Blogs.Core.Constants.TagPostPreview, post.GetPreviewText(500)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserName, DisplayUserSettings.GetFullUserName(comment.UserID)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(comment.UserID, CommonLinkUtility.GetProductID()))),
                    new TagValue(ASC.Blogs.Core.Constants.TagDate, string.Format("{0:d} {0:t}", comment.Datetime)),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentBody, comment.Content),

                    new TagValue(ASC.Blogs.Core.Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString())),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString() + "#" + comment.ID.ToString())),
                    GetReplyToTag(comment.ID, post)
                };

                NotifyClient.SendNoticeAsync(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    null,
                    tags.ToArray());

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

            BlogUserActivityPublisher.AddComment(comment, post);

            ASC.Notify.Model.ISubscriptionProvider subscriptionProvider = NotifySource.GetSubscriptionProvider();

            if (!subscriptionProvider.IsUnsubscribe((IDirectRecipient)NotifySource.GetRecipientsProvider().
                                                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), ASC.Blogs.Core.Constants.NewComment, post.ID.ToString()))
            {
                subscriptionProvider.Subscribe(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    NotifySource.GetRecipientsProvider().
                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString())
                    );
            }
        }
Exemplo n.º 5
0
 public static void Notify(string AccountID, NotifySource Source, string action, string catalog, string extraInfo)
 {
     if (string.IsNullOrEmpty(AccountID))
     {
         // broadcast to every connected client
         foreach (var nc in _peers.Values.ToList())
         {
             nc.Source  = Source;
             nc.Action  = action;
             nc.Catalog = catalog;
             nc.ExtInfo = extraInfo;
             nc.tcs.TrySetResult(true);
         }
     }
     else if (_peers.ContainsKey(AccountID))
     {
         var nc = _peers[AccountID];
         nc.Source  = Source;
         nc.Action  = action;
         nc.Catalog = catalog;
         nc.ExtInfo = extraInfo;
         nc.tcs.TrySetResult(true);
     }
 }
Exemplo n.º 6
0
        public void SavePost(Post post, bool isNew, bool notifyComments)
        {
            CommunitySecurity.DemandPermissions(
                new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(post.UserID)),
                isNew ? Constants.Action_AddPost : Constants.Action_EditRemovePost);

            _storage.GetPostDao().SavePost(post);
            if (isNew)
            {
                var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(post.UserID.ToString(), ""));
                try
                {
                    NotifyClient.BeginSingleRecipientEvent("asc_blog");
                    NotifyClient.AddInterceptor(initiatorInterceptor);

                    var tags = new List <ITagValue>
                    {
                        new TagValue(Constants.TagPostSubject, post.Title),
                        new TagValue(Constants.TagPostPreview,
                                     post.GetPreviewText(500)),
                        new TagValue(Constants.TagUserName,
                                     DisplayUserSettings.GetFullUserName(post.UserID)),
                        new TagValue(Constants.TagUserURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(post.UserID))),
                        new TagValue(Constants.TagDate,
                                     string.Format("{0:d} {0:t}", post.Datetime)),
                        new TagValue(Constants.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         Constants.ViewBlogPageUrl +
                                         "?blogid=" + post.ID.ToString())),
                        GetReplyToTag(Guid.Empty, post)
                    };

                    NotifyClient.SendNoticeAsync(
                        Constants.NewPost,
                        null,
                        null,
                        tags.ToArray());


                    NotifyClient.SendNoticeAsync(
                        Constants.NewPostByAuthor,
                        post.UserID.ToString(),
                        null,
                        tags.ToArray());

                    NotifyClient.EndSingleRecipientEvent("asc_blog");
                }
                finally
                {
                    NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
                }
            }
            if (!notifyComments)
            {
                return;
            }

            var subscriptionProvider = NotifySource.GetSubscriptionProvider();

            subscriptionProvider.Subscribe(
                Constants.NewComment,
                post.ID.ToString(),
                NotifySource.GetRecipientsProvider().
                GetRecipient(post.UserID.ToString())
                );
        }
Exemplo n.º 7
0
 public ISubscriptionProvider GetSubscriptionProvider(IServiceScope scope)
 {
     return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetSubscriptionProvider());
 }
Exemplo n.º 8
0
 public IRecipientProvider GetRecipientsProvider(IServiceScope scope)
 {
     return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetRecipientsProvider());
 }
Exemplo n.º 9
0
 public IPatternProvider GetPatternProvider(IServiceScope scope)
 {
     return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetPatternProvider());
 }
Exemplo n.º 10
0
 public ProductSubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource)
 {
     _coreBaseSettings = coreBaseSettings;
 }
Exemplo n.º 11
0
 public SubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource)
 {
     CoreBaseSettings = coreBaseSettings;
     NotifySource     = notifySource;
 }
Exemplo n.º 12
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())
                    );
            }
        }