@ -18,7 +18,7 @@ function findChannelById({ roomId, checkedArchived = true }) {
}
RocketChat . API . v1 . addRoute ( 'channels.addAll' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
Meteor . runAsUser ( this . userId , ( ) => {
@ -32,7 +32,7 @@ RocketChat.API.v1.addRoute('channels.addAll', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.addModerator' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -46,7 +46,7 @@ RocketChat.API.v1.addRoute('channels.addModerator', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.addOwner' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -60,7 +60,7 @@ RocketChat.API.v1.addRoute('channels.addOwner', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.archive' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
Meteor . runAsUser ( this . userId , ( ) => {
@ -72,7 +72,7 @@ RocketChat.API.v1.addRoute('channels.archive', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.cleanHistory' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
if ( ! this . bodyParams . latest ) {
@ -100,7 +100,7 @@ RocketChat.API.v1.addRoute('channels.cleanHistory', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.close' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId , checkedArchived : false } ) ;
const sub = RocketChat . models . Subscriptions . findOneByRoomIdAndUserId ( findResult . _id , this . userId ) ;
@ -122,7 +122,7 @@ RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.create' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! RocketChat . authz . hasPermission ( this . userId , 'create-p' ) ) {
return RocketChat . API . v1 . unauthorized ( ) ;
}
@ -156,7 +156,7 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.delete' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId , checkedArchived : false } ) ;
//The find method returns either with the group or the failur
@ -172,7 +172,7 @@ RocketChat.API.v1.addRoute('channels.delete', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.getIntegrations' , { authRequired : true } , {
get : function ( ) {
get ( ) {
if ( ! RocketChat . authz . hasPermission ( this . userId , 'manage-integrations' ) ) {
return RocketChat . API . v1 . unauthorized ( ) ;
}
@ -216,7 +216,7 @@ RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.history' , { authRequired : true } , {
get : function ( ) {
get ( ) {
const findResult = findChannelById ( { roomId : this . queryParams . roomId , checkedArchived : false } ) ;
let latestDate = new Date ( ) ;
@ -256,7 +256,7 @@ RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.info' , { authRequired : true } , {
get : function ( ) {
get ( ) {
const findResult = findChannelById ( { roomId : this . queryParams . roomId , checkedArchived : false } ) ;
return RocketChat . API . v1 . success ( {
@ -266,7 +266,7 @@ RocketChat.API.v1.addRoute('channels.info', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.invite' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -282,7 +282,7 @@ RocketChat.API.v1.addRoute('channels.invite', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.join' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
Meteor . runAsUser ( this . userId , ( ) => {
@ -296,7 +296,7 @@ RocketChat.API.v1.addRoute('channels.join', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.kick' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -312,7 +312,7 @@ RocketChat.API.v1.addRoute('channels.kick', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.leave' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
Meteor . runAsUser ( this . userId , ( ) => {
@ -328,7 +328,7 @@ RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, {
RocketChat . API . v1 . addRoute ( 'channels.list' , { authRequired : true } , {
get : {
//This is like this only to provide an example of how we routes can be defined :X
action : function ( ) {
action ( ) {
const { offset , count } = this . getPaginationItems ( ) ;
const { sort , fields , query } = this . parseJsonQuery ( ) ;
@ -352,7 +352,7 @@ RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.list.joined' , { authRequired : true } , {
get : function ( ) {
get ( ) {
const { offset , count } = this . getPaginationItems ( ) ;
const { sort , fields } = this . parseJsonQuery ( ) ;
let rooms = _ . pluck ( RocketChat . models . Subscriptions . findByTypeAndUserId ( 'c' , this . userId ) . fetch ( ) , '_room' ) ;
@ -375,7 +375,7 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.online' , { authRequired : true } , {
get : function ( ) {
get ( ) {
const { query } = this . parseJsonQuery ( ) ;
const ourQuery = Object . assign ( { } , query , { t : 'c' } ) ;
@ -408,7 +408,7 @@ RocketChat.API.v1.addRoute('channels.online', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.open' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId , checkedArchived : false } ) ;
const sub = RocketChat . models . Subscriptions . findOneByRoomIdAndUserId ( findResult . _id , this . userId ) ;
@ -430,7 +430,7 @@ RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.removeModerator' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -444,7 +444,7 @@ RocketChat.API.v1.addRoute('channels.removeModerator', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.removeOwner' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId } ) ;
const user = this . getUserFromParams ( ) ;
@ -458,7 +458,7 @@ RocketChat.API.v1.addRoute('channels.removeOwner', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.rename' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . name || ! this . bodyParams . name . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "name" is required' ) ;
}
@ -480,7 +480,7 @@ RocketChat.API.v1.addRoute('channels.rename', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setDescription' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . description || ! this . bodyParams . description . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "description" is required' ) ;
}
@ -502,7 +502,7 @@ RocketChat.API.v1.addRoute('channels.setDescription', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setJoinCode' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . joinCode || ! this . bodyParams . joinCode . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "joinCode" is required' ) ;
}
@ -520,7 +520,7 @@ RocketChat.API.v1.addRoute('channels.setJoinCode', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setPurpose' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . purpose || ! this . bodyParams . purpose . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "purpose" is required' ) ;
}
@ -542,7 +542,7 @@ RocketChat.API.v1.addRoute('channels.setPurpose', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setReadOnly' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( typeof this . bodyParams . readOnly === 'undefined' ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "readOnly" is required' ) ;
}
@ -564,7 +564,7 @@ RocketChat.API.v1.addRoute('channels.setReadOnly', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setTopic' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . topic || ! this . bodyParams . topic . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "topic" is required' ) ;
}
@ -586,7 +586,7 @@ RocketChat.API.v1.addRoute('channels.setTopic', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.setType' , { authRequired : true } , {
post : function ( ) {
post ( ) {
if ( ! this . bodyParams . type || ! this . bodyParams . type . trim ( ) ) {
return RocketChat . API . v1 . failure ( 'The bodyParam "type" is required' ) ;
}
@ -608,7 +608,7 @@ RocketChat.API.v1.addRoute('channels.setType', { authRequired: true }, {
} ) ;
RocketChat . API . v1 . addRoute ( 'channels.unarchive' , { authRequired : true } , {
post : function ( ) {
post ( ) {
const findResult = findChannelById ( { roomId : this . bodyParams . roomId , checkedArchived : false } ) ;
if ( ! findResult . archived ) {