1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-03-21 21:30:46 +00:00
comunicapiv2/src/entities/AccountImage.ts

43 lines
833 B
TypeScript
Raw Normal View History

2019-11-23 16:10:51 +01:00
import { pathUserData } from "../utils/UserDataUtils";
/**
* Single user account image
*
* @author Pierre HUBERT
*/
const defaultAccountImage = "0Reverse.png";
const errorAccountImage = "0Red.png";
export enum AccountImageVisibilityLevel {
FRIENDS = 1,
COMUNIC_USERS = 2,
EVERYONE = 3
}
export class AccountImage {
public constructor(
public userID: number,
public path : string,
public level: AccountImageVisibilityLevel
) {}
/**
* Get account image URL
*/
get url() : string {
if(this.path.length < 1)
return AccountImage.urlForFile(defaultAccountImage);
return AccountImage.urlForFile(this.path);
}
static get errorURL() : string {
return this.urlForFile(errorAccountImage);
}
private static urlForFile(file : string) : string {
return pathUserData("avatars/" + file, false);
}
}