1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 16:45:16 +00:00

Start to process user account image

This commit is contained in:
2019-11-23 16:10:51 +01:00
parent 1ff0a72b70
commit b6294870ce
7 changed files with 179 additions and 4 deletions

View File

@ -0,0 +1,43 @@
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);
}
}

View File

@ -167,6 +167,13 @@ export class RequestHandler {
return this.userID;
}
/**
* Check out whether user is signed in or not
*/
public get signedIn() : boolean {
return this.userID > 0;
}
/**
* Output an error code and throws an error
*

View File

@ -1,3 +1,5 @@
import { AccountImage } from "./AccountImage";
/**
* User information
*
@ -17,6 +19,7 @@ export interface UserBuilder {
timeCreate: number,
virtualDirectory: string,
pageStatus: UserPageStatus,
accountImage: AccountImage,
}
export class User {
@ -26,6 +29,7 @@ export class User {
timeCreate: number;
virtualDirectory: string;
pageStatus: UserPageStatus;
accountImage: AccountImage;
public constructor(info : UserBuilder) {
this.id = info.id;
@ -34,6 +38,7 @@ export class User {
this.timeCreate = info.timeCreate;
this.virtualDirectory = info.virtualDirectory;
this.pageStatus = info.pageStatus;
this.accountImage = info.accountImage;
}
}