mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 07:56:08 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
50 lines
950 B
Ruby
50 lines
950 B
Ruby
# frozen_string_literal: true
|
|
|
|
class FlaggedUserSerializer < BasicUserSerializer
|
|
attributes :can_delete_all_posts,
|
|
:can_be_deleted,
|
|
:post_count,
|
|
:topic_count,
|
|
:ip_address,
|
|
:custom_fields,
|
|
:flags_agreed,
|
|
:flags_disagreed,
|
|
:flags_ignored
|
|
|
|
def can_delete_all_posts
|
|
scope.can_delete_all_posts?(object)
|
|
end
|
|
|
|
def can_be_deleted
|
|
scope.can_delete_user?(object)
|
|
end
|
|
|
|
def ip_address
|
|
object.ip_address.try(:to_s)
|
|
end
|
|
|
|
def flags_agreed
|
|
object.user_stat.flags_agreed
|
|
end
|
|
|
|
def flags_disagreed
|
|
object.user_stat.flags_disagreed
|
|
end
|
|
|
|
def flags_ignored
|
|
object.user_stat.flags_ignored
|
|
end
|
|
|
|
def custom_fields
|
|
fields = User.whitelisted_user_custom_fields(scope)
|
|
|
|
result = {}
|
|
fields.each do |k|
|
|
result[k] = object.custom_fields[k] if object.custom_fields[k].present?
|
|
end
|
|
|
|
result
|
|
end
|
|
|
|
end
|