|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import _ from 'underscore'; |
|
|
|
|
|
|
|
|
|
//Returns the channel IF found otherwise it will return the failure of why it didn't. Check the `statusCode` property
|
|
|
|
|
// Returns the channel IF found otherwise it will return the failure of why it didn't. Check the `statusCode` property
|
|
|
|
|
function findChannelByIdOrName({ params, checkedArchived = true }) { |
|
|
|
|
if ((!params.roomId || !params.roomId.trim()) && (!params.roomName || !params.roomName.trim())) { |
|
|
|
|
throw new Meteor.Error('error-roomid-param-not-provided', 'The parameter "roomId" or "roomName" is required'); |
|
|
|
|
@ -35,9 +35,9 @@ RocketChat.API.v1.addRoute('channels.addAll', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.addModerator', { authRequired: true }, { |
|
|
|
|
@ -51,7 +51,7 @@ RocketChat.API.v1.addRoute('channels.addModerator', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.addOwner', { authRequired: true }, { |
|
|
|
|
@ -65,7 +65,7 @@ RocketChat.API.v1.addRoute('channels.addOwner', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.archive', { authRequired: true }, { |
|
|
|
|
@ -77,7 +77,7 @@ RocketChat.API.v1.addRoute('channels.archive', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, { |
|
|
|
|
@ -99,7 +99,7 @@ RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.counters', { authRequired: true }, { |
|
|
|
|
@ -123,7 +123,7 @@ RocketChat.API.v1.addRoute('channels.counters', { authRequired: true }, { |
|
|
|
|
} |
|
|
|
|
const room = findChannelByIdOrName({ |
|
|
|
|
params: this.requestParams(), |
|
|
|
|
returnUsernames: true |
|
|
|
|
returnUsernames: true, |
|
|
|
|
}); |
|
|
|
|
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(room._id, user); |
|
|
|
|
const lm = room.lm ? room.lm : room._updatedAt; |
|
|
|
|
@ -148,9 +148,9 @@ RocketChat.API.v1.addRoute('channels.counters', { authRequired: true }, { |
|
|
|
|
unreadsFrom, |
|
|
|
|
msgs, |
|
|
|
|
latest, |
|
|
|
|
userMentions |
|
|
|
|
userMentions, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Channel -> create
|
|
|
|
|
@ -185,14 +185,14 @@ function createChannel(userId, params) { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(id.rid, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(id.rid, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RocketChat.API.channels = {}; |
|
|
|
|
RocketChat.API.channels.create = { |
|
|
|
|
validate: createChannelValidator, |
|
|
|
|
execute: createChannel |
|
|
|
|
execute: createChannel, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, { |
|
|
|
|
@ -205,16 +205,16 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, { |
|
|
|
|
try { |
|
|
|
|
RocketChat.API.channels.create.validate({ |
|
|
|
|
user: { |
|
|
|
|
value: userId |
|
|
|
|
value: userId, |
|
|
|
|
}, |
|
|
|
|
name: { |
|
|
|
|
value: bodyParams.name, |
|
|
|
|
key: 'name' |
|
|
|
|
key: 'name', |
|
|
|
|
}, |
|
|
|
|
members: { |
|
|
|
|
value: bodyParams.members, |
|
|
|
|
key: 'members' |
|
|
|
|
} |
|
|
|
|
key: 'members', |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} catch (e) { |
|
|
|
|
if (e.message === 'unauthorized') { |
|
|
|
|
@ -229,7 +229,7 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(RocketChat.API.channels.create.execute(userId, bodyParams)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.delete', { authRequired: true }, { |
|
|
|
|
@ -241,9 +241,9 @@ RocketChat.API.v1.addRoute('channels.delete', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: findResult |
|
|
|
|
channel: findResult, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.files', { authRequired: true }, { |
|
|
|
|
@ -269,7 +269,7 @@ RocketChat.API.v1.addRoute('channels.files', { authRequired: true }, { |
|
|
|
|
sort: sort ? sort : { name: 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count, |
|
|
|
|
fields |
|
|
|
|
fields, |
|
|
|
|
}).fetch(); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
@ -277,9 +277,9 @@ RocketChat.API.v1.addRoute('channels.files', { authRequired: true }, { |
|
|
|
|
count: |
|
|
|
|
files.length, |
|
|
|
|
offset, |
|
|
|
|
total: RocketChat.models.Uploads.find(ourQuery).count() |
|
|
|
|
total: RocketChat.models.Uploads.find(ourQuery).count(), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, { |
|
|
|
|
@ -296,12 +296,12 @@ RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let ourQuery = { |
|
|
|
|
channel: `#${ findResult.name }` |
|
|
|
|
channel: `#${ findResult.name }`, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (includeAllPublicChannels) { |
|
|
|
|
ourQuery.channel = { |
|
|
|
|
$in: [ourQuery.channel, 'all_public_channels'] |
|
|
|
|
$in: [ourQuery.channel, 'all_public_channels'], |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -314,16 +314,16 @@ RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, { |
|
|
|
|
sort: sort ? sort : { _createdAt: 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count, |
|
|
|
|
fields |
|
|
|
|
fields, |
|
|
|
|
}).fetch(); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
integrations, |
|
|
|
|
count: integrations.length, |
|
|
|
|
offset, |
|
|
|
|
total: RocketChat.models.Integrations.find(ourQuery).count() |
|
|
|
|
total: RocketChat.models.Integrations.find(ourQuery).count(), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, { |
|
|
|
|
@ -363,7 +363,7 @@ RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, { |
|
|
|
|
oldest: oldestDate, |
|
|
|
|
inclusive, |
|
|
|
|
count, |
|
|
|
|
unreads |
|
|
|
|
unreads, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -372,7 +372,7 @@ RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(result); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.info', { authRequired: true }, { |
|
|
|
|
@ -380,9 +380,9 @@ RocketChat.API.v1.addRoute('channels.info', { authRequired: true }, { |
|
|
|
|
const findResult = findChannelByIdOrName({ params: this.requestParams(), checkedArchived: false }); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.invite', { authRequired: true }, { |
|
|
|
|
@ -396,9 +396,9 @@ RocketChat.API.v1.addRoute('channels.invite', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.join', { authRequired: true }, { |
|
|
|
|
@ -410,9 +410,9 @@ RocketChat.API.v1.addRoute('channels.join', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.kick', { authRequired: true }, { |
|
|
|
|
@ -426,9 +426,9 @@ RocketChat.API.v1.addRoute('channels.kick', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, { |
|
|
|
|
@ -440,14 +440,14 @@ RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, { |
|
|
|
|
get: { |
|
|
|
|
//This is defined as such only to provide an example of how the routes can be defined :X
|
|
|
|
|
// This is defined as such only to provide an example of how the routes can be defined :X
|
|
|
|
|
action() { |
|
|
|
|
const { offset, count } = this.getPaginationItems(); |
|
|
|
|
const { sort, fields, query } = this.parseJsonQuery(); |
|
|
|
|
@ -459,7 +459,7 @@ RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, { |
|
|
|
|
if (!RocketChat.authz.hasPermission(this.userId, 'view-joined-room')) { |
|
|
|
|
return RocketChat.API.v1.unauthorized(); |
|
|
|
|
} |
|
|
|
|
const roomIds = RocketChat.models.Subscriptions.findByUserIdAndType(this.userId, 'c', { fields: { rid: 1 } }).fetch().map(s => s.rid); |
|
|
|
|
const roomIds = RocketChat.models.Subscriptions.findByUserIdAndType(this.userId, 'c', { fields: { rid: 1 } }).fetch().map((s) => s.rid); |
|
|
|
|
ourQuery._id = { $in: roomIds }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -467,7 +467,7 @@ RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, { |
|
|
|
|
sort: sort ? sort : { name: 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count, |
|
|
|
|
fields |
|
|
|
|
fields, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const total = cursor.count(); |
|
|
|
|
@ -478,10 +478,10 @@ RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, { |
|
|
|
|
channels: rooms, |
|
|
|
|
count: rooms.length, |
|
|
|
|
offset, |
|
|
|
|
total |
|
|
|
|
total, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, { |
|
|
|
|
@ -494,7 +494,7 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, { |
|
|
|
|
sort: sort ? sort : { name: 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count, |
|
|
|
|
fields |
|
|
|
|
fields, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const totalCount = cursor.count(); |
|
|
|
|
@ -504,16 +504,16 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, { |
|
|
|
|
channels: rooms, |
|
|
|
|
offset, |
|
|
|
|
count: rooms.length, |
|
|
|
|
total: totalCount |
|
|
|
|
total: totalCount, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.members', { authRequired: true }, { |
|
|
|
|
get() { |
|
|
|
|
const findResult = findChannelByIdOrName({ |
|
|
|
|
params: this.requestParams(), |
|
|
|
|
checkedArchived: false |
|
|
|
|
checkedArchived: false, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (findResult.broadcast && !RocketChat.authz.hasPermission(this.userId, 'view-broadcast-member-list')) { |
|
|
|
|
@ -527,39 +527,39 @@ RocketChat.API.v1.addRoute('channels.members', { authRequired: true }, { |
|
|
|
|
fields: { 'u._id': 1 }, |
|
|
|
|
sort: { 'u.username': sort.username != null ? sort.username : 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count |
|
|
|
|
limit: count, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const total = subscriptions.count(); |
|
|
|
|
|
|
|
|
|
const members = subscriptions.fetch().map(s => s.u && s.u._id); |
|
|
|
|
const members = subscriptions.fetch().map((s) => s.u && s.u._id); |
|
|
|
|
|
|
|
|
|
const users = RocketChat.models.Users.find({ _id: { $in: members } }, { |
|
|
|
|
fields: { _id: 1, username: 1, name: 1, status: 1, utcOffset: 1 }, |
|
|
|
|
sort: { username: sort.username != null ? sort.username : 1 } |
|
|
|
|
sort: { username: sort.username != null ? sort.username : 1 }, |
|
|
|
|
}).fetch(); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
members: users, |
|
|
|
|
count: users.length, |
|
|
|
|
offset, |
|
|
|
|
total |
|
|
|
|
total, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.messages', { authRequired: true }, { |
|
|
|
|
get() { |
|
|
|
|
const findResult = findChannelByIdOrName({ |
|
|
|
|
params: this.requestParams(), |
|
|
|
|
checkedArchived: false |
|
|
|
|
checkedArchived: false, |
|
|
|
|
}); |
|
|
|
|
const { offset, count } = this.getPaginationItems(); |
|
|
|
|
const { sort, fields, query } = this.parseJsonQuery(); |
|
|
|
|
|
|
|
|
|
const ourQuery = Object.assign({}, query, { rid: findResult._id }); |
|
|
|
|
|
|
|
|
|
//Special check for the permissions
|
|
|
|
|
// Special check for the permissions
|
|
|
|
|
if (RocketChat.authz.hasPermission(this.userId, 'view-joined-room') && !RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(findResult._id, this.userId, { fields: { _id: 1 } })) { |
|
|
|
|
return RocketChat.API.v1.unauthorized(); |
|
|
|
|
} |
|
|
|
|
@ -571,7 +571,7 @@ RocketChat.API.v1.addRoute('channels.messages', { authRequired: true }, { |
|
|
|
|
sort: sort ? sort : { ts: -1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count, |
|
|
|
|
fields |
|
|
|
|
fields, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const total = cursor.count(); |
|
|
|
|
@ -581,9 +581,9 @@ RocketChat.API.v1.addRoute('channels.messages', { authRequired: true }, { |
|
|
|
|
messages, |
|
|
|
|
count: messages.length, |
|
|
|
|
offset, |
|
|
|
|
total |
|
|
|
|
total, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
// TODO: CACHE: I dont like this method( functionality and how we implemented ) its very expensive
|
|
|
|
|
// TODO check if this code is better or not
|
|
|
|
|
@ -626,24 +626,24 @@ RocketChat.API.v1.addRoute('channels.online', { authRequired: true }, { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const online = RocketChat.models.Users.findUsersNotOffline({ |
|
|
|
|
fields: { username: 1 } |
|
|
|
|
fields: { username: 1 }, |
|
|
|
|
}).fetch(); |
|
|
|
|
|
|
|
|
|
const onlineInRoom = []; |
|
|
|
|
online.forEach(user => { |
|
|
|
|
online.forEach((user) => { |
|
|
|
|
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(root._id, user._id, { fields: { _id: 1 } }); |
|
|
|
|
if (subscription) { |
|
|
|
|
onlineInRoom.push({ |
|
|
|
|
_id: user._id, |
|
|
|
|
username: user.username |
|
|
|
|
username: user.username, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
online: onlineInRoom |
|
|
|
|
online: onlineInRoom, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, { |
|
|
|
|
@ -665,7 +665,7 @@ RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.removeModerator', { authRequired: true }, { |
|
|
|
|
@ -679,7 +679,7 @@ RocketChat.API.v1.addRoute('channels.removeModerator', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.removeOwner', { authRequired: true }, { |
|
|
|
|
@ -693,7 +693,7 @@ RocketChat.API.v1.addRoute('channels.removeOwner', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.rename', { authRequired: true }, { |
|
|
|
|
@ -713,9 +713,9 @@ RocketChat.API.v1.addRoute('channels.rename', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setCustomFields', { authRequired: true }, { |
|
|
|
|
@ -731,9 +731,9 @@ RocketChat.API.v1.addRoute('channels.setCustomFields', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setDefault', { authRequired: true }, { |
|
|
|
|
@ -753,9 +753,9 @@ RocketChat.API.v1.addRoute('channels.setDefault', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setDescription', { authRequired: true }, { |
|
|
|
|
@ -775,9 +775,9 @@ RocketChat.API.v1.addRoute('channels.setDescription', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
description: this.bodyParams.description |
|
|
|
|
description: this.bodyParams.description, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setJoinCode', { authRequired: true }, { |
|
|
|
|
@ -793,9 +793,9 @@ RocketChat.API.v1.addRoute('channels.setJoinCode', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setPurpose', { authRequired: true }, { |
|
|
|
|
@ -815,9 +815,9 @@ RocketChat.API.v1.addRoute('channels.setPurpose', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
purpose: this.bodyParams.purpose |
|
|
|
|
purpose: this.bodyParams.purpose, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setReadOnly', { authRequired: true }, { |
|
|
|
|
@ -837,9 +837,9 @@ RocketChat.API.v1.addRoute('channels.setReadOnly', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setTopic', { authRequired: true }, { |
|
|
|
|
@ -859,9 +859,9 @@ RocketChat.API.v1.addRoute('channels.setTopic', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
topic: this.bodyParams.topic |
|
|
|
|
topic: this.bodyParams.topic, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setAnnouncement', { authRequired: true }, { |
|
|
|
|
@ -877,9 +877,9 @@ RocketChat.API.v1.addRoute('channels.setAnnouncement', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
announcement: this.bodyParams.announcement |
|
|
|
|
announcement: this.bodyParams.announcement, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.setType', { authRequired: true }, { |
|
|
|
|
@ -899,9 +899,9 @@ RocketChat.API.v1.addRoute('channels.setType', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }) |
|
|
|
|
channel: RocketChat.models.Rooms.findOneById(findResult._id, { fields: RocketChat.API.v1.defaultFieldsToExclude }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.unarchive', { authRequired: true }, { |
|
|
|
|
@ -917,7 +917,7 @@ RocketChat.API.v1.addRoute('channels.unarchive', { authRequired: true }, { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.getAllUserMentionsByChannel', { authRequired: true }, { |
|
|
|
|
@ -935,22 +935,22 @@ RocketChat.API.v1.addRoute('channels.getAllUserMentionsByChannel', { authRequire |
|
|
|
|
options: { |
|
|
|
|
sort: sort ? sort : { ts: 1 }, |
|
|
|
|
skip: offset, |
|
|
|
|
limit: count |
|
|
|
|
} |
|
|
|
|
limit: count, |
|
|
|
|
}, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
const allMentions = Meteor.runAsUser(this.userId, () => Meteor.call('getUserMentionsByChannel', { |
|
|
|
|
roomId, |
|
|
|
|
options: {} |
|
|
|
|
options: {}, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
mentions, |
|
|
|
|
count: mentions.length, |
|
|
|
|
offset, |
|
|
|
|
total: allMentions.length |
|
|
|
|
total: allMentions.length, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.API.v1.addRoute('channels.roles', { authRequired: true }, { |
|
|
|
|
@ -960,7 +960,7 @@ RocketChat.API.v1.addRoute('channels.roles', { authRequired: true }, { |
|
|
|
|
const roles = Meteor.runAsUser(this.userId, () => Meteor.call('getRoomRoles', findResult._id)); |
|
|
|
|
|
|
|
|
|
return RocketChat.API.v1.success({ |
|
|
|
|
roles |
|
|
|
|
roles, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|