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