mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 11:33:44 +08:00
6bc74ceb50
* Split alias levels in mentionable and messageable levels. * Fixed some tests. * Set messageable level to everyone by default. * By defaults, groups are not mentionable or messageable. * Made staff groups messageable by the system.
42 lines
724 B
Ruby
42 lines
724 B
Ruby
class GroupShowSerializer < BasicGroupSerializer
|
|
attributes :is_group_user, :is_group_owner, :mentionable
|
|
|
|
def include_is_group_user?
|
|
authenticated?
|
|
end
|
|
|
|
def is_group_user
|
|
!!fetch_group_user
|
|
end
|
|
|
|
def include_is_group_owner?
|
|
authenticated?
|
|
end
|
|
|
|
def is_group_owner
|
|
scope.is_admin? || fetch_group_user&.owner
|
|
end
|
|
|
|
def include_mentionable?
|
|
authenticated?
|
|
end
|
|
|
|
def mentionable
|
|
Group.mentionable(scope.user).exists?(id: object.id)
|
|
end
|
|
|
|
def messageable
|
|
Group.messageable(scope.user).exists?(id: object.id)
|
|
end
|
|
|
|
private
|
|
|
|
def authenticated?
|
|
scope.authenticated?
|
|
end
|
|
|
|
def fetch_group_user
|
|
@group_user ||= object.group_users.find_by(user: scope.user)
|
|
end
|
|
end
|