mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 06:55:03 -05:00
FEATURE: can invite/revoke groups on private messages
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user