2014-11-26 13:56:12 -05:00
|
|
|
class AdminUserListSerializer < BasicUserSerializer
|
|
|
|
|
|
|
|
attributes :email,
|
2018-07-03 07:51:22 -04:00
|
|
|
:secondary_emails,
|
2014-11-26 13:56:12 -05:00
|
|
|
:active,
|
|
|
|
:admin,
|
|
|
|
:moderator,
|
2014-12-20 04:24:16 -05:00
|
|
|
:last_seen_at,
|
|
|
|
:last_emailed_at,
|
|
|
|
:created_at,
|
2014-11-26 13:56:12 -05:00
|
|
|
:last_seen_age,
|
|
|
|
:last_emailed_age,
|
|
|
|
:created_at_age,
|
|
|
|
:username_lower,
|
|
|
|
:trust_level,
|
2017-11-23 15:55:44 -05:00
|
|
|
:manual_locked_trust_level,
|
2014-11-26 13:56:12 -05:00
|
|
|
:flag_level,
|
|
|
|
:username,
|
|
|
|
:title,
|
|
|
|
:avatar_template,
|
|
|
|
:can_approve,
|
|
|
|
:approved,
|
|
|
|
:suspended_at,
|
|
|
|
:suspended_till,
|
|
|
|
:suspended,
|
2017-11-10 12:18:08 -05:00
|
|
|
:silenced,
|
2017-11-13 13:41:36 -05:00
|
|
|
:silenced_till,
|
2016-01-19 10:41:07 -05:00
|
|
|
:time_read,
|
2018-02-21 19:59:11 -05:00
|
|
|
:staged,
|
|
|
|
:second_factor_enabled
|
2014-11-26 13:56:12 -05:00
|
|
|
|
|
|
|
[:days_visited, :posts_read_count, :topics_entered, :post_count].each do |sym|
|
|
|
|
attributes sym
|
|
|
|
define_method sym do
|
|
|
|
object.user_stat.send(sym)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_email?
|
|
|
|
# staff members can always see their email
|
2018-12-19 04:24:57 -05:00
|
|
|
(scope.is_staff? && (object.id == scope.user.id || object.staged?)) ||
|
2019-01-18 09:26:44 -05:00
|
|
|
(@options[:emails_desired] && scope.can_check_emails?(object))
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|
|
|
|
|
2018-07-03 07:51:22 -04:00
|
|
|
alias_method :include_secondary_emails?, :include_email?
|
2014-11-26 13:56:12 -05:00
|
|
|
alias_method :include_associated_accounts?, :include_email?
|
|
|
|
|
2017-11-13 13:41:36 -05:00
|
|
|
def silenced
|
|
|
|
object.silenced?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_silenced?
|
|
|
|
object.silenced?
|
|
|
|
end
|
|
|
|
|
|
|
|
def silenced_till
|
|
|
|
object.silenced_till
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_silenced_till?
|
|
|
|
object.silenced_till?
|
|
|
|
end
|
|
|
|
|
2014-11-26 13:56:12 -05:00
|
|
|
def suspended
|
|
|
|
object.suspended?
|
|
|
|
end
|
|
|
|
|
2017-10-13 12:17:26 -04:00
|
|
|
def include_suspended_at?
|
|
|
|
object.suspended?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_suspended_till?
|
|
|
|
object.suspended?
|
|
|
|
end
|
|
|
|
|
2014-11-26 13:56:12 -05:00
|
|
|
def can_impersonate
|
|
|
|
scope.can_impersonate?(object)
|
|
|
|
end
|
2016-01-19 10:41:07 -05:00
|
|
|
|
2014-12-20 04:24:16 -05:00
|
|
|
def last_emailed_at
|
|
|
|
return nil if object.last_emailed_at.blank?
|
|
|
|
object.last_emailed_at
|
|
|
|
end
|
2014-11-26 13:56:12 -05:00
|
|
|
|
|
|
|
def last_emailed_age
|
|
|
|
return nil if object.last_emailed_at.blank?
|
2017-11-17 17:08:49 -05:00
|
|
|
Time.now - object.last_emailed_at
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|
2016-01-19 10:41:07 -05:00
|
|
|
|
2014-12-20 04:24:16 -05:00
|
|
|
def last_seen_at
|
|
|
|
return nil if object.last_seen_at.blank?
|
|
|
|
object.last_seen_at
|
|
|
|
end
|
2014-11-26 13:56:12 -05:00
|
|
|
|
|
|
|
def last_seen_age
|
|
|
|
return nil if object.last_seen_at.blank?
|
2017-11-17 17:08:49 -05:00
|
|
|
Time.now - object.last_seen_at
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def time_read
|
|
|
|
return nil if object.user_stat.time_read.blank?
|
2017-11-17 17:08:49 -05:00
|
|
|
object.user_stat.time_read
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def created_at_age
|
2017-11-17 17:08:49 -05:00
|
|
|
Time.now - object.created_at
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_approve
|
|
|
|
scope.can_approve?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_can_approve?
|
|
|
|
SiteSetting.must_approve_users
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_approved?
|
|
|
|
SiteSetting.must_approve_users
|
|
|
|
end
|
|
|
|
|
2018-02-21 19:59:11 -05:00
|
|
|
def include_second_factor_enabled?
|
|
|
|
object.totp_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def second_factor_enabled
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2014-11-26 13:56:12 -05:00
|
|
|
end
|