FEATURE: can invite/revoke groups on private messages

This commit is contained in:
Sam
2016-06-20 16:29:27 +10:00
parent 94df22564f
commit 8866169879
16 changed files with 210 additions and 19 deletions
+28
View File
@@ -375,6 +375,34 @@ class TopicsController < ApplicationController
end
end
def remove_allowed_group
params.require(:name)
topic = Topic.find_by(id: params[:topic_id])
guardian.ensure_can_remove_allowed_users!(topic)
if topic.remove_allowed_group(current_user, params[:name])
render json: success_json
else
render json: failed_json, status: 422
end
end
def invite_group
group = Group.find_by(name: params[:group])
raise Discourse::NotFound unless group
topic = Topic.find_by(id: params[:topic_id])
if topic.private_message?
guardian.ensure_can_send_private_message!(group)
topic.invite_group(current_user, group)
render json: success_json
else
render json: failed_json, status: 422
end
end
def invite
username_or_email = params[:user] ? fetch_username : fetch_email