public async Task <IActionResult> GetComment(int commentId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } return(Ok(await _feedService.GetCommentByIdAsync(commentId, ct))); }
public async Task <IActionResult> GetMyDTOPosts(string uuid = "", CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } return(Ok(await _feedService.GetAllDTOPostsForUserAsync(!string.IsNullOrEmpty(uuid) ? uuid : AuthenticationUtilities.GetUUIDFromIdentity(User), ct))); }
public async Task <IActionResult> GetAditLogsAsync(int teamId = 0, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } return(Ok(await _feedService.GetAllAditLogsAsync(teamId, ct))); }
public async Task <IActionResult> CreateNewAditLog([FromBody] AditLog aditLog, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } return(Ok(await _feedService.UploadNewAditLogAsync(aditLog, ct))); }
public async Task <IActionResult> ReportUser([FromBody] FeedReport report, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } await _feedService.ReportPostAsync(report, ct); return(Ok()); }
public async Task <IActionResult> GetFeed(long startfrom, int limit = 10, int teamId = 0, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (startfrom == 0) { startfrom = DateTime.UtcNow.Millisecond; } return(Ok(await _feedService.GetAllAsync(startfrom, teamId, limit, ct))); }
public async Task <IActionResult> UploadFeedMediaAttachment() { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (HttpContext.Request.Form.Files.Count > 0) { return(Ok(await _feedService.UploadMediaAttachmentAsync(HttpContext.Request.Form.Files[0]))); } return(BadRequest()); }
public async Task <IActionResult> UploadAditLogAttachment(bool isVideo = false, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } if (HttpContext.Request.Form.Files.Count >= 1) { return(Ok(await _feedService.UploadAditLogMediaAsync(HttpContext.Request.Form.Files.FirstOrDefault(), isVideo, ct: ct))); } return(BadRequest("No files uploaded")); }
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> DeleteAditLog(int aditLogId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } AditLog aditLog = await _feedService.GetAditLogAsync(aditLogId); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, aditLog.PosterUUID)) { return(Unauthorized("You do not have access to modify this Adit Log")); } await _feedService.MarkAditLogAsDeletedAsync(aditLogId, ct); return(Ok()); }
public async Task <IActionResult> DeletePost(int feedPostId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } FeedPost post = await _feedService.GetByIdAsync(feedPostId); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, post.PosterUUID)) { return(Unauthorized("You do not have access to modify this post")); } await _feedService.MarkPostAsDeletedAsync(feedPostId, ct); return(Ok()); }
public async Task <IActionResult> DeleteComment(int commentId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } FeedComment comment = await _feedService.GetCommentByIdAsync(commentId, ct); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, comment.UserUUID)) { return(Unauthorized("You do not have access to delete this comment")); } await _feedService.MarkFeedCommentAsDeletedAsync(commentId, ct); 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()); }