mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Can get account image settings
This commit is contained in:
parent
ea203e6b3f
commit
d02eb7afce
@ -97,6 +97,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/settings/update_password", cb: (h) => SettingsController.UpdatePassword(h)},
|
||||
|
||||
{path: "/settings/get_account_image", cb: (h) => SettingsController.GetAccountImageSettings(h)},
|
||||
|
||||
|
||||
// Friends controller
|
||||
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
|
||||
|
@ -10,6 +10,16 @@ import { GeneralSettings, UserPageStatus, SupportedLanguages, LangSettings, Secu
|
||||
import { removeHTMLNodes, checkURL, fixEncoding } from "../utils/StringUtils";
|
||||
import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/VirtualDirsUtils";
|
||||
import { AccountHelper } from "../helpers/AccountHelper";
|
||||
import { AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||
|
||||
/**
|
||||
* API account image visibility levels
|
||||
*/
|
||||
const ACCOUNT_IMAGE_VISIBLITY_LEVELS = {};
|
||||
ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.EVERYONE] = "open";
|
||||
ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.COMUNIC_USERS] = "public";
|
||||
ACCOUNT_IMAGE_VISIBLITY_LEVELS[AccountImageVisibilityLevel.FRIENDS] = "friends";
|
||||
|
||||
|
||||
export class SettingsController {
|
||||
|
||||
@ -190,4 +200,19 @@ export class SettingsController {
|
||||
|
||||
h.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account image settings
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async GetAccountImageSettings(h: RequestHandler) {
|
||||
const imageInfo = (await UserHelper.GetUserInfo(h.getUserId())).accountImage;
|
||||
|
||||
h.send({
|
||||
has_image: imageInfo.hasImage,
|
||||
image_url: imageInfo.url,
|
||||
visibility: ACCOUNT_IMAGE_VISIBLITY_LEVELS[imageInfo.level]
|
||||
});
|
||||
}
|
||||
}
|
@ -33,6 +33,14 @@ export class AccountImage {
|
||||
return AccountImage.urlForFile(this.path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out whether the user has an account image
|
||||
* or if it is the default account image
|
||||
*/
|
||||
get hasImage() : boolean {
|
||||
return this.path.length > 0;
|
||||
}
|
||||
|
||||
static get errorURL() : string {
|
||||
return this.urlForFile(errorAccountImage);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user