diaspora/app/presenters/profile_presenter.rb
Dennis Schubert e92c8000ba Do not leak private profile fields in JSON format
Signed-off-by: Dennis Schubert <mail@dennis-schubert.de>
2015-07-02 10:07:59 +02:00

30 lines
586 B
Ruby

class ProfilePresenter < BasePresenter
include PeopleHelper
def base_hash
{
id: id,
searchable: searchable
}
end
def public_hash
base_hash.merge(
avatar: AvatarPresenter.new(@presentable).base_hash,
tags: tags.pluck(:name)
)
end
def private_hash
public_hash.merge(
bio: bio_message.plain_text_for_json,
birthday: formatted_birthday,
gender: gender,
location: location_message.plain_text_for_json
)
end
def formatted_birthday
birthday_format(birthday) if birthday
end
end