mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 01:58:40 +00:00
parent
30e5d4e3b5
commit
5fd10b2bb1
1 changed files with 17 additions and 0 deletions
|
@ -58,5 +58,22 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
await this.database.SaveChangesAsync();
|
await this.database.SaveChangesAsync();
|
||||||
return this.Ok();
|
return this.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("deleteUserComment/{username}")]
|
||||||
|
public async Task<IActionResult> DeleteComment([FromQuery] int commentId, string username) {
|
||||||
|
User user = await this.database.UserFromRequest(this.Request);
|
||||||
|
if(user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
Comment comment = await this.database.Comments
|
||||||
|
.FirstOrDefaultAsync(c => c.CommentId == commentId);
|
||||||
|
|
||||||
|
if(comment.TargetUserId != user.UserId && comment.PosterUserId != user.UserId)
|
||||||
|
return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
this.database.Comments.Remove(comment);
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue