mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 08:35:17 +00:00
Can change account image visibility
This commit is contained in:
@ -103,6 +103,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/settings/delete_account_image", cb: (h) => SettingsController.DeleteAccountImage(h)},
|
||||
|
||||
{path: "/settings/set_account_image_visibility", cb: (h) => SettingsController.SetAccountImageVisibility(h)},
|
||||
|
||||
|
||||
// Friends controller
|
||||
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
|
||||
|
@ -12,6 +12,7 @@ import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/Virt
|
||||
import { AccountHelper } from "../helpers/AccountHelper";
|
||||
import { AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||
import { AccountImageHelper } from "../helpers/AccountImageHelper";
|
||||
import { findKey } from "../utils/ArrayUtils";
|
||||
|
||||
/**
|
||||
* API account image visibility levels
|
||||
@ -242,4 +243,21 @@ export class SettingsController {
|
||||
await AccountImageHelper.Delete(h.getUserId());
|
||||
h.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change account image visibility level
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async SetAccountImageVisibility(h: RequestHandler) {
|
||||
|
||||
const visibilityLevel = findKey(ACCOUNT_IMAGE_VISIBLITY_LEVELS, h.postString("visibility"));
|
||||
if(visibilityLevel == null)
|
||||
h.error(400, "Account image visibility level not understood!");
|
||||
|
||||
await AccountImageHelper.SetVisibilityLevel(
|
||||
h.getUserId(), <AccountImageVisibilityLevel>Number(visibilityLevel));
|
||||
|
||||
h.success();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user