-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] REST API endpoint rooms.favorite
to favorite and unfavorite rooms
#10342
Changes from 1 commit
4cbbcd0
a168f83
90c239c
0f3ef7a
7488028
2c5842f
3ba5af0
65d3771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,3 +115,23 @@ RocketChat.API.v1.addRoute('rooms.saveNotification', { authRequired: true }, { | |
return RocketChat.API.v1.success(); | ||
} | ||
}); | ||
|
||
RocketChat.API.v1.addRoute('rooms.favorite/:roomId', { authRequired: true }, { | ||
post() { | ||
const { favorite } = this.bodyParams; | ||
const { roomId } = this.urlParams; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is "roomId" in the url path and "favorite" in the body? Why not everything in the body? 🤔 Like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to follow what was instructed here, but we can put it in the body, no problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you'll notice the suggestion you linked to, both the roomId and the favoriting was in the query parameters and not the body or the url path. |
||
|
||
if (!roomId) { | ||
return RocketChat.API.v1.failure('The \'roomId\' param is required'); | ||
} | ||
|
||
if (!this.bodyParams.hasOwnProperty('favorite')) { | ||
return RocketChat.API.v1.failure('The \'favorite\' param is required'); | ||
} | ||
|
||
Meteor.runAsUser(this.userId, () => Meteor.call('toggleFavorite', roomId, favorite)); | ||
|
||
return RocketChat.API.v1.success(); | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's convert this to be like the other v1 items, where the data is passed into it via the body params. This way it can be either the room name or the id and so we're not changing on people.