{String.trim(name, ":"), url}
end)
+ # ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
+ # For example: [{"name": "Pronoun", "value": "she/her"}, …]
+ fields =
+ (user.info["source_data"]["attachment"] || [])
+ |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
+ |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end)
+
data = %{
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
"description" => HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
"is_local" => user.local,
"locked" => !!user.info["locked"],
"default_scope" => user.info["default_scope"] || "public",
- "no_rich_text" => user.info["no_rich_text"] || false
+ "no_rich_text" => user.info["no_rich_text"] || false,
+ "fields" => fields
}
if assigns[:token] do
"is_local" => true,
"locked" => false,
"default_scope" => "public",
- "no_rich_text" => false
+ "no_rich_text" => false,
+ "fields" => []
}
assert represented == UserView.render("show.json", %{user: user})
"is_local" => true,
"locked" => false,
"default_scope" => "public",
- "no_rich_text" => false
+ "no_rich_text" => false,
+ "fields" => []
}
assert represented == UserView.render("show.json", %{user: user, for: follower})
"is_local" => true,
"locked" => false,
"default_scope" => "public",
- "no_rich_text" => false
+ "no_rich_text" => false,
+ "fields" => []
}
assert represented == UserView.render("show.json", %{user: follower, for: user})
"is_local" => true,
"locked" => false,
"default_scope" => "public",
- "no_rich_text" => false
+ "no_rich_text" => false,
+ "fields" => []
}
blocker = Repo.get(User, blocker.id)