mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Start account image migration
This commit is contained in:
@ -1,13 +1,23 @@
|
||||
import { AccountImage } from "./AccountImage";
|
||||
|
||||
/**
|
||||
* User information
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
import { pathUserData } from "../utils/UserDataUtils";
|
||||
|
||||
export const SupportedLanguages = ["fr", "en"]
|
||||
|
||||
export enum AccountImageVisibilityLevel {
|
||||
FRIENDS = "friends",
|
||||
COMUNIC_USERS = "comunic_users",
|
||||
EVERYONE = "everyone"
|
||||
}
|
||||
|
||||
const defaultAccountImage = "0Reverse.png";
|
||||
const errorAccountImage = "0Red.png";
|
||||
|
||||
|
||||
export enum UserPageStatus {
|
||||
PRIVATE,
|
||||
PUBLIC,
|
||||
@ -21,7 +31,8 @@ export interface UserInfo {
|
||||
timeCreate: number,
|
||||
virtualDirectory: string,
|
||||
pageStatus: UserPageStatus,
|
||||
accountImage: AccountImage,
|
||||
accountImagePath: string,
|
||||
accountImageVisibilityLevel: AccountImageVisibilityLevel,
|
||||
friendsListPublic: boolean,
|
||||
personnalWebsite ?: string,
|
||||
publicNote ?: string,
|
||||
@ -70,7 +81,6 @@ export class User implements UserBuilder {
|
||||
timeCreate: number;
|
||||
virtualDirectory: string;
|
||||
pageStatus: UserPageStatus;
|
||||
accountImage: AccountImage;
|
||||
friendsListPublic: boolean;
|
||||
personnalWebsite?: string;
|
||||
publicNote?: string;
|
||||
@ -78,6 +88,8 @@ export class User implements UserBuilder {
|
||||
allowPostsFromFriends: boolean;
|
||||
allowMails: boolean;
|
||||
lang: string;
|
||||
accountImagePath: string;
|
||||
accountImageVisibilityLevel: AccountImageVisibilityLevel;
|
||||
security_question_1?: string;
|
||||
security_answer_1?: string;
|
||||
security_question_2?: string;
|
||||
@ -93,6 +105,46 @@ export class User implements UserBuilder {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get account image URL
|
||||
*/
|
||||
get accountImageURL() : string {
|
||||
if(this.accountImagePath.length < 1)
|
||||
return User.pathForAccountImageFile(defaultAccountImage);
|
||||
|
||||
return User.pathForAccountImageFile(this.accountImagePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account image sys path
|
||||
*/
|
||||
get accountImageSysPath() : string {
|
||||
if(this.accountImagePath.length < 1)
|
||||
throw new Error("This user has no account image!");
|
||||
|
||||
return User.pathForAccountImageFile(this.accountImagePath, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out whether the user has an account image
|
||||
* or if it is the default account image
|
||||
*/
|
||||
get hasAccountImage() : boolean {
|
||||
return this.accountImagePath.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback account image URL
|
||||
*/
|
||||
static get errorAccountImageURL() : string {
|
||||
return this.pathForAccountImageFile(errorAccountImage);
|
||||
}
|
||||
|
||||
private static pathForAccountImageFile(file : string, sysPath = false) : string {
|
||||
return pathUserData("avatars/" + file, sysPath);
|
||||
}
|
||||
|
||||
|
||||
get isPublic() : boolean {
|
||||
return this.pageStatus != UserPageStatus.PRIVATE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user