private IEnumerable <MessageOutbound> generateMessages(ScheduleItemSmall post, ScheduleItemComment comment)
        {
            IEnumerable <ScheduleItemSubscription> subscriptions = scheduleItemRepository.GetSubscriptions(post.EventName, 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 (ScheduleItemSubscription 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);
        }
Example #2
0
 private bool getUserRelationshipExists(ScheduleItemSmall scheduleItem, Guid userID)
 {
     return((
                from si in context.oxite_Conferences_ScheduleItems
                join siur in context.oxite_Conferences_ScheduleItemUserRelationships on si.ScheduleItemID equals siur.ScheduleItemID
                join e in context.oxite_Conferences_Events on si.EventID equals e.EventID
                where string.Compare(e.EventName, scheduleItem.EventName, true) == 0 && si.ScheduleItemID == scheduleItem.ID && siur.UserID == userID
                select si
                ).Any());
 }
Example #3
0
 private bool getSubscriptionExists(Guid siteID, ScheduleItemSmall scheduleItem, Guid creatorUserID)
 {
     return((
                from s in context.oxite_Subscriptions
                join sisr in context.oxite_Conferences_ScheduleItemSubscriptionRelationships on s.SubscriptionID equals sisr.SubscriptionID
                join si in context.oxite_Conferences_ScheduleItems on sisr.ScheduleItemID equals si.ScheduleItemID
                join e in context.oxite_Conferences_Events on si.EventID equals e.EventID
                where /*e.SiteID == siteID && */ string.Compare(e.EventName, scheduleItem.EventName, true) == 0 && si.Slug == scheduleItem.Slug && s.UserID == creatorUserID
                select sisr
                ).Any());
 }
Example #4
0
        private bool getSubscriptionExists(Guid siteID, ScheduleItemSmall scheduleItem, string creatorEmail)
        {
            Guid userID = context.oxite_Users.Single(u => u.Username == "Anonymous").UserID;

            return((
                       from s in context.oxite_Subscriptions
                       join sisr in context.oxite_Conferences_ScheduleItemSubscriptionRelationships on s.SubscriptionID equals sisr.SubscriptionID
                       join si in context.oxite_Conferences_ScheduleItems on sisr.ScheduleItemID equals si.ScheduleItemID
                       join e in context.oxite_Conferences_Events on si.EventID equals e.EventID
                       where /*e.SiteID == siteID && */ string.Compare(e.EventName, scheduleItem.EventName, true) == 0 && si.Slug == scheduleItem.Slug && s.UserID == userID && s.UserEmail == creatorEmail
                       select s
                       ).Any());
        }
Example #5
0
        public void RemoveUserRelationship(ScheduleItemSmall scheduleItem, Guid userID)
        {
            if (scheduleItem == null || !getUserRelationshipExists(scheduleItem, userID))
            {
                return;
            }

            var relationship =
                context.oxite_Conferences_ScheduleItemUserRelationships.Single(
                    r => r.ScheduleItemID.Equals(scheduleItem.ID) && r.UserID.Equals(userID));

            context.oxite_Conferences_ScheduleItemUserRelationships.DeleteOnSubmit(relationship);
            context.SubmitChanges();
        }
        private string generateMessageBody(ScheduleItemSmall post, ScheduleItemComment 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);
        }
Example #7
0
        public void AddUserRelationship(ScheduleItemSmall scheduleItem, Guid userID)
        {
            if (scheduleItem == null || getUserRelationshipExists(scheduleItem, userID))
            {
                return;
            }

            var relationship = new oxite_Conferences_ScheduleItemUserRelationship()
            {
                ScheduleItemID = scheduleItem.ID,
                UserID         = userID
            };

            context.oxite_Conferences_ScheduleItemUserRelationships.InsertOnSubmit(relationship);
            context.SubmitChanges();
        }
Example #8
0
        public void AddSubscription(Guid siteID, ScheduleItemSmall scheduleItem, Guid creatorUserID)
        {
            if (getSubscriptionExists(siteID, scheduleItem, creatorUserID))
            {
                return;
            }

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

            context.oxite_Subscriptions.InsertOnSubmit(subscription);
            context.oxite_Conferences_ScheduleItemSubscriptionRelationships.InsertOnSubmit(new oxite_Conferences_ScheduleItemSubscriptionRelationship {
                SubscriptionID = subscription.SubscriptionID, ScheduleItemID = GetScheduleItem(scheduleItem.EventName, scheduleItem.Slug).ID
            });

            context.SubmitChanges();
        }
 public ScheduleItemSmallReadOnly(ScheduleItemSmall scheduleItemSmall)
 {
     Title = scheduleItemSmall.Title;
     Slug  = scheduleItemSmall.Slug;
 }
Example #10
0
 public static string AddComment(this UrlHelper urlHelper, ScheduleItemSmall scheduleItemSmall)
 {
     return(urlHelper.RouteUrl("AddCommentToScheduleItem", new { /*eventName = scheduleItemSmall.EventName, */ scheduleItemSlug = scheduleItemSmall.Slug }));
 }