2019-05-22 14:12:11 +02:00
|
|
|
import { IPicture } from '@/types/picture.model';
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
export enum ActorType {
|
|
|
|
PERSON = 'PERSON',
|
|
|
|
APPLICATION = 'APPLICATION',
|
|
|
|
GROUP = 'GROUP',
|
|
|
|
ORGANISATION = 'ORGANISATION',
|
|
|
|
SERVICE = 'SERVICE',
|
|
|
|
}
|
|
|
|
|
2019-04-26 15:22:16 +02:00
|
|
|
export interface IActor {
|
2019-06-17 17:15:27 +02:00
|
|
|
id?: number;
|
2019-04-26 15:22:16 +02:00
|
|
|
url: string;
|
|
|
|
name: string;
|
|
|
|
domain: string|null;
|
|
|
|
summary: string;
|
|
|
|
preferredUsername: string;
|
|
|
|
suspended: boolean;
|
2019-05-22 14:12:11 +02:00
|
|
|
avatar: IPicture | null;
|
|
|
|
banner: IPicture | null;
|
2019-12-03 11:29:51 +01:00
|
|
|
type: ActorType;
|
2019-04-26 15:22:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Actor implements IActor {
|
2019-06-17 17:15:27 +02:00
|
|
|
id?: number;
|
2019-05-22 14:12:11 +02:00
|
|
|
avatar: IPicture | null = null;
|
|
|
|
banner: IPicture | null = null;
|
2019-04-26 15:22:16 +02:00
|
|
|
domain: string | null = null;
|
|
|
|
name: string = '';
|
|
|
|
preferredUsername: string = '';
|
|
|
|
summary: string = '';
|
|
|
|
suspended: boolean = false;
|
|
|
|
url: string = '';
|
2019-12-03 11:29:51 +01:00
|
|
|
type: ActorType = ActorType.PERSON;
|
2019-04-26 15:22:16 +02:00
|
|
|
|
|
|
|
constructor (hash: IActor | {} = {}) {
|
|
|
|
Object.assign(this, hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
get displayNameAndUsername(): string {
|
|
|
|
return `${this.name} (${this.usernameWithDomain})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
usernameWithDomain(): string {
|
|
|
|
const domain = this.domain ? `@${this.domain}` : '';
|
|
|
|
return `@${this.preferredUsername}${domain}`;
|
|
|
|
}
|
|
|
|
|
2019-09-11 09:59:01 +02:00
|
|
|
public displayName(): string {
|
2019-04-26 15:22:16 +02:00
|
|
|
return this.name != null && this.name !== '' ? this.name : this.usernameWithDomain();
|
|
|
|
}
|
|
|
|
}
|