PERF: Add endpoint to check if a group can be mentioned by user.

This commit is contained in:
Guo Xiang Tan
2016-11-25 16:45:15 +08:00
parent 5794f1619d
commit 559918c6c6
9 changed files with 61 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
class GroupsController < ApplicationController
before_filter :ensure_logged_in, only: [:set_notifications]
before_filter :ensure_logged_in, only: [:set_notifications, :mentionable]
skip_before_filter :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
def show
@@ -120,6 +120,16 @@ class GroupsController < ApplicationController
end
end
def mentionable
group = find_group(:name)
if group
render json: { mentionable: Group.mentionable(current_user).where(id: group.id).present? }
else
raise Discourse::InvalidAccess.new
end
end
def remove_member
group = Group.find(params[:id])
guardian.ensure_can_edit!(group)