public async Task <IActionResult> CommentOnPost([FromBody] FeedComment comment, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (!AuthenticationUtilities.IsSameUser(User, comment.UserUUID)) { return(Unauthorized("You do not have access to comment for this user")); } return(Ok(await _feedService.AddCommentToPostAsync(comment, ct))); }
public async Task <IActionResult> ToggleLikeForPost(int feedPostId, string userUUID, CancellationToken ct = default) { if (!AuthenticationUtilities.IsSameUser(User, userUUID)) { return(Unauthorized("You do not have access to Like for this user")); } if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } await _feedService.ToggleLikeForPostAsync(feedPostId, userUUID, ct); return(Ok()); }
public async Task <IActionResult> WatchAditLog(int aditLogId, string userUUID, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (!AuthenticationUtilities.IsSameUser(User, userUUID)) { Unauthorized("You do not have access to mark this adit log as watched"); } await _feedService.WatchAditLogAsync(aditLogId, userUUID, ct); return(Ok()); }
public async Task <IActionResult> VoteForPoll(int pollAnswerId, string userUUID, bool isVotingFor = true) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (!AuthenticationUtilities.IsSameUser(User, userUUID)) { return(Unauthorized("You do not have access to vote for this user")); } await _feedService.VoteForPollAsync(userUUID, pollAnswerId, isVotingFor); return(Ok()); }
public async Task <IActionResult> ResetPollVotes(int postId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } FeedPost post = await _feedService.GetByIdAsync(postId); if (!AuthenticationUtilities.IsSameUser(User, post.PosterUUID)) { return(Unauthorized("You do not have access to edit this post")); } if (post == null || post.PostType != "poll") { return(BadRequest("Poll does not exist at this id")); } await _feedService.ResetPollVotesAsync(postId, ct); return(Ok()); }