mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Create postMovieID method
This commit is contained in:
parent
3058069a7d
commit
e06cb1b28c
@ -213,10 +213,7 @@ export class PostsController {
|
||||
|
||||
// Personnal movies posts
|
||||
case PostKind.POST_KIND_MOVIE:
|
||||
const movieID = h.postInt("movieID");
|
||||
|
||||
if(!await MoviesHelper.DoesUserHas(h.getUserId(), movieID))
|
||||
h.error(401, "You are not authorized to use this movie!");
|
||||
const movieID = await h.postMovieID("movieID");
|
||||
|
||||
newPost.movieID = movieID;
|
||||
|
||||
|
@ -18,6 +18,7 @@ import { ConversationsHelper } from "../helpers/ConversationsHelper";
|
||||
import { AbstractUserConnectionContainer } from "./UserConnectionContainer";
|
||||
import { CustomEmoji } from "./CustomEmoji";
|
||||
import { CustomEmojisHelper } from "../helpers/CustomEmojisHelper";
|
||||
import { MoviesHelper } from "../helpers/MoviesHelper";
|
||||
|
||||
export abstract class BaseRequestsHandler implements AbstractUserConnectionContainer {
|
||||
|
||||
@ -437,4 +438,18 @@ export abstract class BaseRequestsHandler implements AbstractUserConnectionConta
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a movie included in a POST request
|
||||
*
|
||||
* @param name The name of the POSt field containing movie ID
|
||||
*/
|
||||
public async postMovieID(name: string) : Promise<number> {
|
||||
const movieID = this.postInt(name);
|
||||
|
||||
if(!await MoviesHelper.DoesUserHas(this.getUserId(), movieID))
|
||||
this.error(401, "You are not authorized to use this movie!");
|
||||
|
||||
return movieID;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user