public static BaseEntryFlagRequestBuilder Flag(ModerationFlag moderationFlag) { return(new BaseEntryFlagRequestBuilder(moderationFlag)); }
public BaseEntryFlagRequestBuilder(ModerationFlag moderationFlag) : this() { this.ModerationFlag = moderationFlag; }
public async Task SetPostCategory(string username, string password, int postId, ModerationFlag category) { var thread = await GetThread(postId); int categoryInt; switch (category) { case ModerationFlag.OnTopic: categoryInt = 5; break; case ModerationFlag.Nws: categoryInt = 2; break; case ModerationFlag.Stupid: categoryInt = 3; break; case ModerationFlag.Political: categoryInt = 9; break; case ModerationFlag.Tangent: categoryInt = 4; break; case ModerationFlag.Informative: categoryInt = 1; break; case ModerationFlag.Nuked: categoryInt = 8; break; default: throw new Api400Exception("Unexpected category string."); } var query = _downloadService.NewQuery(); query.Add("root", $"{thread.ThreadId}"); query.Add("post_id", $"{postId}"); query.Add("mod_type_id", $"{categoryInt}"); var response = await _downloadService.DownloadWithUserLogin( "https://www.shacknews.com/mod_chatty.x?" + query.ToString(), username, password); if (response.Contains("Invalid moderation flags", StringComparison.Ordinal)) { throw new Api500Exception("Possible bug in the API. Server does not understand the moderation flag."); } if (!response.Contains("navigate_page_no_history( window, \"/frame_chatty.x?root=", StringComparison.Ordinal)) { throw new Api400Exception(Api400Exception.Codes.NOT_MODERATOR, "Failed to set the post category. User likely does not have moderator privileges."); } }