1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 16:45:16 +00:00

Can get the list of movies of the user

This commit is contained in:
2020-01-03 08:39:59 +01:00
parent bb47968626
commit 31c9e758ae
4 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import { RequestHandler } from "../entities/RequestHandler";
import { MoviesHelper } from "../helpers/MoviesHelper";
import { Movie } from "../entities/Movies";
/**
* Movies controller
*
* @author Pierre HUBERT
*/
export class MoviesController {
/**
* Get the list of movies of the user
*
* @param h Request handler
*/
public static async GetList(h: RequestHandler) {
const list = await MoviesHelper.GetListUser(h.getUserId());
h.send(list.map((m) => this.MovieToAPI(m)));
}
/**
* Turn a movie into an API entry
*
* @param m The movie to convert
*/
private static MovieToAPI(m: Movie): any {
return {
id: m.id,
uri: m.uri,
url: m.url,
userID: m.userID,
name: m.name,
file_type: m.fileType,
size: m.size
}
}
}

View File

@ -10,6 +10,7 @@ import { VirtualDirectoryController } from "./VirtualDirectoryController";
import { WebAppControllers } from "./WebAppController";
import { CallsController } from "./CallsController";
import { FriendsController } from "./FriendsController";
import { MoviesController } from "./MoviesController";
/**
* Controllers routes
@ -190,6 +191,11 @@ export const Routes : Route[] = [
// Movies controller
{path: "/movies/get_list", cb: (h) => MoviesController.GetList(h)},
// Virtual directory controller
{path: "/user/findbyfolder", cb: (h) => VirtualDirectoryController.FindUser(h)},