mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Can replace account image
This commit is contained in:
@ -99,6 +99,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/settings/get_account_image", cb: (h) => SettingsController.GetAccountImageSettings(h)},
|
||||
|
||||
{path: "/settings/upload_account_image", cb: (h) => SettingsController.UploadAccountImage(h)},
|
||||
|
||||
|
||||
// Friends controller
|
||||
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
|
||||
|
@ -11,6 +11,7 @@ import { removeHTMLNodes, checkURL, fixEncoding } from "../utils/StringUtils";
|
||||
import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/VirtualDirsUtils";
|
||||
import { AccountHelper } from "../helpers/AccountHelper";
|
||||
import { AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||
import { AccountImageHelper } from "../helpers/AccountImageHelper";
|
||||
|
||||
/**
|
||||
* API account image visibility levels
|
||||
@ -215,4 +216,20 @@ export class SettingsController {
|
||||
visibility: ACCOUNT_IMAGE_VISIBLITY_LEVELS[imageInfo.level]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload new account image
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async UploadAccountImage(h: RequestHandler) {
|
||||
if(!h.hasFile("picture"))
|
||||
h.error(400, "An error occured while receiving the image !")
|
||||
|
||||
const uri = await h.savePostImage("picture", "avatars", 800, 800);
|
||||
|
||||
await AccountImageHelper.Set(h.getUserId(), uri);
|
||||
|
||||
h.success();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user