Formatting.

This commit is contained in:
lain 2018-04-20 13:10:57 +02:00
commit a61e8ac154
4 changed files with 48 additions and 22 deletions

View file

@ -217,8 +217,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
activities = []
else
activities =
ActivityPub.fetch_public_activities(params)
|> Enum.reverse()
ActivityPub.fetch_public_activities(params)
|> Enum.reverse()
end
conn

View file

@ -23,16 +23,34 @@ defmodule Pleroma.Web.TwitterAPI.NotificationView do
end
def render("notification.json", %{notifications: notifications, for: user}) do
render_many(notifications, Pleroma.Web.TwitterAPI.NotificationView, "notification.json", for: user)
render_many(
notifications,
Pleroma.Web.TwitterAPI.NotificationView,
"notification.json",
for: user
)
end
def render("notification.json", %{notification: %Notification{id: id, seen: seen, activity: activity, inserted_at: created_at}, for: user} = opts) do
ntype = case activity.data["type"] do
"Create" -> "mention"
"Like" -> "like"
"Announce" -> "repeat"
"Follow" -> "follow"
end
def render(
"notification.json",
%{
notification: %Notification{
id: id,
seen: seen,
activity: activity,
inserted_at: created_at
},
for: user
} = opts
) do
ntype =
case activity.data["type"] do
"Create" -> "mention"
"Like" -> "like"
"Announce" -> "repeat"
"Follow" -> "follow"
end
from = get_user(activity.data["actor"], opts)
%{
@ -40,7 +58,7 @@ defmodule Pleroma.Web.TwitterAPI.NotificationView do
"ntype" => ntype,
"notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
"from_profile" => UserView.render("show.json", %{user: from, for: user}),
"is_seen" => (if seen, do: 1, else: 0),
"is_seen" => if(seen, do: 1, else: 0),
"created_at" => created_at |> Utils.format_naive_asctime()
}
end