public ExpandoObject Topic(TopicSaveModel model) { dynamic o = new ExpandoObject(); var t = new Topic(); t.Body = model.Body; t.Title = model.Title; t.MemberId = Members.GetCurrentMemberId(); t.Created = DateTime.Now; t.ParentId = model.Forum; t.UrlName = url.FormatUrl(model.Title); t.Updated = DateTime.Now; t.Version = model.Version; t.Locked = false; t.LatestComment = 0; t.LatestReplyAuthor = 0; t.Replies = 0; t.Score = 0; t.Answer = 0; t.LatestComment = 0; t.IsSpam = Members.GetCurrentMember().GetPropertyValue <bool>("blocked") || t.DetectSpam(); TopicService.Save(t); if (t.IsSpam) { SpamChecker.SendSlackSpamReport(t.Body, t.Id, "topic", t.MemberId); } o.url = string.Format("{0}/{1}-{2}", library.NiceUrl(t.ParentId), t.Id, t.UrlName); return(o); }
public ExpandoObject Comment(CommentSaveModel model) { dynamic o = new ExpandoObject(); var currentMemberId = Members.GetCurrentMemberId(); var c = new Comment(); c.Body = model.Body; c.MemberId = currentMemberId; c.Created = DateTime.Now; c.ParentCommentId = model.Parent; c.TopicId = model.Topic; c.IsSpam = Members.GetCurrentMember().GetPropertyValue <bool>("blocked") || c.DetectSpam(); CommentService.Save(c); if (c.IsSpam) { SpamChecker.SendSlackSpamReport(c.Body, c.TopicId, "comment", c.MemberId); } o.id = c.Id; o.body = c.Body.Sanitize().ToString(); o.topicId = c.TopicId; o.authorId = c.MemberId; o.created = c.Created.ConvertToRelativeTime(); var author = Members.GetById(currentMemberId); o.authorKarma = author.Karma(); o.authorName = author.Name; o.roles = author.GetRoles(); o.cssClass = model.Parent > 0 ? "level-2" : string.Empty; o.parent = model.Parent; o.isSpam = c.IsSpam; return(o); }
public ExpandoObject Topic(TopicSaveModel model) { dynamic o = new ExpandoObject(); var t = new Topic(); t.Body = model.Body; t.Title = model.Title; t.MemberId = Members.GetCurrentMemberId(); t.Created = DateTime.Now; t.ParentId = model.Forum; t.UrlName = url.FormatUrl(model.Title); t.Updated = DateTime.Now; t.Version = model.Version; t.Locked = false; t.LatestComment = 0; t.LatestReplyAuthor = 0; t.Replies = 0; t.Score = 0; t.Answer = 0; t.LatestComment = 0; t.IsSpam = Members.GetCurrentMember().GetPropertyValue <bool>("blocked") || t.DetectSpam(); // If the chosen version is Umbraco Heartcore, overrule other categories if (model.Version == Constants.Forum.HeartcoreVersionNumber) { var heartCodeForumId = GetForumIdFromName(Constants.Forum.UmbracoHeadlessName); t.ParentId = heartCodeForumId; } // If the chosen version is Umbraco Uno, overrule other categories if (model.Version == Constants.Forum.UnoVersionNumber) { var heartCodeForumId = GetForumIdFromName(Constants.Forum.UmbracoUnoName); t.ParentId = heartCodeForumId; } // If the chosen version is Umbraco 9, overrule other categories if (model.Version == 9) { var heartCodeForumId = GetForumIdFromName("Umbraco 9"); t.ParentId = heartCodeForumId; } TopicService.Save(t); if (t.IsSpam) { SpamChecker.SendSlackSpamReport(t.Body, t.Id, "topic", t.MemberId); } o.url = string.Format("{0}/{1}-{2}", library.NiceUrl(t.ParentId), t.Id, t.UrlName); return(o); }
public ExpandoObject Comment(CommentSaveModel model) { dynamic expandoObject = new ExpandoObject(); var currentMember = Members.GetCurrentMember(); var comment = new Comment { Body = model.Body, MemberId = currentMember.Id, Created = DateTime.Now, ParentCommentId = model.Parent, TopicId = model.Topic }; comment.IsSpam = currentMember.GetPropertyValue <bool>("blocked") || comment.DetectSpam(); CommentService.Save(comment); if (comment.IsSpam) { SpamChecker.SendSlackSpamReport(comment.Body, comment.TopicId, "comment", comment.MemberId); } expandoObject.id = comment.Id; expandoObject.body = comment.Body.Sanitize().ToString(); expandoObject.topicId = comment.TopicId; expandoObject.authorId = comment.MemberId; expandoObject.created = comment.Created.ConvertToRelativeTime(); expandoObject.authorKarma = currentMember.Karma(); expandoObject.authorName = currentMember.Name; expandoObject.roles = currentMember.GetRoles().GetBadges(); expandoObject.cssClass = model.Parent > 0 ? "level-2" : string.Empty; expandoObject.parent = model.Parent; expandoObject.isSpam = comment.IsSpam; SignalRcommentSaved(expandoObject); return(expandoObject); }