Skip to content
Snippets Groups Projects
Commit 6b68ab94 authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #4660 from bnagydeveloper/develop

Added room archive and unarchive api endpoints
parents 9767726f b17cddba
No related merge requests found
...@@ -240,3 +240,39 @@ Api.addRoute 'bulk/createRoom', authRequired: true, ...@@ -240,3 +240,39 @@ Api.addRoute 'bulk/createRoom', authRequired: true,
console.log '[restapi] bulk/createRoom -> '.red, "User does not have 'bulk-create-c' permission" console.log '[restapi] bulk/createRoom -> '.red, "User does not have 'bulk-create-c' permission"
statusCode: 403 statusCode: 403
body: status: 'error', message: 'You do not have permission to do this' body: status: 'error', message: 'You do not have permission to do this'
# archive a room by it's ID
Api.addRoute 'room/:id/archive', authRequired: true,
post:
action: ->
# user must also have archive-room permission
if RocketChat.authz.hasPermission(@userId, 'archive-room')
try
Meteor.runAsUser this.userId, () =>
Meteor.call('archiveRoom', @urlParams.id)
status: 'success' # need to handle error
catch e
statusCode: 400 # bad request or other errors
body: status: 'fail', message: e.name + ' :: ' + e.message
else
console.log '[restapi] archiveRoom -> '.red, "User does not have 'archive-room' permission"
statusCode: 403
body: status: 'error', message: 'You do not have permission to do this'
# unarchive a room by it's ID
Api.addRoute 'room/:id/unarchive', authRequired: true,
post:
action: ->
# user must also have unarchive-room permission
if RocketChat.authz.hasPermission(@userId, 'unarchive-room')
try
Meteor.runAsUser this.userId, () =>
Meteor.call('unarchiveRoom', @urlParams.id)
status: 'success' # need to handle error
catch e
statusCode: 400 # bad request or other errors
body: status: 'fail', message: e.name + ' :: ' + e.message
else
console.log '[restapi] unarchiveRoom -> '.red, "User does not have 'unarchive-room' permission"
statusCode: 403
body: status: 'error', message: 'You do not have permission to do this'
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment