- def render("short.json", %{
- user: %User{
- nickname: nickname,
- id: id,
- ap_id: ap_id,
- name: name
- }
- }) do
- %{
- "fullname" => name,
- "id" => id,
- "ostatus_uri" => ap_id,
- "profile_url" => ap_id,
- "screen_name" => nickname
- }
+ defp maybe_with_activation_status(data, user, %User{info: %{is_admin: true}}) do
+ Map.put(data, "deactivated", user.info.deactivated)
+ end
+
+ defp maybe_with_activation_status(data, _, _), do: data
+
+ defp maybe_with_role(data, %User{id: id} = user, %User{id: id}) do
+ Map.merge(data, %{"role" => role(user), "show_role" => user.info.show_role})
+ end
+
+ defp maybe_with_role(data, %User{info: %{show_role: true}} = user, _user) do
+ Map.merge(data, %{"role" => role(user)})