-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10105 from RocketChat/feature/rest-api-mentions-o…
…f-channel [NEW] Added endpoint to retrieve mentions of a channel
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/rocketchat-mentions/server/methods/getUserMentionsByChannel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Meteor.methods({ | ||
getUserMentionsByChannel({ roomId, options }) { | ||
check(roomId, String); | ||
|
||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserMentionsByChannel' }); | ||
} | ||
|
||
const room = RocketChat.models.Rooms.findOneById(roomId); | ||
|
||
if (!room) { | ||
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'getUserMentionsByChannel' }); | ||
} | ||
|
||
const user = RocketChat.models.Users.findOneById(Meteor.userId()); | ||
|
||
return RocketChat.models.Messages.findVisibleByMentionAndRoomId(user.username, roomId, options).fetch(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters