Use shared models
[oweals/peertube.git] / client / src / app / shared / users / user.model.ts
1 import { User as UserServerModel } from '../../../../../shared';
2
3 export class User implements UserServerModel {
4   id: number;
5   username: string;
6   email: string;
7   role: string;
8   displayNSFW: boolean;
9   createdAt: Date;
10
11   constructor(hash: {
12     id: number,
13     username: string,
14     email: string,
15     role: string,
16     displayNSFW?: boolean,
17     createdAt?: Date,
18   }) {
19     this.id = hash.id;
20     this.username = hash.username;
21     this.email = hash.email;
22     this.role = hash.role;
23     this.displayNSFW = hash.displayNSFW;
24
25     if (hash.createdAt) {
26       this.createdAt = hash.createdAt;
27     }
28   }
29
30   isAdmin() {
31     return this.role === 'admin';
32   }
33 }