Пример #1
0
        private IEnumerable <MessageOutbound> generateMessages(PostSmall post, PostComment comment)
        {
            IEnumerable <PostSubscription> subscriptions = postRepository.GetSubscriptions(context.Site.ID, post.BlogName, post.Slug);
            List <MessageOutbound>         messages      = new List <MessageOutbound>();
            //TODO: (erikpo) Once the plugin model is done, get this from the plugin
            int retryCount = 4;

            foreach (PostSubscription subscription in subscriptions)
            {
                string userName = subscription.UserName;

                MessageOutbound message = new MessageOutbound
                {
                    ID                  = Guid.NewGuid(),
                    To                  = !string.IsNullOrEmpty(userName) ? string.Format("{0} <{1}>", userName, subscription.UserEmail) : subscription.UserEmail,
                    Subject             = string.Format(getPhrase("Messages.Formats.ReplySubject", context.Site.LanguageDefault, "RE: {0}"), post.Title),
                    Body                = generateMessageBody(post, comment, context.Site),
                    RemainingRetryCount = retryCount
                };

                messages.Add(message);
            }

            return(messages);
        }
 private bool getSubscriptionExists(Guid siteID, PostSmall post, Guid creatorUserID)
 {
     return((
                from s in context.oxite_Subscriptions
                join psr in context.oxite_Blogs_PostSubscriptionRelationships on s.SubscriptionID equals psr.SubscriptionID
                join p in context.oxite_Blogs_Posts on psr.PostID equals p.PostID
                join b in context.oxite_Blogs_Blogs on p.BlogID equals b.BlogID
                where b.SiteID == siteID && string.Compare(b.BlogName, post.BlogName, true) == 0 && p.Slug == post.Slug && s.UserID == creatorUserID
                select psr
                ).Any());
 }
        private bool getSubscriptionExists(Guid siteID, PostSmall post, string creatorEmail)
        {
            Guid userID = context.oxite_Users.Single(u => u.Username == "Anonymous").UserID;

            return((
                       from s in context.oxite_Subscriptions
                       join psr in context.oxite_Blogs_PostSubscriptionRelationships on s.SubscriptionID equals psr.SubscriptionID
                       join p in context.oxite_Blogs_Posts on psr.PostID equals p.PostID
                       join b in context.oxite_Blogs_Blogs on p.BlogID equals b.BlogID
                       where b.SiteID == siteID && string.Compare(b.BlogName, post.BlogName, true) == 0 && p.Slug == post.Slug && s.UserID == userID && s.UserEmail == creatorEmail
                       select s
                       ).Any());
        }
Пример #4
0
        private string generateMessageBody(PostSmall post, PostComment comment, Site site)
        {
            string body = getPhrase("Messages.NewComment", site.LanguageDefault, getDefaultBody());
            //TODO: (erikpo) Change this to come from the user this message is going to if applicable
            double timeZoneOffset = site.TimeZoneOffset;

            body = body.Replace("{Site.Name}", site.DisplayName);
            body = body.Replace("{User.Name}", comment.CreatorName);
            body = body.Replace("{Post.Title}", post.Title);
            //TODO: (erikpo) Change the published date to be relative (e.g. 5 minutes ago)
            body = body.Replace("{Comment.Created}", comment.Created.AddHours(timeZoneOffset).ToLongTimeString());
            body = body.Replace("{Comment.Body}", comment.Body);
            body = body.Replace("{Comment.Permalink}", absolutePathHelper.GetAbsolutePath(comment).Replace("%23", "#"));

            return(body);
        }
        public void AddSubscription(Guid siteID, PostSmall post, Guid creatorUserID)
        {
            if (getSubscriptionExists(siteID, post, creatorUserID))
            {
                return;
            }

            oxite_Subscription subscription = new oxite_Subscription {
                SubscriptionID = Guid.NewGuid(), UserID = creatorUserID
            };

            context.oxite_Subscriptions.InsertOnSubmit(subscription);
            context.oxite_Blogs_PostSubscriptionRelationships.InsertOnSubmit(new oxite_Blogs_PostSubscriptionRelationship {
                SubscriptionID = subscription.SubscriptionID, PostID = GetPost(siteID, post.BlogName, post.Slug).ID
            });

            context.SubmitChanges();
        }
Пример #6
0
 public static string AddComment(this UrlHelper urlHelper, PostSmall postSmall)
 {
     return(urlHelper.RouteUrl("AddCommentToPost", new { blogName = postSmall.BlogName, postSlug = postSmall.Slug }));
 }
Пример #7
0
 public static string CommentOnPost(this UrlHelper urlHelper, PostSmall postSmall)
 {
     return(string.Format("{0}#comment", urlHelper.Post(postSmall)));
 }
Пример #8
0
 public static string Comment(this UrlHelper urlHelper, PostCommentSmall comment, PostSmall post)
 {
     return(urlHelper.RouteUrl("PostCommentPermalink", new { blogName = post.BlogName, postSlug = post.Slug, commentSlug = comment.Slug }));
 }
Пример #9
0
 public static string Post(this UrlHelper urlHelper, PostSmall postSmall)
 {
     return(urlHelper.RouteUrl("Post", new { blogName = postSmall.BlogName, postSlug = postSmall.Slug, dataFormat = "" }));
 }
Пример #10
0
 public PostSmallReadOnly(PostSmall postSmall)
 {
     BlogName = postSmall.BlogName;
     Title    = postSmall.Title;
     Slug     = postSmall.Slug;
 }
Пример #11
0
 public static PostComment ToPostComment(this CommentOut comment, PostCommentSmall parent, PostSmall post)
 {
     return(new PostComment(comment.Body, comment.Created, comment.CreatorUserID, comment.CreatorName, comment.CreatorEmail, comment.CreatorEmailHash, comment.CreatorUrl, comment.CreatorIP, comment.CreatorUserAgent, comment.Language, comment.Modified, parent, post, comment.Url, comment.State));
 }