Add initial profile background image handling

This commit is contained in:
Johannes Zellner
2025-03-25 15:05:08 +01:00
parent 1f8cdbaf62
commit 23dd575ce1
6 changed files with 53 additions and 6 deletions
+18
View File
@@ -35,6 +35,8 @@ function create() {
result.body.isAtLeastAdmin = [ ROLES.OWNER, ROLES.ADMIN ].indexOf(result.body.role) !== -1;
result.body.isAtLeastOwner = [ ROLES.OWNER ].indexOf(result.body.role) !== -1;
result.body.backgroundImageUrl = result.body.hasBackgroundImage ? `${API_ORIGIN}/api/v1/profile/background_image?access_token=${accessToken}&bustcache=${Date.now()}` : '';
return [null, result.body];
},
async setPassword(password, newPassword) {
@@ -118,6 +120,22 @@ function create() {
return null;
},
async setBackgroundImage(file) {
const fd = new FormData();
if (file) fd.append('backgroundImage', file);
let error, result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/background_image`, fd, { access_token: accessToken });
} catch (e) {
error = e;
}
if (error) return error;
if (result.status !== 202) return result;
return null;
},
async sendPasswordReset(identifier) {
let error, result;
try {