Make testing for moderator state centralized in User class

This commit is contained in:
Gabe Kangas
2023-03-03 21:54:01 -08:00
parent e5dee5d258
commit c4f057eded
6 changed files with 59 additions and 27 deletions

View File

@ -1,10 +1,37 @@
export interface User {
/* eslint-disable import/prefer-default-export */
export class User {
constructor(u) {
this.id = u.id;
this.displayName = u.displayName;
this.displayColor = u.displayColor;
this.createdAt = u.createdAt;
this.previousNames = u.previousNames;
this.nameChangedAt = u.nameChangedAt;
this.scopes = u.scopes;
this.authenticated = u.authenticated;
}
id: string;
displayName: string;
displayColor: number;
createdAt: Date;
previousNames: string[];
nameChangedAt: Date;
scopes: string[];
authenticated: boolean;
public isModerator = (): boolean => {
if (!this.scopes || this.scopes.length === 0) {
return false;
}
return this.scopes.includes('moderator');
};
}