[lib.content-controller] message management + get user data

This commit is contained in:
xdrm-brackets 2018-03-22 16:03:09 +01:00
parent 568a9fb16a
commit 4ff95c44b8
1 changed files with 29 additions and 0 deletions

View File

@ -46,4 +46,33 @@ export class ContentController{
get messages(){ return this.rbuf.messages; } get messages(){ return this.rbuf.messages; }
get members(){ return this.rbuf.members; } get members(){ return this.rbuf.members; }
/* (5) User getter
*
* @user_id<int> User id
*
* @return user<array> 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 {};
}
} }