Skip to content
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] Route to get updated roles after a date #16610

Merged
merged 11 commits into from
Mar 20, 2020
13 changes: 13 additions & 0 deletions app/api/server/v1/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ API.v1.addRoute('roles.list', { authRequired: true }, {
},
});

// api to to get updated roles after a date(in ISODate format)
API.v1.addRoute('roles.listByUpdatedDate', { authRequired: true }, {
get() {
check(this.bodyParams, {
updatedAfter: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashwaniYDV can you please validate this query parameter, to make sure it is a valid date? Here we have an example: https://github.com/RocketChat/Rocket.Chat/blob/develop/app/api/server/v1/rooms.js#L34-L43

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

});

const roles = Roles.find({ _updatedAt: { $gte: new Date(this.bodyParams.updatedAfter) } }).fetch();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a Model method and put this logic inside it to avoid model logic leak?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure. I'll do it :)


return API.v1.success({ roles });
},
});

API.v1.addRoute('roles.create', { authRequired: true }, {
post() {
check(this.bodyParams, {
Expand Down