mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-03-21 21:30:46 +00:00
43 lines
833 B
TypeScript
43 lines
833 B
TypeScript
|
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);
|
||
|
}
|
||
|
}
|