public async Task <ActionResult> ReportSubmission(int id) { var s = _db.Submissions.Find(id); if (s != null) { // prepare report headers var subverse = s.Subverse; //don't allow banned users to send reports if (!UserHelper.IsUserBannedFromSubverse(User.Identity.Name, subverse) && !UserHelper.IsUserGloballyBanned(User.Identity.Name)) { var reportTimeStamp = Repository.CurrentDate.ToString(CultureInfo.InvariantCulture); try { string cacheKeyReport = CachingKey.ReportKey(ContentType.Submission, id); //see if comment has been reported before if (CacheHandler.Instance.Retrieve <object>(cacheKeyReport) == null) { //mark comment in cache as having been reported CacheHandler.Instance.Register(cacheKeyReport, new Func <object>(() => { return(new object()); }), contentReportTimeOut, -1); string userName = User.Identity.Name; string cacheKeyUserReportCount = CachingKey.ReportCountUserKey(ContentType.Submission, userName); int reportsPerUserThreshold = 5; var reportCountViaUser = CacheHandler.Instance.Retrieve <int?>(cacheKeyUserReportCount); //ensure user is below reporting threshold if (reportCountViaUser == null || reportCountViaUser.Value <= reportsPerUserThreshold) { //add or update cache with current user reports if (reportCountViaUser.HasValue) { CacheHandler.Instance.Replace <int?>(cacheKeyUserReportCount, new Func <int?, int?>((x) => { return((int?)(x.Value + 1)); }), contentUserCountTimeOut); } else { CacheHandler.Instance.Register <int?>(cacheKeyUserReportCount, new Func <int?>(() => { return((int?)1); }), contentUserCountTimeOut, -1); } string body = String.Format("This submission has been reported:\r\n\r\nhttps://voat.co/v/{0}/{1}\r\n\r\n\r\nReport Spammers to v/ReportSpammers.", s.Subverse, s.ID); var message = new Domain.Models.SendMessage() { Sender = s.IsAnonymized ? "Anon" : userName, Recipient = $"v/{subverse}", Subject = "Submission Spam Report", Message = body }; var cmd = new SendMessageCommand(message, true); await cmd.Execute(); //MesssagingUtility.SendPrivateMessage(commentToReport.IsAnonymized ? "Anon" : userName, String.Format("v/{0}", commentSubverse), "Comment Spam Report", body); } } } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable, "Service Unavailable")); } } } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Bad Request")); } return(new HttpStatusCodeResult(HttpStatusCode.OK, "OK")); }