2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
class TopicPoster < OpenStruct
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
2017-02-17 17:54:43 -05:00
|
|
|
attr_accessor :user, :description, :extras, :id, :primary_group
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
def attributes
|
2013-03-23 09:39:01 -04:00
|
|
|
{
|
|
|
|
'user' => user,
|
|
|
|
'description' => description,
|
|
|
|
'extras' => extras,
|
2017-02-17 17:54:43 -05:00
|
|
|
'id' => id,
|
|
|
|
'primary_group' => primary_group
|
2013-03-23 09:39:01 -04:00
|
|
|
}
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2021-02-02 04:50:04 -05:00
|
|
|
def name_and_description
|
|
|
|
if SiteSetting.prioritize_username_in_ux? || user.name.blank?
|
|
|
|
name = user.username
|
|
|
|
else
|
|
|
|
name = user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
I18n.t("js.user.avatar.name_and_description", name: name, description: description)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
end
|