public void DeletePost(Post post) { CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost); _storage.GetPostDao().DeletePost(post.ID); NotifySource.GetSubscriptionProvider().UnSubscribe( Constants.NewComment, post.ID.ToString() ); }
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() ); }
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); }
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()) ); } }
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); } }
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()) ); }
public ISubscriptionProvider GetSubscriptionProvider(IServiceScope scope) { return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetSubscriptionProvider()); }
public IRecipientProvider GetRecipientsProvider(IServiceScope scope) { return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetRecipientsProvider()); }
public IPatternProvider GetPatternProvider(IServiceScope scope) { return(((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetPatternProvider()); }
public ProductSubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource) { _coreBaseSettings = coreBaseSettings; }
public SubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource) { CoreBaseSettings = coreBaseSettings; NotifySource = notifySource; }
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()) ); } }