1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-26 13:38:52 +00:00

Create postMovieID method

This commit is contained in:
Pierre HUBERT 2020-04-18 11:44:27 +02:00
parent 3058069a7d
commit e06cb1b28c
2 changed files with 16 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}
}