2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 08:41:47 -07:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2017-04-17 06:12:36 -06:00
|
|
|
defmodule Pleroma.Web.OStatus.UserRepresenter do
|
|
|
|
alias Pleroma.User
|
2018-03-30 07:01:53 -06:00
|
|
|
|
2017-04-18 10:41:51 -06:00
|
|
|
def to_simple_form(user) do
|
|
|
|
ap_id = to_charlist(user.ap_id)
|
|
|
|
nickname = to_charlist(user.nickname)
|
2017-04-22 07:11:13 -06:00
|
|
|
name = to_charlist(user.name)
|
|
|
|
bio = to_charlist(user.bio)
|
2017-04-18 10:41:51 -06:00
|
|
|
avatar_url = to_charlist(User.avatar_url(user))
|
2017-09-16 05:44:08 -06:00
|
|
|
|
2018-03-30 07:01:53 -06:00
|
|
|
banner =
|
|
|
|
if banner_url = User.banner_url(user) do
|
|
|
|
[{:link, [rel: 'header', href: banner_url], []}]
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
|
|
|
ap_enabled =
|
|
|
|
if user.local do
|
|
|
|
[{:ap_enabled, ['true']}]
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
2018-02-24 05:06:53 -07:00
|
|
|
|
2017-04-18 10:41:51 -06:00
|
|
|
[
|
2017-04-27 07:18:50 -06:00
|
|
|
{:id, [ap_id]},
|
|
|
|
{:"activity:object", ['http://activitystrea.ms/schema/1.0/person']},
|
|
|
|
{:uri, [ap_id]},
|
|
|
|
{:"poco:preferredUsername", [nickname]},
|
|
|
|
{:"poco:displayName", [name]},
|
|
|
|
{:"poco:note", [bio]},
|
2017-12-03 05:34:17 -07:00
|
|
|
{:summary, [bio]},
|
2017-04-27 07:18:50 -06:00
|
|
|
{:name, [nickname]},
|
|
|
|
{:link, [rel: 'avatar', href: avatar_url], []}
|
2018-02-24 05:06:53 -07:00
|
|
|
] ++ banner ++ ap_enabled
|
2017-04-17 06:12:36 -06:00
|
|
|
end
|
|
|
|
end
|