Merge branch 'version-2' into version-2-tabletop
This commit is contained in:
@@ -51,21 +51,21 @@ const sendMessage = new ValidatedMethod({
|
||||
timeInterval: 5000,
|
||||
},
|
||||
|
||||
run({content, tabletopId}) {
|
||||
run({ content, tabletopId }) {
|
||||
let user = Meteor.user();
|
||||
if (!user) {
|
||||
throw new Meteor.Error('messages.send.denied',
|
||||
'You need to be logged in to send a message');
|
||||
'You need to be logged in to send a message');
|
||||
}
|
||||
assertUserInTabletop(tabletopId, this.userId);
|
||||
|
||||
return Messages.insert({
|
||||
content,
|
||||
content,
|
||||
tabletopId,
|
||||
timestamp: new Date(),
|
||||
userId: user._id,
|
||||
username: user.username,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
@@ -87,24 +87,24 @@ const removeMessages = new ValidatedMethod({
|
||||
timeInterval: 5000,
|
||||
},
|
||||
|
||||
run({messageId, tabletopId}) {
|
||||
run({ messageId, tabletopId }) {
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('messages.remove.denied',
|
||||
'You need to be logged in to remove a tabletop');
|
||||
'You need to be logged in to remove a tabletop');
|
||||
}
|
||||
let message = Messages.findOne(messageId);
|
||||
let tabletop = Tabletops.findOne(message.tabletopId);
|
||||
if (this.userId !== message.userId && this.userId !== tabletop.gameMaster){
|
||||
if (this.userId !== message.userId && this.userId !== tabletop.gameMaster) {
|
||||
throw new Meteor.Error('messages.remove.denied',
|
||||
'You don\'t have permission to remove this message');
|
||||
'You don\'t have permission to remove this message');
|
||||
}
|
||||
let removed = Messages.remove({
|
||||
_id: messageId,
|
||||
});
|
||||
_id: messageId,
|
||||
});
|
||||
Creatures.update({
|
||||
tabletop: tabletopId,
|
||||
}, {
|
||||
$unset: {tabletop: 1},
|
||||
$unset: { tabletop: 1 },
|
||||
});
|
||||
return removed;
|
||||
},
|
||||
|
||||
@@ -19,14 +19,14 @@ const insertTabletop = new ValidatedMethod({
|
||||
run() {
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('tabletops.insert.denied',
|
||||
'You need to be logged in to insert a tabletop');
|
||||
'You need to be logged in to insert a tabletop');
|
||||
}
|
||||
assertUserHasPaidBenefits(this.userId);
|
||||
assertAdmin(this.userId);
|
||||
|
||||
return Tabletops.insert({
|
||||
gameMaster: this.userId,
|
||||
});
|
||||
gameMaster: this.userId,
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -24,22 +24,22 @@ const removeTabletop = new ValidatedMethod({
|
||||
timeInterval: 5000,
|
||||
},
|
||||
|
||||
run({tabletopId}) {
|
||||
run({ tabletopId }) {
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('tabletops.remove.denied',
|
||||
'You need to be logged in to remove a tabletop');
|
||||
'You need to be logged in to remove a tabletop');
|
||||
}
|
||||
assertUserHasPaidBenefits(this.userId);
|
||||
assertUserIsTabletopOwner(tabletopId, this.userId);
|
||||
assertAdmin(this.userId);
|
||||
|
||||
let removed = Tabletops.remove({
|
||||
_id: tabletopId,
|
||||
});
|
||||
_id: tabletopId,
|
||||
});
|
||||
Creatures.update({
|
||||
tabletop: tabletopId,
|
||||
}, {
|
||||
$unset: {tabletop: 1},
|
||||
$unset: { tabletop: 1 },
|
||||
});
|
||||
return removed;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user