Meteor.publish('common-app.avatar-images', function (_id, counter) { if (!_.isArray(_id)) _id = [_id]; return [ AvatarOriginalCollection.find({_id: {$in: _id}, userId: this.userId}), AvatarMediumCollection.find({_id: {$in: _id}, userId: this.userId}), AvatarThumbCollection.find({_id: {$in: _id}, userId: this.userId}) ]; });
archiveTask: function (taskId: string, compt?: number) { check(taskId, String); let c = compt || 0; let user = Meteor.user(); let task = Tasks.findOne(taskId); let auth = false; if (!user || !task) { throw new Meteor.Error('not-authorized'); } let project = Projects.findOne(task.project); if (!project) { throw new Meteor.Error('404', 'project-not-found'); } if (task.owner === user._id) { auth = true; } if (user._id === project.owner) { auth = true; } if (!auth) { throw new Meteor.Error('not-authorized'); } Tasks.update(taskId, { $set: { archived: true, archivor: user._id } }); if (task.hasSubTasks) { // on update et complete les sub tasks (qui ne le sont pas uniquement). Tasks.update( { parentTask: task._id, archived: false, }, { $set: { archivor: user._id, archived: true } }, { multi: true } ); if (c >= 100) { throw new Meteor.Error('500', 'too-many-rec'); } task.subTasks.forEach((subTaskId) => { Meteor.call('archiveTask', subTaskId, c+1); }); } },
'tasks.addTask': function(text) { Tasks.insert({ text: text, checked: false, private: false }); },
Meteor.publish("counts-by-room", function (roomId: string) { var self = this; check(roomId, String); var count = 0; var initializing = true; var handle = Messages.find({ roomId: roomId }).observeChanges({ added: function (id: any) { count++; // if (!initializing) // this.changed("counts", roomId, {count: count}); }, removed: function (id: any) { count--; // Todo: Not sure how to define in typescript // self.changed("counts", roomId, {count: count}); } }); initializing = false; // Todo: Not sure how to define in typescript // self.added("counts", roomId, {count: count}); self.ready(); self.onStop(function () { handle.stop(); }); });
destroyComponentUpload: function() { // On retire tous les fichiers non link a au moins 1 projet et appartenant au user co. // finalement on ne regarde meme pas filesIds /*let f = MyFiles.find({ userId: Meteor.userId(), projectId: { $exists: false } }); console.log('Files will be removed (destroyed component):', f.count());*/ MyFiles.remove({ userId: Meteor.userId(), projectId: {$exists: false} }); },
export function recordEvent(charId: number, text: string) { EventLog.insert({ text: text, time: new Date(), charid: charId, }); }
Meteor.publish('tasks.public', function() { return Tasks.find({ $or: [ { private: { $ne: true } }, { owner: this.userId } ] }); });
'tasks.addTask': function(text: string) { Tasks.insert({ text: text, checked: false, private: false, createdAt: new Date() }); },
removeTask: function (taskId: string) { let user = Meteor.user(); if (!user) { throw new Meteor.Error('403', 'not-authorized'); } let task = Tasks.findOne(taskId); if (!task) { throw new Meteor.Error('404', 'not-found'); } if (task.owner !== user._id) { throw new Meteor.Error('403', 'not-authorized'); } if (task.hasSubTasks || task.isSubTask) { throw new Meteor.Error('400', 'task-with-sub-tasks-or-parent'); } MyFiles.remove({ modelName: 'task', modelId: taskId }); // on spécifie aussi le owner dans le remove Tasks.remove({ _id: taskId, owner: user._id }); }
function addAction(action:GamePlayAction, userId:string):string { if (action.creatorId !== userId) throw new Meteor.Error('invalid-user', 'current userId does not match user ID of passed object'); checkUser(action.gameId, action.creatorId); action.cardsEncoded = CardEncoder.encodeCards(action.cards); if (action.gameConfig) { action.gameConfig._deck_id = action.gameConfig.deck.id; } else { } return GamePlayActionCollection.insert(action); }