diff --git a/OurUmbraco.Client/package.json b/OurUmbraco.Client/package.json index 07ef3a3c61..6657ec5477 100644 --- a/OurUmbraco.Client/package.json +++ b/OurUmbraco.Client/package.json @@ -6,9 +6,9 @@ "private": true, "dependencies": {}, "devDependencies": { - "gulp-clean-css": "4.0.0", "gulp": "4.0.0", "gulp-autoprefixer": "6.0.0", + "gulp-clean-css": "4.0.0", "gulp-concat": "2.6.1", "gulp-imagemin": "5.0.3", "gulp-jshint": "^2.1.0", @@ -18,7 +18,7 @@ "gulp-uglify": "3.0.1", "gulp-util": "3.0.8", "gulp-watch": "5.0.1", - "jshint": "^2.9.7", + "jshint": "^2.12.0", "jshint-stylish": "2.2.1", "node-sass": "4.14.1" }, diff --git a/OurUmbraco.Site/OurUmbraco.Site.csproj b/OurUmbraco.Site/OurUmbraco.Site.csproj index c6aa231b8d..7de0141a27 100644 --- a/OurUmbraco.Site/OurUmbraco.Site.csproj +++ b/OurUmbraco.Site/OurUmbraco.Site.csproj @@ -1,7 +1,7 @@  - + @@ -4535,9 +4535,9 @@ - + diff --git a/OurUmbraco/NotificationsCore/Notifications/MarkAsSolutionReminder.cs b/OurUmbraco/NotificationsCore/Notifications/MarkAsSolutionReminder.cs index 2899e0e7a6..bfcb4eed72 100644 --- a/OurUmbraco/NotificationsCore/Notifications/MarkAsSolutionReminder.cs +++ b/OurUmbraco/NotificationsCore/Notifications/MarkAsSolutionReminder.cs @@ -24,7 +24,10 @@ public void SendNotification(int topicId, int memberId, NotificationMail notific { var memberShipHelper = new MembershipHelper(UmbracoContext.Current); var member = memberShipHelper.GetById(memberId); - + + if (member == null) + return; + using (var smtpClient = new SmtpClient()) { var fromMailAddress = new MailAddress(notificationMail.FromMail, notificationMail.FromName); diff --git a/OurUmbraco/Our/Services/ContributorBadgeService.cs b/OurUmbraco/Our/Services/ContributorBadgeService.cs index 18c11b5a5a..7d44f93de4 100644 --- a/OurUmbraco/Our/Services/ContributorBadgeService.cs +++ b/OurUmbraco/Our/Services/ContributorBadgeService.cs @@ -1,13 +1,13 @@ -using System; -using System.Linq; -using System.Text; -using System.Web.Security; -using Hangfire.Console; +using Hangfire.Console; using Hangfire.Server; using OurUmbraco.Community.GitHub; using OurUmbraco.Our.Models.GitHub; using OurUmbraco.Our.Models.GitHub.AutoReplies; -using Umbraco.Core; +using System; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Web.Security; using Umbraco.Core.Models; namespace OurUmbraco.Our.Services @@ -24,9 +24,9 @@ public class ContributorBadgeService private readonly GitHubService _github; /// - /// Indicates whether live mode is activated. If false, the service will not post comments to GitHub. + /// If true, the service will post comments to GitHub, otherwise member profiles are updated silently /// - public bool IsLive = false; + public bool EnableComments; public ContributorBadgeService() { @@ -40,6 +40,13 @@ public ContributorBadgeService() /// A reference to the Hangfire context if running from Hangfire. public void CheckContributorBadges(PerformContext hangfire = null) { + bool.TryParse(ConfigurationManager.AppSettings["EnableContribBadgeBot"], out bool enabled); + if (!enabled) + return; + + bool.TryParse(ConfigurationManager.AppSettings["EnableContribBadgeBotComments"], out bool enableComments); + EnableComments = enableComments; + CheckContributorBadges(DateTime.UtcNow.Subtract(TimeSpan.FromDays(10)), hangfire); } @@ -72,10 +79,6 @@ public void CheckContributorBadges(DateTime since, PerformContext hangfire = nul /// A reference to the Hangfire context if running from Hangfire. public void CheckContributorBadges(Issue pr, PerformContext hangfire = null) { - - if (IsLive == false) - return; - string prefix = $"[{pr.RepoSlug}/{pr.Number}]"; // Look for a "merged" event in the list of events @@ -110,7 +113,7 @@ public void CheckContributorBadges(Issue pr, PerformContext hangfire = null) } // Add the comment to the issue on GitHub - if (IsLive) _github.AddCommentToIssue(pr, GitHubAutoReplyType.ContributorsBadgeMemberNotFound, GetContributorBadgeMemberNotFoundMessage(pr)); + if (EnableComments) _github.AddCommentToIssue(pr, GitHubAutoReplyType.ContributorsBadgeMemberNotFound, GetContributorBadgeMemberNotFoundMessage(pr)); return; } @@ -126,7 +129,7 @@ public void CheckContributorBadges(Issue pr, PerformContext hangfire = null) Roles.AddUserToRole(creator.Email, Constants.MemberGroups.Contributor); // Add the comment to the issue on GitHub - if (IsLive) _github.AddCommentToIssue(pr, GitHubAutoReplyType.ContributorsBadgeAdded, GetContributorBadgeAddedMessage(pr, creator)); + if (EnableComments) _github.AddCommentToIssue(pr, GitHubAutoReplyType.ContributorsBadgeAdded, GetContributorBadgeAddedMessage(pr, creator)); hangfire.WriteLine($"{prefix} Creator {pr.User.Login} has successfully been given the contributors badge"); @@ -144,7 +147,7 @@ private string GetContributorBadgeMemberNotFoundMessage(Issue issue) sb.AppendLine("Hi @" + issue.User.Login + ","); sb.AppendLine(); - sb.Append($"We really wish to give you the [**Contributors badge**]({ourBadgeUrl}) badge on **Our Umbraco**, "); + sb.Append($"We'd loved to give you the [**Contributors badge**]({ourBadgeUrl}) badge on **Our Umbraco**, "); sb.Append("but we haven't been able to find an account on Our Umbraco matching your GitHub ID."); sb.AppendLine(); sb.AppendLine(); @@ -173,7 +176,7 @@ private string GetContributorBadgeAddedMessage(Issue issue, IMember member) sb.AppendLine("Hi @" + issue.User.Login + ","); sb.AppendLine(); - sb.Append("As a appreciation for your merged PR, you have now been given the"); + sb.Append("As a token of appreciation for your merged PR, you have now been given the"); sb.Append($"[**Contributors badge**]({ourBadgeUrl}) badge on **Our Umbraco** - the official Umbraco community forum."); sb.AppendLine(); sb.AppendLine();