mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
initial commit
This commit is contained in:
parent
b7c7d8b449
commit
750811a81f
52 changed files with 25204 additions and 92 deletions
42
imports/api/messages.js
Normal file
42
imports/api/messages.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const Messages = new Mongo.Collection('messages');
|
||||
|
||||
Messages.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.message' (entityId, messageText, imageData, intendedRecipient, isGroupRecipient) {
|
||||
check(entityId, String);
|
||||
check(messageText, String);
|
||||
check(imageData, String);
|
||||
check(intendedRecipient, String);
|
||||
check(isGroupRecipient, Boolean);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('User is not allowed to add new messages in the system, make sure you are logged in.');
|
||||
}
|
||||
|
||||
// need to get the userId and role, and ensure the message is sent properly to the appropriate person / people
|
||||
|
||||
},
|
||||
'delete.message' (messageId) {
|
||||
check(messageId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('User is not allowed to add new messages in the system, make sure you are logged in.');
|
||||
}
|
||||
|
||||
return Messages.update({ _id: messageId }, {
|
||||
$set: {
|
||||
isDeleted: true,
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue