mtwomey
(Matthew Twomey)
Agosto 3, 2017, 2:48am
1
I’d like to be able to add users to “allowed_users” of a topic. When I retrieve a topic, one section is details.allowed_users. Is there a way to add additional users here with a PUT?
Yes you can.
As per above code I am sure by inviting you can add any user to allowed_users list.
mtwomey
(Matthew Twomey)
Agosto 3, 2017, 5:38pm
3
I apologize, my ruby experience is fairly limited - can you give me a pointer on how to infer the needed API call to do that? Not asking anyone to do it for me, but maybe a pointer?
mtwomey
(Matthew Twomey)
Agosto 7, 2017, 10:04pm
4
bump Anyone know if this is possible via the existing API?
blake
(Blake Erickson)
Agosto 7, 2017, 11:58pm
5
You can use this endpoint to invite a user to a topic .
POST https://discourse.example.com/t/{id}/invite
BODY "username": "string"
If you are using the ruby discourse_api gem you can use this method: invite_user_to_topic
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require File.expand_path("../../lib/discourse_api", __FILE__)
config = DiscourseApi::ExampleHelper.load_yml
client = DiscourseApi::Client.new(config["host"] || "http://localhost:3000")
client.api_key = config["api_key"] || "YOUR_API_KEY"
client.api_username = config["api_username"] || "YOUR_USERNAME"
# invite user
invite = client.invite_user(email: "name@example.com", group_ids: "41,42")
#update invite
client.update_invite(invite["id"], email: "namee@example.com")
# resend invite
client.resend_invite("namee@example.com")
# invite to a topic
client.invite_to_topic(1, email: "foo@bar.com")