mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 22:23:44 +08:00
34387c5a38
Users can invite people to topics from secured category, but they will not be redirected to the topic after signing up unless they have the permissions to view the topic. This commit shows a warning when invite is saved if the topic is in a secured category and none of the invite groups are allowed to see it.
57 lines
1.1 KiB
Ruby
57 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class InviteSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:invite_key,
|
|
:link,
|
|
:email,
|
|
:emailed,
|
|
:max_redemptions_allowed,
|
|
:redemption_count,
|
|
:custom_message,
|
|
:created_at,
|
|
:updated_at,
|
|
:expires_at,
|
|
:expired,
|
|
:warnings
|
|
|
|
has_many :topics, embed: :object, serializer: BasicTopicSerializer
|
|
has_many :groups, embed: :object, serializer: BasicGroupSerializer
|
|
|
|
def include_email?
|
|
options[:show_emails] && !object.redeemed?
|
|
end
|
|
|
|
def include_emailed?
|
|
email.present?
|
|
end
|
|
|
|
def emailed
|
|
object.emailed_status != Invite.emailed_status_types[:not_required]
|
|
end
|
|
|
|
def include_custom_message?
|
|
email.present?
|
|
end
|
|
|
|
def include_max_redemptions_allowed?
|
|
email.blank?
|
|
end
|
|
|
|
def include_redemption_count?
|
|
email.blank?
|
|
end
|
|
|
|
def expired
|
|
object.expired?
|
|
end
|
|
|
|
def warnings
|
|
object.warnings(scope)
|
|
end
|
|
|
|
def include_warnings?
|
|
object.warnings(scope).present?
|
|
end
|
|
end
|