mirror of https://github.com/wekan/wekan
The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
import { Meteor } from 'meteor/meteor';
|
|
import { FilesCollection } from 'meteor/ostrio:files';
|
|
import { createBucket } from './lib/grid/createBucket';
|
|
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
|
import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
|
|
import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
|
|
|
|
const os = require('os');
|
|
|
|
let avatarsBucket;
|
|
if (Meteor.isServer) {
|
|
avatarsBucket = createBucket('avatars');
|
|
}
|
|
|
|
Avatars = new FilesCollection({
|
|
debug: false, // Change to `true` for debugging
|
|
collectionName: 'avatars',
|
|
storagePath: os.tmpdir(),
|
|
allowClientCode: true,
|
|
onBeforeUpload(file) {
|
|
if (file.size <= 72000 && file.type.startsWith('image/')) {
|
|
return true;
|
|
}
|
|
return 'avatar-too-big';
|
|
},
|
|
onAfterUpload: createOnAfterUpload(avatarsBucket),
|
|
interceptDownload: createInterceptDownload(avatarsBucket),
|
|
onAfterRemove: createOnAfterRemove(avatarsBucket),
|
|
});
|
|
|
|
function isOwner(userId, doc) {
|
|
return userId && userId === doc.userId;
|
|
}
|
|
|
|
if (Meteor.isServer) {
|
|
Avatars.allow({
|
|
insert: isOwner,
|
|
update: isOwner,
|
|
remove: isOwner,
|
|
fetch: ['userId'],
|
|
});
|
|
}
|
|
|
|
export default Avatars;
|
|
|