Sync createPrivateGroup and createChannel parameter order for readOnly and customFields

pull/994/merge
Gabriel Engel 8 years ago
parent 6811201ba8
commit 54379d1440
No known key found for this signature in database
GPG Key ID: A9FF0AD7DEE40258
  1. 2
      .meteor/versions
  2. 5
      example-build.sh
  3. 6
      packages/rocketchat-api/server/v1/channels.js
  4. 7
      packages/rocketchat-api/server/v1/groups.js
  5. 6
      packages/rocketchat-lib/server/methods/createChannel.coffee
  6. 6
      packages/rocketchat-lib/server/methods/createPrivateGroup.coffee

@ -101,7 +101,7 @@ oauth1@1.1.11
oauth2@1.1.11
observe-sequence@1.0.14
ordered-dict@1.0.9
ostrio:cookies@2.0.5
ostrio:cookies@2.1.0
pauli:accounts-linkedin@1.3.1
pauli:linkedin@1.3.1
peerlibrary:aws-sdk@2.4.9_1

@ -3,10 +3,13 @@ set -x
set -euvo pipefail
IFS=$'\n\t'
export METEOR_SETTINGS=$(cat settings.json)
# Build
export NODE_ENV=production
meteor add rocketchat:internal-hubot meteorhacks:kadira
meteor build --server https://demo.rocket.chat --directory /var/www/rocket.chat
# Run
export METEOR_SETTINGS=$(cat settings.json)
cd /var/www/rocket.chat/bundle/programs/server
npm install
cd /var/www/rocket.chat/current

@ -135,6 +135,10 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, {
return RocketChat.API.v1.failure('Body param "members" must be an array if provided');
}
if (this.bodyParams.customFields && !(typeof this.bodyParams.customFields === 'object')) {
return RocketChat.API.v1.failure('Body param "customFields" must be an object if provided');
}
let readOnly = false;
if (typeof this.bodyParams.readOnly !== 'undefined') {
readOnly = this.bodyParams.readOnly;
@ -142,7 +146,7 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, {
let id;
Meteor.runAsUser(this.userId, () => {
id = Meteor.call('createChannel', this.bodyParams.name, this.bodyParams.members ? this.bodyParams.members : [], readOnly);
id = Meteor.call('createChannel', this.bodyParams.name, this.bodyParams.members ? this.bodyParams.members : [], readOnly, this.bodyParams.customFields);
});
return RocketChat.API.v1.success({

@ -98,9 +98,14 @@ RocketChat.API.v1.addRoute('groups.create', { authRequired: true }, {
return RocketChat.API.v1.failure('Body param "customFields" must be an object if provided');
}
let readOnly = false;
if (typeof this.bodyParams.readOnly !== 'undefined') {
readOnly = this.bodyParams.readOnly;
}
let id;
Meteor.runAsUser(this.userId, () => {
id = Meteor.call('createPrivateGroup', this.bodyParams.name, this.bodyParams.members ? this.bodyParams.members : [], this.bodyParams.customFields);
id = Meteor.call('createPrivateGroup', this.bodyParams.name, this.bodyParams.members ? this.bodyParams.members : [], readOnly, this.bodyParams.customFields);
});
return RocketChat.API.v1.success({

@ -1,5 +1,5 @@
Meteor.methods
createChannel: (name, members, readOnly) ->
createChannel: (name, members, readOnly = false, customFields = {}) ->
check name, String
check members, Match.Optional([String])
@ -7,7 +7,7 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', "Invalid user", { method: 'createChannel' }
if RocketChat.authz.hasPermission(Meteor.userId(), 'create-c') isnt true
if not RocketChat.authz.hasPermission(Meteor.userId(), 'create-c')
throw new Meteor.Error 'error-not-allowed', "Not allowed", { method: 'createChannel' }
return RocketChat.createRoom('c', name, Meteor.user()?.username, members, readOnly);
return RocketChat.createRoom('c', name, Meteor.user()?.username, members, readOnly, {customFields: customFields});

@ -1,5 +1,5 @@
Meteor.methods
createPrivateGroup: (name, members, customFields) ->
createPrivateGroup: (name, members, readOnly = false, customFields = {}) ->
check name, String
check members, Match.Optional([String])
@ -7,7 +7,7 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', "Invalid user", { method: 'createPrivateGroup' }
unless RocketChat.authz.hasPermission(Meteor.userId(), 'create-p')
if not RocketChat.authz.hasPermission(Meteor.userId(), 'create-p')
throw new Meteor.Error 'error-not-allowed', "Not allowed", { method: 'createPrivateGroup' }
return RocketChat.createRoom('p', name, Meteor.user()?.username, members, {customFields: customFields});
return RocketChat.createRoom('p', name, Meteor.user()?.username, members, readOnly, {customFields: customFields});

Loading…
Cancel
Save