Beispiel #1
0
        public virtual ActionResult NotifyMaintainersOfAddedComment(string packageId, CommentViewModel commentViewModel)
        {
            var package = packageSvc.FindPackageRegistrationById(packageId);

            if (package == null)
            {
                return(PackageNotFound(packageId));
            }

            var packageUrl = EnsureTrailingSlash(Configuration.GetSiteRoot(UseHttps())) + RemoveStartingSlash(Url.Package(package));

            messageService.SendCommentNotificationToMaintainers(package, commentViewModel, packageUrl);

            return(new HttpStatusCodeResult(200));
        }
        public virtual ActionResult NotifyMaintainersOfAddedComment(string packageId, CommentViewModel commentViewModel)
        {
            var package = packageSvc.FindPackageRegistrationById(packageId);
            if (package == null) return PackageNotFound(packageId);

            var packageUrl = EnsureTrailingSlash(Configuration.GetSiteRoot(useHttps: false)) + RemoveStartingSlash(Url.Package(package));

            messageService.SendCommentNotificationToMaintainers(package, commentViewModel, packageUrl);

            return new HttpStatusCodeResult(200);
        }
        public void SendCommentNotificationToMaintainers(
            PackageRegistration packageRegistration, CommentViewModel comment, string packageUrl)
        {
            string body = @"Comment: {0}

This comment has been added to the disqus forum thread for {1}. 

Package Url: {2}
Comment Url: {3}

{4}
";
            string subject = "[{0}] New disqus comment for maintainers of '{1}'";
            string disqusCommentUrl = string.Format("{0}#comment-{1}", packageUrl, comment.Id);

            body = String.Format(
                CultureInfo.CurrentCulture,
                body,
                comment.Text,
                packageRegistration.Id,
                packageUrl,
                disqusCommentUrl,
                GetDisqusInformationMessage());

            subject = String.Format(CultureInfo.CurrentCulture, subject, settings.GalleryOwnerName, packageRegistration.Id);

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.From = new MailAddress(SiteEmail, "NO REPLY - Chocolatey");

                AddOwnersToMailMessage(packageRegistration, mailMessage);
                if (mailMessage.To.Any()) SendMessage(mailMessage);
            }
        }
Beispiel #4
0
        public void SendCommentNotificationToMaintainers(PackageRegistration packageRegistration, CommentViewModel comment, string packageUrl)
        {
            string body             = @"Comment: {0}

This comment has been added to the disqus forum thread for {1}. 

Package Url: {2}
Comment Url: {3}

{4}
";
            string subject          = "[{0}] New disqus comment for maintainers of '{1}'";
            string disqusCommentUrl = string.Format("{0}#comment-{1}", packageUrl, comment.Id);

            body = String.Format(CultureInfo.CurrentCulture,
                                 body,
                                 comment.Text,
                                 packageRegistration.Id,
                                 packageUrl,
                                 disqusCommentUrl,
                                 GetDisqusInformationMessage());

            subject = String.Format(CultureInfo.CurrentCulture, subject, settings.GalleryOwnerName, packageRegistration.Id);

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body    = body;
                mailMessage.From    = new MailAddress(settings.GalleryOwnerEmail, settings.GalleryOwnerName);

                AddOwnersToMailMessage(packageRegistration, mailMessage);
                if (mailMessage.To.Any())
                {
                    SendMessage(mailMessage);
                }
            }
        }