-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
RocketChat API Add private channel #3866
Comments
just another dev here but yes you can use api/v1/groups.create it passes it a p flag makeing it a private channel other api methods are here (packages/rocketchat-api/server/routes.coffee. hope that helps |
I was confused about this as well. I am working on my own version of the API (more restful) for our project. Still figuring everything out. Anyway, if you want you can create a separate package for an API of your own (not ideal). So far I have gotten the code below to do what I want, but you could always modify it. room_types = {
private: 'p',
public: 'c',
direct_message: 'd'
}
RocketChat.API.v2.addRoute 'rooms', authRequired: true,
get: ->
params = {}
if RocketChat.authz.hasRole( this.userId, 'admin') is not true
return RocketChat.API.v2.unauthorized()
return { groups: RocketChat.models.Rooms.find().fetch() }
post: ->
if RocketChat.authz.hasRole( this.userId, 'admin') is not true
return RocketChat.API.v2.unauthorized()
if not @bodyParams.name?
return RocketChat.API.v2.failure 'Body param "name" is required'
if not @bodyParams.type?
return RocketChat.API.v2.failure 'Body param "type" is required'
id = undefined
try
if @bodyParams.type == 'p'
Meteor.runAsUser this.userId, =>
id = Meteor.call 'createPrivateGroup', @bodyParams.name, []
else if @bodyParams.type == 'c'
Meteor.runAsUser this.userId, =>
id = Meteor.call 'createChannel', @bodyParams.name, []
else if @bodyParams.type == 'd'
return RocketChat.API.v2.failure 'API does not allow for direct message creation'
else
return RocketChat.API.v2.failure 'Invalid room type'
catch e
return RocketChat.API.v2.failure e.name + ': ' + e.message
return RocketChat.API.v2.success
room: RocketChat.models.Rooms.findOne({_id: id.rid})
RocketChat.API.v2.addRoute 'rooms/:type', authRequired: true,
get: ->
params = {}
if RocketChat.authz.hasRole( this.userId, 'admin') is not true
return RocketChat.API.v2.unauthorized()
if not @urlParams.type?
return RocketChat.API.v2.failure 'Query param "type" is required'
return { rooms: RocketChat.models.Rooms.find({t: room_types[@urlParams.type]}).fetch() } Hoping I can make some useful contributions if I get somewhere concrete with the API. Still new to meteor. |
@ryannealmes Any new contributions please try and use es6 instead of coffescript. Also, feel free to join us in the #dev channel on the demo server so that we can chat about flushing out the v2 rest api as we would like to make it "Restful". |
As for the original message, it is possible now via the rest api to create private groups. https://rocket.chat/docs/developer-guides/rest-api/groups will have the details of it here in a day or two as I'm still working on finishing the rest api documentation. |
Your Rocket.Chat version: Most current
I am looking at using the RocketChat API as documented here: https://rocket.chat/docs/developer-guides/rest-api/
I had 2 questions:
ex: "Join a room" vs. "Create a channel"
The text was updated successfully, but these errors were encountered: