Skip to content

Commit

Permalink
#527: API for creating report
Browse files Browse the repository at this point in the history
  • Loading branch information
riipah committed Nov 20, 2019
1 parent a6c231e commit c9841c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions VocaDbWeb/Controllers/Api/UserApiController.cs
Expand Up @@ -675,6 +675,19 @@ public class UserEventAssociation {

}

public class CreateReportModel {
public UserReportType ReportType { get; set; }
public string Reason { get; set; }
}

[Authorize]
[Route("{id:int}/reports")]
public void PostReport(int id, [FromBody] CreateReportModel model) {

queries.CreateReport(id, model.ReportType, WebHelper.GetRealHost(Request), model.Reason);

}

[Route("current/followedTags/{tagId:int}")]
[Authorize]
public void PostFollowedTag(int tagId) {
Expand Down
8 changes: 8 additions & 0 deletions VocaDbWeb/Scripts/ViewModels/User/UserDetailsViewModel.ts
Expand Up @@ -47,6 +47,14 @@ module vdb.viewModels.user {
});
});

public reportUserViewModel = new DeleteEntryViewModel(notes => {
$.ajax(this.urlMapper.mapRelative("api/users/" + this.userId + "/reports"), {
type: 'POST', data: { reason: notes, reportType: 'Spamming' }, success: () => {
window.location.reload();
}
});
});

public initComments = () => {

this.comments.initComments();
Expand Down

0 comments on commit c9841c2

Please sign in to comment.