mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:37:55 +08:00
31 lines
642 B
Ruby
31 lines
642 B
Ruby
# frozen_string_literal: true
|
|
|
|
class InvitedSerializer < ApplicationSerializer
|
|
attributes :invites, :can_see_invite_details, :counts
|
|
|
|
def invites
|
|
ActiveModel::ArraySerializer.new(
|
|
object.invite_list,
|
|
each_serializer:
|
|
(
|
|
if object.type == "pending" || object.type == "expired"
|
|
InviteSerializer
|
|
else
|
|
InvitedUserSerializer
|
|
end
|
|
),
|
|
scope: scope,
|
|
root: false,
|
|
show_emails: object.show_emails,
|
|
).as_json
|
|
end
|
|
|
|
def can_see_invite_details
|
|
scope.can_see_invite_details?(object.inviter)
|
|
end
|
|
|
|
def counts
|
|
object.counts
|
|
end
|
|
end
|