From 4ff95c44b8266171426ccbb47f6b30f84648a730 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 22 Mar 2018 16:03:09 +0100 Subject: [PATCH] [lib.content-controller] message management + get user data --- webpack/lib/content-controller.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/webpack/lib/content-controller.js b/webpack/lib/content-controller.js index 1d91075..a9fc6b7 100644 --- a/webpack/lib/content-controller.js +++ b/webpack/lib/content-controller.js @@ -46,4 +46,33 @@ export class ContentController{ get messages(){ return this.rbuf.messages; } get members(){ return this.rbuf.members; } + + /* (5) User getter + * + * @user_id User id + * + * @return user User data + * + ---------------------------------------------------------*/ + user(user_id=null){ + + /* (1) Error: if invalid user_id */ + if( isNaN(user_id) ) + return {}; + + /* (2) Error: unknown user */ + if( this.cbuf.users == null || this.cbuf.users.length < 1 ) + return {}; + + /* (3) return user data */ + for( let u of this.cbuf.users ) + if( u.uid === user_id ) + return u; + + /* (4) Error */ + return {}; + + } + + } \ No newline at end of file