Have 3 explicit avatar options

custom image, gravatar or none
This commit is contained in:
Johannes Zellner
2021-07-07 14:39:17 +02:00
parent 2caac75dbd
commit d292d5d419
4 changed files with 192 additions and 45 deletions

View File

@@ -1805,28 +1805,29 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.clearAvatar = function (callback) {
del('/api/v1/profile/avatar', {}, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
});
};
Client.prototype.changeAvatar = function (avatarFileOrType, callback) {
// Blob type if object
if (typeof avatarFileOrType === 'object') {
var fd = new FormData();
fd.append('avatar', avatarFileOrType);
Client.prototype.changeAvatar = function (avatarFile, callback) {
var fd = new FormData();
fd.append('avatar', avatarFile);
var config = {
headers: { 'Content-Type': undefined },
transformRequest: angular.identity
};
var config = {
headers: { 'Content-Type': undefined },
transformRequest: angular.identity
};
post('/api/v1/profile/avatar', fd, config, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
});
post('/api/v1/profile/avatar', fd, config, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
});
} else {
post('/api/v1/profile/avatar', { avatar: avatarFileOrType === 'gravatar' ? 'gravatar' : '' }, null, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
});
}
};
Client.prototype.changePassword = function (currentPassword, newPassword, callback) {