mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 21:39:22 +00:00
Add movies support
This commit is contained in:
parent
6edf39d971
commit
7341475c24
@ -204,7 +204,16 @@ export class PostsController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Personnal movies
|
||||||
|
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!");
|
||||||
|
|
||||||
|
newPost.movieID = movieID;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { RequestHandler } from "../entities/RequestHandler";
|
|
||||||
import { Movie } from "../entities/Movies";
|
import { Movie } from "../entities/Movies";
|
||||||
import { DatabaseHelper } from "./DatabaseHelper";
|
import { DatabaseHelper } from "./DatabaseHelper";
|
||||||
|
|
||||||
@ -46,6 +45,20 @@ export class MoviesHelper {
|
|||||||
return this.DBToMovie(row);
|
return this.DBToMovie(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check out whether a movie belongs to a user or not
|
||||||
|
*
|
||||||
|
* @param userID Target user ID
|
||||||
|
* @param movieID The ID of the movie to check
|
||||||
|
*/
|
||||||
|
public static async DoesUserHas(userID: number, movieID: number): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
return (await this.GetInfo(movieID)).userID == userID;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a database entry into a movie object
|
* Turn a database entry into a movie object
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user