mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
The user is now able to upload an avatar, and pick one in a list. This functionality should eventually be abstracted in a community package but we still need to work on a great public API. We rely on collectionFS to manage uploaded avatars. We also removed bengott:avatar which was trying to solve the wrong problem (namely displaying the avatar, which is as simple as displaying an image), and not a avatar system as it should be. Gravatar support is coming (back) soon. We may also want to have a list of default fun avatars the user can choose instead of uploading its own one.
27 lines
489 B
JavaScript
27 lines
489 B
JavaScript
Avatars = new FS.Collection('avatars', {
|
|
stores: [
|
|
new FS.Store.GridFS('avatars')
|
|
],
|
|
filter: {
|
|
maxSize: 32000,
|
|
allow: {
|
|
contentTypes: ['image/*']
|
|
}
|
|
}
|
|
});
|
|
|
|
var isOwner = function(userId, file) {
|
|
return userId && userId === file.userId;
|
|
};
|
|
|
|
Avatars.allow({
|
|
insert: isOwner,
|
|
update: isOwner,
|
|
remove: isOwner,
|
|
download: function() { return true; },
|
|
fetch: ['userId']
|
|
});
|
|
|
|
Avatars.files.before.insert(function(userId, doc) {
|
|
doc.userId = userId;
|
|
});
|