mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 23:09:22 +00:00
Return information about a single movie
This commit is contained in:
parent
87daf8acbe
commit
f18a0952d6
@ -26,7 +26,7 @@ export class MoviesController {
|
||||
*
|
||||
* @param m The movie to convert
|
||||
*/
|
||||
private static MovieToAPI(m: Movie): any {
|
||||
public static MovieToAPI(m: Movie): any {
|
||||
return {
|
||||
id: m.id,
|
||||
uri: m.uri,
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { UserHelper } from "../helpers/UserHelper";
|
||||
import { PostsHelper } from "../helpers/PostsHelper";
|
||||
import { Post, PostVisibilityLevel } from "../entities/Post";
|
||||
import { Post, PostVisibilityLevel, PostKind } from "../entities/Post";
|
||||
import { MoviesController } from "./MoviesController";
|
||||
import { MoviesHelper } from "../helpers/MoviesHelper";
|
||||
|
||||
/**
|
||||
* Posts controller
|
||||
@ -60,7 +62,13 @@ export class PostsController {
|
||||
file_size: !p.hasFile ? null : p.file.size,
|
||||
file_type: !p.hasFile ? null : p.file.type,
|
||||
file_path: !p.hasFile ? null : p.file.path,
|
||||
file_url: !p.hasFile ? null : p.file.url
|
||||
file_url: !p.hasFile ? null : p.file.url,
|
||||
|
||||
|
||||
// Movie specific
|
||||
video_id: p.kind == PostKind.POST_KIND_MOVIE ? p.movieID : null,
|
||||
video_info: p.kind == PostKind.POST_KIND_MOVIE ?
|
||||
MoviesController.MovieToAPI(await MoviesHelper.GetInfo(p.movieID)) : null
|
||||
};
|
||||
|
||||
return data;
|
||||
|
@ -27,6 +27,25 @@ export class MoviesHelper {
|
||||
})).map((row) => this.DBToMovie(row));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a single movie
|
||||
*
|
||||
* @param movieID The movie to get
|
||||
*/
|
||||
public static async GetInfo(movieID: number) : Promise<Movie> {
|
||||
const row = await DatabaseHelper.QueryRow({
|
||||
table: MOVIES_TABLE,
|
||||
where: {
|
||||
ID: movieID
|
||||
}
|
||||
});
|
||||
|
||||
if(row == null)
|
||||
throw Error("Movie " + movieID + " could not be found!");
|
||||
|
||||
return this.DBToMovie(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a database entry into a movie object
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user