From f0c8781ba70d5c93de9b43540cd421590c644a06 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 3 Jan 2020 10:30:37 +0100 Subject: [PATCH] Post are more complete --- src/controllers/PostsController.ts | 17 ++++++++++++++--- src/entities/Post.ts | 12 ++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/controllers/PostsController.ts b/src/controllers/PostsController.ts index ae3ff2e..d3b115f 100644 --- a/src/controllers/PostsController.ts +++ b/src/controllers/PostsController.ts @@ -58,6 +58,7 @@ export class PostsController { visibility_level: VISIBILITY_LEVELS_API[p.visibilityLevel], kind: p.kind, + // File specific file_size: !p.hasFile ? null : p.file.size, file_type: !p.hasFile ? null : p.file.type, @@ -66,9 +67,19 @@ export class PostsController { // 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 + video_id: p.hasMovie ? p.movieID : null, + video_info: p.hasMovie ? + MoviesController.MovieToAPI(await MoviesHelper.GetInfo(p.movieID)) : null, + + + // Countdown timer specific + time_end: p.hasTimeEnd ? p.timeEnd : null, + + // Weblink specific + link_url: !p.hasLink ? null : p.link.url, + link_title: !p.hasLink ? null : p.link.title, + link_description: !p.hasLink ? null : p.link.description, + link_image: !p.hasLink ? null : p.link.image }; return data; diff --git a/src/entities/Post.ts b/src/entities/Post.ts index 2489d2c..b1efb1e 100644 --- a/src/entities/Post.ts +++ b/src/entities/Post.ts @@ -148,4 +148,16 @@ export class Post implements PostBuilder { get hasFile() : boolean { return this.file != null && this.file != undefined; } + + get hasMovie() : boolean { + return this.kind == PostKind.POST_KIND_MOVIE; + } + + get hasTimeEnd() : boolean { + return this.kind == PostKind.POST_KIND_COUNTDOWN; + } + + get hasLink() : boolean { + return this.kind == PostKind.POST_KIND_WEBLINK; + } } \ No newline at end of file