Add an api method for getting a single message by id, #6783
parent
caeea7922d
commit
e76d6e36f4
@ -0,0 +1,19 @@ |
|||||||
|
Meteor.methods({ |
||||||
|
getSingleMessage(msgId) { |
||||||
|
check(msgId, String); |
||||||
|
|
||||||
|
if (!Meteor.userId()) { |
||||||
|
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getSingleMessage' }); |
||||||
|
} |
||||||
|
|
||||||
|
const msg = RocketChat.models.Messages.findOneById(msgId); |
||||||
|
|
||||||
|
if (!msg && !msg.rid) { |
||||||
|
return undefined; |
||||||
|
} |
||||||
|
|
||||||
|
Meteor.call('canAccessRoom', msg.rid, Meteor.userId()); |
||||||
|
|
||||||
|
return msg; |
||||||
|
} |
||||||
|
}); |
||||||
Loading…
Reference in new issue