// POST /api/forummod public ModerationResult Post(ModerationRequest modReq) { //log.Info("cmd = " + modReq.Cmd); //log.Info("pageId = " + modReq.PageId.ToInvariantString()); //log.Info("moduleId = " + modReq.ModuleId.ToInvariantString()); //log.Info("pageNumber = " + modReq.PageNumber.ToInvariantString()); //log.Info("threadId = " + modReq.ThreadId.ToInvariantString()); //log.Info("postId = " + modReq.PostId.ToInvariantString()); ModerationResult result = new ModerationResult(); result.Msg = "rejected"; if (IsAllowed(modReq)) { switch (modReq.Cmd) { case "sendnotification": bool notifyModeratorOnly = false; ForumNotification.NotifySubscribers( forum, thread, module, postUser, siteSettings, config, SiteUtils.GetNavigationSiteRoot(), modReq.PageId, modReq.PageNumber, SiteUtils.GetDefaultCulture(), ForumConfiguration.GetSmtpSettings(), notifyModeratorOnly ); thread.NotificationSent = true; thread.UpdatePost(); result.Msg = "success"; break; case "marksent": thread.NotificationSent = true; thread.UpdatePost(); //System.Threading.Thread.Sleep(7000); result.Msg = "success"; break; } } return(result); }
/// <summary> /// Takes in a discussion notification with it's existing follower list. /// Gets the follower list from the repo for the movie noted in the discussion. /// Adds movie follower list to existing list. /// </summary> /// <param name="forumNote"></param> /// <returns>ForumNotification</returns> public ForumNotification GetFollowersForForumNotification(ForumNotification forumNote) { if (forumNote.Imdbid != null) { forumNote.Followers = _repo.GetFollowingMoviesByMovieID(forumNote.Imdbid); } return(forumNote); }
public Task <int> SaveForumNotification(ForumNotification newForumNotification) { if (newForumNotification.Id == 0) { return(_database.InsertAsync(newForumNotification)); } else { return(_database.UpdateAsync(newForumNotification)); } }
[HttpPost("discussion/notification")] //Needs endpoint -Larson public async Task <ActionResult <bool> > RetrieveNewDiscussion([FromBody] ForumNotification forumNotification) { var forumNote = _movieLogic.GetFollowersForForumNotification(forumNotification); if (forumNote.Followers != null) { await Logic.ApiHelper.ApiProcessor.SendForumNotification(forumNote); return(StatusCode(200)); } else { return(StatusCode(404)); } }
/// <summary> /// Sends the forum notification on to Users with the list of users who follow the movie the new forum topic belongs to. /// </summary> /// <param name="forumNotification"></param> /// <returns></returns> public static async Task <bool> SendForumNotification(ForumNotification forumNotification) { HttpClientHandler clientHandler = new HttpClientHandler(); clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return(true); }; HttpClient client = new HttpClient(clientHandler); string path = $"{_userapi}notification/discussion"; HttpResponseMessage response = await client.PostAsJsonAsync(path, forumNotification); if (response.IsSuccessStatusCode) { return(true); } else { return(false); } }
private void SendNotification(HttpContext context) { //log.Info("theadId = " + threadId); //log.Info("postId = " + postId); //log.Info("pageId = " + pageId); //log.Info("mid = " + moduleId); bool notifyModeratorOnly = false; ModResult result = new ModResult(); if (LoadAndValidateForumObjects()) { thread.NotificationSent = true; thread.UpdatePost(); ForumNotification.NotifySubscribers( forum, thread, module, postUser, siteSettings, config, SiteUtils.GetNavigationSiteRoot(), pageId, pageNumber, SiteUtils.GetDefaultCulture(), ForumConfiguration.GetSmtpSettings(), notifyModeratorOnly ); result.Msg = "success"; } else { log.Info("Send forum notification request rejected due to invalid params"); result.Msg = "rejected"; } context.Response.ContentType = "application/json"; JavaScriptSerializer s = new JavaScriptSerializer(); context.Response.Write(s.Serialize(result)); }
public Task <int> DeleteForumNotification(ForumNotification forumNotification) { return(_database.DeleteAsync(forumNotification)); }