discourse/app/serializers/invited_serializer.rb
Dan Ungureanu c047640ad4
FEATURE: Various improvements to invite system (#12023)
The user interface has been reorganized to show email and link invites
in the same screen. Staff has more control over creating and updating
invites. Bulk invite has also been improved with better explanations.

On the server side, many code paths for email and link invites have
been merged to avoid duplicated logic. The API returns better responses
with more appropriate HTTP status codes.
2021-03-03 11:45:29 +02:00

24 lines
531 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: object.type == "pending" ? InviteSerializer : InvitedUserSerializer,
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