public async Task <ActionResult> Compose(NewMessageViewModel message)
        {
            //ViewBag.PmView = "compose";
            //ViewBag.Title = "Compose";

            //set this incase invalid submittal
            var userData = UserData;

            message.RequireCaptcha = userData.Information.CommentPoints.Sum < VoatSettings.Instance.MinimumCommentPointsForCaptchaMessaging && VoatSettings.Instance.CaptchaEnabled;

            if (!ModelState.IsValid)
            {
                return(View(message));
            }

            if (message.Recipient == null || message.Subject == null || message.Body == null)
            {
                return(RedirectToAction("Sent", "Messages"));
            }

            if (message.RequireCaptcha)
            {
                bool isCaptchaValid = await ReCaptchaUtility.Validate(Request);

                if (!isCaptchaValid)
                {
                    ModelState.AddModelError(string.Empty, "Incorrect recaptcha answer.");
                    return(View(message));
                }
            }
            var sendMessage = new SendMessage()
            {
                Recipient = message.Recipient,
                Message   = message.Body,
                Subject   = message.Subject,
                Sender    = message.Sender
            };
            var cmd      = new SendMessageCommand(sendMessage, false, true).SetUserContext(User);
            var response = await cmd.Execute();



            if (response.Success)
            {
                var m = response.Response;
                if (m.SenderType == IdentityType.Subverse)
                {
                    return(RedirectToAction("SubverseIndex", "Messages", new { subverse = m.Sender, type = MessageTypeFlag.Sent, state = MessageState.All }));
                }
                else
                {
                    return(RedirectToAction("Sent", "Messages"));
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, response.Message);
                return(View(message));
            }
        }
示例#2
0
        public async Task <ActionResult> Compose([Bind(Include = "ID,Recipient,Subject,Body")] PrivateMessage privateMessage)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            if (privateMessage.Recipient == null || privateMessage.Subject == null || privateMessage.Body == null)
            {
                return(RedirectToAction("Sent", "Messaging"));
            }

            if (Karma.CommentKarma(User.Identity.Name) < 100)
            {
                bool isCaptchaValid = await ReCaptchaUtility.Validate(Request);

                if (!isCaptchaValid)
                {
                    ModelState.AddModelError(string.Empty, "Incorrect recaptcha answer.");
                    return(View());
                }
            }

            var response = MesssagingUtility.SendPrivateMessage(User.Identity.Name, privateMessage.Recipient, privateMessage.Subject, privateMessage.Body);

            return(RedirectToAction("Sent", "Messaging"));
        }
示例#3
0
        public async Task <ActionResult> Compose([Bind(Include = "Id,Recipient,Subject,Body")] Privatemessage privateMessage)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            if (privateMessage.Recipient == null || privateMessage.Subject == null || privateMessage.Body == null)
            {
                return(RedirectToAction("Sent", "Messaging"));
            }

            if (Karma.CommentKarma(User.Identity.Name) < 100)
            {
                bool isCaptchaValid = await ReCaptchaUtility.Validate(Request);

                if (!isCaptchaValid)
                {
                    ModelState.AddModelError(string.Empty, "Incorrect recaptcha answer.");
                    return(View());
                }
            }

            // check if recipient exists
            if (Voat.Utilities.UserHelper.UserExists(privateMessage.Recipient) && !Voat.Utilities.UserHelper.IsUserGloballyBanned(User.Identity.Name))
            {
                // send the submission
                privateMessage.Timestamp = DateTime.Now;
                privateMessage.Sender    = User.Identity.Name;
                privateMessage.Status    = true;
                if (Voat.Utilities.UserHelper.IsUserGloballyBanned(User.Identity.Name))
                {
                    return(RedirectToAction("Sent", "Messaging"));
                }
                _db.Privatemessages.Add(privateMessage);
                try
                {
                    await _db.SaveChangesAsync();

                    // get count of unread notifications
                    int unreadNotifications = Voat.Utilities.UserHelper.UnreadTotalNotificationsCount(privateMessage.Recipient);

                    // send SignalR realtime notification to recipient
                    var hubContext = GlobalHost.ConnectionManager.GetHubContext <MessagingHub>();
                    hubContext.Clients.User(privateMessage.Recipient).setNotificationsPending(unreadNotifications);
                }
                catch (Exception)
                {
                    return(View("~/Views/Errors/DbNotResponding.cshtml"));
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Sorry, there is no recipient with that username.");
                return(View());
            }
            return(RedirectToAction("Sent", "Messaging"));
        }
示例#4
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // begin recaptcha check
            string encodedResponse    = Request.Form["g-Recaptcha-Response"];
            bool   isCaptchaCodeValid = (ReCaptchaUtility.Validate(encodedResponse) == "True" ? true : false);

            if (!isCaptchaCodeValid)
            {
                ModelState.AddModelError("", "Incorrect recaptcha answer.");
                return(View());
            }
            // end recaptcha check

            try
            {
                // get user IP address
                string clientIpAddress = Utils.User.UserIpAddress(Request);

                var user = new WhoaVerseUser
                {
                    UserName             = model.UserName,
                    RegistrationDateTime = DateTime.Now,
                    LastLoginFromIp      = clientIpAddress,
                    LastLoginDateTime    = DateTime.Now
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent : false);

                    // redirect new users to Welcome actionresult
                    return(RedirectToAction("Welcome", "Home"));
                }
                AddErrors(result);
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, "Something bad happened. You broke Whoaverse.");
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            // begin recaptcha check
            const string captchaMessage     = "";
            var          isCaptchaCodeValid = ReCaptchaUtility.GetCaptchaResponse(captchaMessage, Request);

            if (!isCaptchaCodeValid)
            {
                ModelState.AddModelError("", "Incorrect recaptcha answer.");
                return(View());
            }
            // end recaptcha check

            try
            {
                var user = new WhoaVerseUser {
                    UserName = model.UserName, RegistrationDateTime = DateTime.Now
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent : false);

                    // redirect new users to Welcome actionresult
                    return(RedirectToAction("Welcome", "Home"));
                }
                AddErrors(result);
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, "Something bad happened. You broke Whoaverse.");
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#6
0
        public ActionResult Submit([Bind(Include = "Id,Votes,Name,Date,Type,Linkdescription,Title,Rank,MessageContent,Subverse")] Message message)
        {
            // abort if model state is invalid
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // save temp values for the view in case submission fails
            ViewBag.selectedSubverse = message.Subverse;
            ViewBag.message          = message.MessageContent;
            ViewBag.title            = message.Title;
            ViewBag.linkDescription  = message.Linkdescription;

            // check if user is banned
            if (Utils.User.IsUserGloballyBanned(message.Name) || Utils.User.IsUserBannedFromSubverse(User.Identity.Name, message.Subverse))
            {
                ViewBag.SelectedSubverse = message.Subverse;
                return(View("~/Views/Home/Comments.cshtml", message));
            }

            // check if user has reached hourly posting quota for target subverse
            if (Utils.User.UserHourlyPostingQuotaForSubUsed(User.Identity.Name, message.Subverse))
            {
                ModelState.AddModelError("", "You have reached your hourly submission quota for this subverse.");
                return(View());
            }

            // check if user has reached daily posting quota for target subverse
            if (Utils.User.UserDailyPostingQuotaForSubUsed(User.Identity.Name, message.Subverse))
            {
                ModelState.AddModelError("", "You have reached your daily submission quota for this subverse.");
                return(View());
            }

            // verify recaptcha if user has less than 25 CCP
            var userCcp = Karma.CommentKarma(User.Identity.Name);

            if (userCcp < 25)
            {
                string encodedResponse    = Request.Form["g-Recaptcha-Response"];
                bool   isCaptchaCodeValid = (ReCaptchaUtility.Validate(encodedResponse) == "True" ? true : false);

                if (!isCaptchaCodeValid)
                {
                    ModelState.AddModelError("", "Incorrect recaptcha answer.");

                    // TODO
                    // SET PREVENT SPAM DELAY TO 0

                    return(View());
                }
            }

            // if user CCP or SCP is less than -50, allow only X submissions per 24 hours
            var userScp = Karma.LinkKarma(User.Identity.Name);

            if (userCcp <= -50 || userScp <= -50)
            {
                var quotaUsed = Utils.User.UserDailyPostingQuotaForNegativeScoreUsed(User.Identity.Name);
                if (quotaUsed)
                {
                    ModelState.AddModelError("", "You have reached your daily submission quota. Your current quota is " + Convert.ToInt32(ConfigurationManager.AppSettings["dailyPostingQuotaForNegativeScore"]) + " submission(s) per 24 hours.");
                    return(View());
                }
            }

            // abort if model state is invalid
            if (!ModelState.IsValid)
            {
                return(View("Submit"));
            }

            // check if subverse exists
            var targetSubverse = _db.Subverses.Find(message.Subverse.Trim());

            if (targetSubverse == null || message.Subverse.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError(string.Empty, "Sorry, The subverse you are trying to post to does not exist.");
                return(View("Submit"));
            }

            // check if subverse has "authorized_submitters_only" set and dissalow submission if user is not allowed submitter
            if (targetSubverse.authorized_submitters_only)
            {
                if (!Utils.User.IsUserSubverseModerator(User.Identity.Name, targetSubverse.name))
                {
                    // user is not a moderator, check if user is an administrator
                    if (!Utils.User.IsUserSubverseAdmin(User.Identity.Name, targetSubverse.name))
                    {
                        ModelState.AddModelError("", "You are not authorized to submit links or start discussions in this subverse. Please contact subverse moderators for authorization.");
                        return(View("Submit"));
                    }
                }
            }

            // everything was okay, process incoming submission

            // submission is a link post
            // generate a thumbnail if submission is a direct link to image or video
            if (message.Type == 2 && message.MessageContent != null && message.Linkdescription != null)
            {
                // strip unicode if title contains unicode
                if (Submissions.ContainsUnicode(message.Linkdescription))
                {
                    message.Linkdescription = Submissions.StripUnicode(message.Linkdescription);
                }
                // abort if title less than 10 characters
                if (message.Linkdescription.Length < 10)
                {
                    ModelState.AddModelError(string.Empty, "Sorry, the title may not be less than 10 characters.");
                    return(View("Submit"));
                }

                var domain = UrlUtility.GetDomainFromUri(message.MessageContent);

                // check if target subvere allows submissions from globally banned hostnames
                if (!targetSubverse.exclude_sitewide_bans)
                {
                    // check if hostname is banned before accepting submission
                    if (BanningUtility.IsHostnameBanned(domain))
                    {
                        ModelState.AddModelError(string.Empty, "Sorry, the hostname you are trying to submit is banned.");
                        return(View("Submit"));
                    }
                }

                // check if same link was submitted before and deny submission
                var existingSubmission = _db.Messages.FirstOrDefault(s => s.MessageContent.Equals(message.MessageContent, StringComparison.OrdinalIgnoreCase) && s.Subverse.Equals(message.Subverse, StringComparison.OrdinalIgnoreCase));

                // submission is a repost, discard it and inform the user
                if (existingSubmission != null)
                {
                    ModelState.AddModelError(string.Empty, "Sorry, this link has already been submitted by someone else.");

                    // todo: offer the option to repost after informing the user about it
                    return(RedirectToRoute(
                               "SubverseComments",
                               new
                    {
                        controller = "Comment",
                        action = "Comments",
                        id = existingSubmission.Id,
                        subversetoshow = existingSubmission.Subverse
                    }
                               ));
                }

                // check if user has reached daily crossposting quota
                if (Utils.User.DailyCrossPostingQuotaUsed(User.Identity.Name, message.MessageContent))
                {
                    ModelState.AddModelError("", "You have reached your daily crossposting quota for this URL.");
                    return(View());
                }

                // check if target subverse has thumbnails setting enabled before generating a thumbnail
                if (targetSubverse.enable_thumbnails)
                {
                    // try to generate and assign a thumbnail to submission model
                    message.Thumbnail = ThumbGenerator.ThumbnailFromSubmissionModel(message);
                }

                // flag the submission as anonymized if it was submitted to a subverse with active anonymized_mode
                if (targetSubverse.anonymized_mode)
                {
                    message.Anonymized = true;
                }
                else
                {
                    message.Name = User.Identity.Name;
                }

                // accept submission and save it to the database
                message.Subverse = targetSubverse.name;

                // grab server timestamp and modify submission timestamp to have posting time instead of "started writing submission" time
                message.Date  = DateTime.Now;
                message.Likes = 1;
                _db.Messages.Add(message);

                // update last submission received date for target subverse
                targetSubverse.last_submission_received = DateTime.Now;
                _db.SaveChanges();
            }
            else if (message.Type == 1 && message.Title != null)
            {
                // submission is a self post

                // strip unicode if message contains unicode
                if (Submissions.ContainsUnicode(message.Title))
                {
                    message.Title = Submissions.StripUnicode(message.Title);
                }
                // abort if title less than 10 characters
                if (message.Title.Length < 10)
                {
                    ModelState.AddModelError(string.Empty, "Sorry, the the message title may not be less than 10 characters.");
                    return(View("Submit"));
                }

                // accept submission and save it to the database
                // trim trailing blanks from subverse name if a user mistakenly types them
                message.Subverse = targetSubverse.name;

                // flag the submission as anonymized if it was submitted to a subverse with active anonymized_mode
                if (targetSubverse.anonymized_mode)
                {
                    message.Anonymized = true;
                }
                else
                {
                    message.Name = User.Identity.Name;
                }
                // grab server timestamp and modify submission timestamp to have posting time instead of "started writing submission" time
                message.Date  = DateTime.Now;
                message.Likes = 1;
                _db.Messages.Add(message);
                // update last submission received date for target subverse
                targetSubverse.last_submission_received = DateTime.Now;

                if (ContentProcessor.Instance.HasStage(ProcessingStage.InboundPreSave))
                {
                    message.MessageContent = ContentProcessor.Instance.Process(message.MessageContent, ProcessingStage.InboundPreSave, message);
                }

                _db.SaveChanges();

                if (ContentProcessor.Instance.HasStage(ProcessingStage.InboundPostSave))
                {
                    ContentProcessor.Instance.Process(message.MessageContent, ProcessingStage.InboundPostSave, message);
                }
            }

            return(RedirectToRoute(
                       "SubverseComments",
                       new
            {
                controller = "Comment",
                action = "Comments",
                id = message.Id,
                subversetoshow = message.Subverse
            }
                       ));
        }
示例#7
0
        public async Task <ActionResult> Submit([Bind(Include = "Id,Votes,Name,Date,Type,Linkdescription,Title,Rank,MessageContent,Subverse")] Message message)
        {
            // check if user is banned
            if (Utils.User.IsUserBanned(message.Name))
            {
                ViewBag.SelectedSubverse = message.Subverse;
                return(View("~/Views/Home/Comments.cshtml", message));
            }

            // verify recaptcha if user has less than 25 CCP
            if (Karma.CommentKarma(User.Identity.Name) < 25)
            {
                const string captchaMessage     = "";
                var          isCaptchaCodeValid = ReCaptchaUtility.GetCaptchaResponse(captchaMessage, Request);

                if (!isCaptchaCodeValid)
                {
                    ModelState.AddModelError("", "Incorrect recaptcha answer.");
                    return(View());
                }
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            // check if subverse exists
            var targetSubverse = _db.Subverses.Find(message.Subverse.Trim());

            if (targetSubverse != null && !message.Subverse.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                // check if subverse has "authorized_submitters_only" set and dissalow submission if user is not allowed submitter
                if (targetSubverse.authorized_submitters_only)
                {
                    if (!Utils.User.IsUserSubverseModerator(User.Identity.Name, targetSubverse.name))
                    {
                        // user is not a moderator, check if user is an administrator
                        if (!Utils.User.IsUserSubverseAdmin(User.Identity.Name, targetSubverse.name))
                        {
                            ModelState.AddModelError("", "You are not authorized to submit links or start discussions in this subverse. Please contact subverse moderators for authorization.");
                            return(View());
                        }
                    }
                }

                // submission is a link post
                // generate a thumbnail if submission is a direct link to image or video
                if (message.Type == 2 && message.MessageContent != null && message.Linkdescription != null)
                {
                    var domain = UrlUtility.GetDomainFromUri(message.MessageContent);

                    // check if hostname is banned before accepting submission
                    if (BanningUtility.IsHostnameBanned(domain))
                    {
                        ModelState.AddModelError(string.Empty, "Sorry, the hostname you are trying to submit is banned.");
                        return(View());
                    }

                    // check if same link was submitted before and deny submission
                    var existingSubmission = _db.Messages.FirstOrDefault(s => s.MessageContent.Equals(message.MessageContent, StringComparison.OrdinalIgnoreCase) && s.Subverse == message.Subverse);

                    // submission is a repost, discard it and inform the user
                    if (existingSubmission != null)
                    {
                        ModelState.AddModelError(string.Empty, "Sorry, this link has already been submitted by someone else.");

                        // todo: offer the option to repost after informing the user about it
                        return(RedirectToRoute(
                                   "SubverseComments",
                                   new
                        {
                            controller = "Comment",
                            action = "Comments",
                            id = existingSubmission.Id,
                            subversetoshow = existingSubmission.Subverse
                        }
                                   ));
                    }

                    // check if target subverse has thumbnails setting enabled before generating a thumbnail
                    if (targetSubverse.enable_thumbnails)
                    {
                        // try to generate and assign a thumbnail to submission model
                        message.Thumbnail = ThumbGenerator.ThumbnailFromSubmissionModel(message);
                    }

                    // flag the submission as anonymized if it was submitted to a subverse with active anonymized_mode
                    if (targetSubverse.anonymized_mode)
                    {
                        message.Anonymized = true;
                    }
                    else
                    {
                        message.Name = User.Identity.Name;
                    }

                    // accept submission and save it to the database
                    message.Subverse = targetSubverse.name;
                    // grab server timestamp and modify submission timestamp to have posting time instead of "started writing submission" time
                    message.Date  = DateTime.Now;
                    message.Likes = 1;
                    _db.Messages.Add(message);

                    // update last submission received date for target subverse
                    targetSubverse.last_submission_received = DateTime.Now;
                    await _db.SaveChangesAsync();
                }
                else if (message.Type == 1 && message.Title != null)
                {
                    // submission is a self post
                    // accept submission and save it to the database
                    // trim trailing blanks from subverse name if a user mistakenly types them
                    message.Subverse = targetSubverse.name;
                    // flag the submission as anonymized if it was submitted to a subverse with active anonymized_mode
                    if (targetSubverse.anonymized_mode)
                    {
                        message.Anonymized = true;
                    }
                    else
                    {
                        message.Name = User.Identity.Name;
                    }
                    // grab server timestamp and modify submission timestamp to have posting time instead of "started writing submission" time
                    message.Date  = DateTime.Now;
                    message.Likes = 1;
                    _db.Messages.Add(message);
                    // update last submission received date for target subverse
                    targetSubverse.last_submission_received = DateTime.Now;

                    if (ContentProcessor.Instance.HasStage(ProcessingStage.InboundPreSave))
                    {
                        message.MessageContent = ContentProcessor.Instance.Process(message.MessageContent, ProcessingStage.InboundPreSave, message);
                    }

                    await _db.SaveChangesAsync();

                    if (ContentProcessor.Instance.HasStage(ProcessingStage.InboundPostSave))
                    {
                        ContentProcessor.Instance.Process(message.MessageContent, ProcessingStage.InboundPostSave, message);
                    }
                }

                return(RedirectToRoute(
                           "SubverseComments",
                           new
                {
                    controller = "Comment",
                    action = "Comments",
                    id = message.Id,
                    subversetoshow = message.Subverse
                }
                           ));
            }
            ModelState.AddModelError(string.Empty, "Sorry, The subverse you are trying to post to does not exist.");
            return(View());
        }
示例#8
0
        public async Task <ActionResult> Submit(CreateSubmissionViewModel model)
        {
            //set this incase invalid submittal
            var userData = UserData;

            model.RequireCaptcha = userData.Information.CommentPoints.Sum < VoatSettings.Instance.MinimumCommentPointsForCaptchaSubmission && VoatSettings.Instance.CaptchaEnabled;

            // abort if model state is invalid
            if (!ModelState.IsValid)
            {
                PreventSpamAttribute.Reset(this.HttpContext);
                return(View(model));
            }

            //Check Captcha
            if (model.RequireCaptcha)
            {
                var captchaSuccess = await ReCaptchaUtility.Validate(Request);

                if (!captchaSuccess)
                {
                    ModelState.AddModelError(string.Empty, "Incorrect recaptcha answer");
                    return(View(model));
                }
            }

            //new pipeline
            var userSubmission = new Domain.Models.UserSubmission();

            userSubmission.IsAdult      = model.IsAdult;
            userSubmission.IsAnonymized = model.IsAnonymized;
            userSubmission.Subverse     = model.Subverse.TrimSafe();

            userSubmission.Title   = model.Title.StripWhiteSpace();
            userSubmission.Content = (model.Type == Domain.Models.SubmissionType.Text ? model.Content.TrimSafe() : null);
            userSubmission.Url     = (model.Type == Domain.Models.SubmissionType.Link ? model.Url.TrimSafe() : null);

            var q      = new CreateSubmissionCommand(userSubmission).SetUserContext(User);
            var result = await q.Execute();

            if (result.Success)
            {
                // redirect to comments section of newly posted submission
                return(RedirectToRoute(
                           "SubverseCommentsWithSort_Short",
                           new
                {
                    submissionID = result.Response.ID,
                    subverseName = result.Response.Subverse,
                    sort = (string)null
                }
                           ));
            }
            else
            {
                //Help formatting issues with unicode.
                if (model.Title.ContainsUnicode())
                {
                    model.Title = model.Title.StripUnicode();
                    ModelState.AddModelError(String.Empty, "Voat has strip searched your title and removed it's unicode. Please verify you approve of what you see.");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.DebugMessage());
                }
                PreventSpamAttribute.Reset(HttpContext);
                return(View(model));
            }
        }
示例#9
0
        public async Task <ActionResult> Submit([Bind(Include = "Id,Votes,Name,Date,Type,Linkdescription,Title,Rank,MessageContent,Subverse")] Message submission)
        {
            // abort if model state is invalid
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // save temp values for the view in case submission fails
            ViewBag.selectedSubverse = submission.Subverse;
            ViewBag.message          = submission.MessageContent;
            ViewBag.title            = submission.Title;
            ViewBag.linkDescription  = submission.Linkdescription;

            // grab server timestamp and modify submission timestamp to have posting time instead of "started writing submission" time
            submission.Date = DateTime.Now;

            // check if user is banned
            if (UserHelper.IsUserGloballyBanned(User.Identity.Name) || UserHelper.IsUserBannedFromSubverse(User.Identity.Name, submission.Subverse))
            {
                ViewBag.SelectedSubverse = submission.Subverse;
                return(View("~/Views/Home/Comments.cshtml", submission));
            }

            // check if subverse exists
            var targetSubverse = _db.Subverses.Find(submission.Subverse.Trim());

            if (targetSubverse == null || submission.Subverse.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError(string.Empty, "Sorry, The subverse you are trying to post to does not exist.");
                return(View("Submit"));
            }

            //wrap captcha check in anon method as following method is in non UI dll
            var captchaCheck = new Func <HttpRequestBase, Task <bool> >(request => {
                return(ReCaptchaUtility.Validate(request));
            });

            // check if this submission is valid and good to go
            var preProcessCheckResult = await Submissions.PreAddSubmissionCheck(submission, Request, User.Identity.Name, targetSubverse, captchaCheck);

            if (preProcessCheckResult != null)
            {
                ModelState.AddModelError(string.Empty, preProcessCheckResult);
                return(View("Submit"));
            }

            // submission is a link post
            if (submission.Type == 2 && submission.MessageContent != null && submission.Linkdescription != null)
            {
                // check if same link was submitted before and deny submission
                var existingSubmission = _db.Messages.FirstOrDefault(s => s.MessageContent.Equals(submission.MessageContent, StringComparison.OrdinalIgnoreCase) && s.Subverse.Equals(submission.Subverse, StringComparison.OrdinalIgnoreCase));

                // submission is a repost, discard it and inform the user
                if (existingSubmission != null)
                {
                    ModelState.AddModelError(string.Empty, "Sorry, this link has already been submitted by someone else.");

                    // todo: offer the option to repost after informing the user about it
                    return(RedirectToRoute(
                               "SubverseComments",
                               new
                    {
                        controller = "Comment",
                        action = "Comments",
                        id = existingSubmission.Id,
                        subversetoshow = existingSubmission.Subverse
                    }
                               ));
                }

                // process new link submission
                var addLinkSubmissionResult = await Submissions.AddNewSubmission(submission, targetSubverse, User.Identity.Name);

                if (addLinkSubmissionResult != null)
                {
                    ModelState.AddModelError(string.Empty, addLinkSubmissionResult);
                    return(View("Submit"));
                }
                // update last submission received date for target subverse
                targetSubverse.last_submission_received = DateTime.Now;
                await _db.SaveChangesAsync();
            }
            // submission is a message type submission
            else if (submission.Type == 1 && submission.Title != null)
            {
                // process new message type submission
                var addMessageSubmissionResult = await Submissions.AddNewSubmission(submission, targetSubverse, User.Identity.Name);

                if (addMessageSubmissionResult != null)
                {
                    ModelState.AddModelError(string.Empty, addMessageSubmissionResult);
                    return(View("Submit"));
                }
                // update last submission received date for target subverse
                targetSubverse.last_submission_received = DateTime.Now;
                await _db.SaveChangesAsync();
            }

            // redirect to comments section of newly posted submission
            return(RedirectToRoute(
                       "SubverseComments",
                       new
            {
                controller = "Comment",
                action = "Comments",
                id = submission.Id,
                subversetoshow = submission.Subverse
            }
                       ));
        }