[lib.content-controller] message management + get user data
This commit is contained in:
parent
568a9fb16a
commit
4ff95c44b8
|
@ -46,4 +46,33 @@ export class ContentController{
|
|||
get messages(){ return this.rbuf.messages; }
|
||||
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 {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue