Exemple #1
0
        public ActionResult CommentReply([FromBody] AddCommentReplyRequest request)
        {
            if (string.IsNullOrWhiteSpace(BlogHelper.removeAllTags(request.Content)))
            {
                return(BadRequest(new { error = "内容不能为空或纯图片。" }));
            }
            var reply = _blogUtil.AddPostReply(request.CommentId, User.Identity.Name, _sanitizerService.Sanitize(request.Content));

            TriggerAddReply(reply);
            string expmsg = HttpContext.Items["QuestMsg"] as string;

            return(Json(new AddReplyResponse {
                CommentId = reply.PostId, ReplyId = reply.ReplyId, Message = expmsg
            }));
        }
Exemple #2
0
        public async Task <JsonResult> AddPostReply(int postid, string addreplycontent)
        {
            DateTime?lastpost = HttpContext.Session.GetDateTime("LastPostTime");

            if (lastpost.HasValue)
            {
                var diff = DateTime.Now - lastpost.Value;
                if (diff.TotalSeconds < 30 && _expUtil.getUserLvl(User.Identity.Name) < 10)
                {
                    return(Json(new { errmsg = "回复CD为30秒,请等" + (30 - diff.Seconds) + "秒后再试" }));
                }
            }
            if (string.IsNullOrWhiteSpace(BlogHelper.removeAllTags(addreplycontent)))
            {
                return(Json(new { errmsg = "回复不能为空" }));
            }
            var reply = _blogUtil.AddPostReply(postid, User.Identity.Name, _sanitizerService.Sanitize(addreplycontent));

            TriggerAddReply(reply);
            string expmsg = HttpContext.Items["QuestMsg"] as string;

            HttpContext.Session.SetDateTime("LastPostTime", DateTime.Now);
            return(Json(new { id = reply.ReplyId, view = await RenderPartail("Components/ReplyView/ReplyPartial", reply), expmsg }));
        }