projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d85d1e1
)
Add debug logs to timeline rendering to assist debugging
author
FloatingGhost
<hannah@coffee-and-dreams.uk>
Wed, 29 Mar 2023 11:01:16 +0000
(12:01 +0100)
committer
FloatingGhost
<hannah@coffee-and-dreams.uk>
Wed, 29 Mar 2023 11:01:16 +0000
(12:01 +0100)
lib/pleroma/activity.ex
patch
|
blob
|
history
lib/pleroma/user.ex
patch
|
blob
|
history
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
patch
|
blob
|
history
lib/pleroma/web/mastodon_api/views/status_view.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/activity.ex
b/lib/pleroma/activity.ex
index 925612d3ce1104c2a7884e7cf09f8639e9eb18d0..c94667fb9f177be171898c9b6b4d42766a9bb1a0 100644
(file)
--- a/
lib/pleroma/activity.ex
+++ b/
lib/pleroma/activity.ex
@@
-284,7
+284,6
@@
defmodule Pleroma.Activity do
|> Repo.one()
end
|> Repo.one()
end
-
@spec create_by_id_with_object(String.t()) :: t() | nil
def create_by_id_with_object(id) do
get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"])
@spec create_by_id_with_object(String.t()) :: t() | nil
def create_by_id_with_object(id) do
get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"])
diff --git
a/lib/pleroma/user.ex
b/lib/pleroma/user.ex
index 48052198489faeac2338782b1b4b8db76757690a..ead37ccca00a03f070f99cef5357fc186acc2362 100644
(file)
--- a/
lib/pleroma/user.ex
+++ b/
lib/pleroma/user.ex
@@
-374,7
+374,7
@@
defmodule Pleroma.User do
do_optional_url(user.banner, "#{Endpoint.url()}/images/banner.png", options)
end
do_optional_url(user.banner, "#{Endpoint.url()}/images/banner.png", options)
end
- defp do_optional_url(field, default, options
\\ []
) do
+ defp do_optional_url(field, default, options) do
case field do
%{"url" => [%{"href" => href} | _]} when is_binary(href) ->
href
case field do
%{"url" => [%{"href" => href} | _]} when is_binary(href) ->
href
diff --git
a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index c9960187d5df352b1fe006b88c9c4c9cd08ae2e0..1d4e734a40d811f18ddd52bc542835173b490773 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@
-37,10
+37,16
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
when action in [:public, :hashtag, :bubble]
)
when action in [:public, :hashtag, :bubble]
)
+ require Logger
+
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.TimelineOperation
# GET /api/v1/timelines/home
def home(%{assigns: %{user: user}} = conn, params) do
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.TimelineOperation
# GET /api/v1/timelines/home
def home(%{assigns: %{user: user}} = conn, params) do
+ %{nickname: nickname} = user
+
+ Logger.debug("TimelineController.home: #{nickname}")
+
followed_hashtags =
user
|> User.followed_hashtags()
followed_hashtags =
user
|> User.followed_hashtags()
@@
-58,11
+64,15
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put(:followed_hashtags, followed_hashtags)
|> Map.delete(:local)
|> Map.put(:followed_hashtags, followed_hashtags)
|> Map.delete(:local)
+ Logger.debug("TimelineController.home: #{nickname} - fetching activities")
+
activities =
[user.ap_id | User.following(user)]
|> ActivityPub.fetch_activities(params)
|> Enum.reverse()
activities =
[user.ap_id | User.following(user)]
|> ActivityPub.fetch_activities(params)
|> Enum.reverse()
+ Logger.debug("TimelineController.home: #{nickname} - rendering")
+
conn
|> add_link_headers(activities)
|> render("index.json",
conn
|> add_link_headers(activities)
|> render("index.json",
@@
-75,6
+85,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
# GET /api/v1/timelines/direct
def direct(%{assigns: %{user: user}} = conn, params) do
# GET /api/v1/timelines/direct
def direct(%{assigns: %{user: user}} = conn, params) do
+ Logger.debug("TimelineController.direct: #{user.nickname}")
+
params =
params
|> Map.put(:type, "Create")
params =
params
|> Map.put(:type, "Create")
@@
-82,11
+94,15
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put(:user, user)
|> Map.put(:visibility, "direct")
|> Map.put(:user, user)
|> Map.put(:visibility, "direct")
+ Logger.debug("TimelineController.direct: #{user.nickname} - fetching activities")
+
activities =
[user.ap_id]
|> ActivityPub.fetch_activities_query(params)
|> Pagination.fetch_paginated(params)
activities =
[user.ap_id]
|> ActivityPub.fetch_activities_query(params)
|> Pagination.fetch_paginated(params)
+ Logger.debug("TimelineController.direct: #{user.nickname} - rendering")
+
conn
|> add_link_headers(activities)
|> render("index.json",
conn
|> add_link_headers(activities)
|> render("index.json",
@@
-102,6
+118,7
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
# GET /api/v1/timelines/public
def public(%{assigns: %{user: user}} = conn, params) do
# GET /api/v1/timelines/public
def public(%{assigns: %{user: user}} = conn, params) do
+ Logger.debug("TimelineController.public")
local_only = params[:local]
timeline_type = if local_only, do: :local, else: :federated
local_only = params[:local]
timeline_type = if local_only, do: :local, else: :federated
@@
-109,6
+126,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
{:enabled, local_only || Config.get([:instance, :federated_timeline_available], true)},
{:authenticated, true} <-
{:authenticated, !(is_nil(user) and restrict_unauthenticated?(timeline_type))} do
{:enabled, local_only || Config.get([:instance, :federated_timeline_available], true)},
{:authenticated, true} <-
{:authenticated, !(is_nil(user) and restrict_unauthenticated?(timeline_type))} do
+ Logger.debug("TimelineController.public: fetching activities")
+
activities =
params
|> Map.put(:type, ["Create"])
activities =
params
|> Map.put(:type, ["Create"])
@@
-121,6
+140,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put(:includes_local_public, not is_nil(user))
|> ActivityPub.fetch_public_activities()
|> Map.put(:includes_local_public, not is_nil(user))
|> ActivityPub.fetch_public_activities()
+ Logger.debug("TimelineController.public: rendering")
+
conn
|> add_link_headers(activities, %{"local" => local_only})
|> render("index.json",
conn
|> add_link_headers(activities, %{"local" => local_only})
|> render("index.json",
@@
-142,6
+163,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
# GET /api/v1/timelines/bubble
def bubble(%{assigns: %{user: user}} = conn, params) do
# GET /api/v1/timelines/bubble
def bubble(%{assigns: %{user: user}} = conn, params) do
+ Logger.debug("TimelineController.bubble")
+
if is_nil(user) and restrict_unauthenticated?(:bubble) do
fail_on_bad_auth(conn)
else
if is_nil(user) and restrict_unauthenticated?(:bubble) do
fail_on_bad_auth(conn)
else
@@
-151,6
+174,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
[Pleroma.Web.Endpoint.host()]
)
[Pleroma.Web.Endpoint.host()]
)
+ Logger.debug("TimelineController.bubble: fetching activities")
+
activities =
params
|> Map.put(:type, ["Create"])
activities =
params
|> Map.put(:type, ["Create"])
@@
-160,6
+185,8
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put(:instance, bubble_instances)
|> ActivityPub.fetch_public_activities()
|> Map.put(:instance, bubble_instances)
|> ActivityPub.fetch_public_activities()
+ Logger.debug("TimelineController.bubble: rendering")
+
conn
|> add_link_headers(activities)
|> render("index.json",
conn
|> add_link_headers(activities)
|> render("index.json",
diff --git
a/lib/pleroma/web/mastodon_api/views/status_view.ex
b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 3868da8d9310c96ec33fcf65230e5eea2552e423..47d1616c47b36794be2e830f8a33e45ea3f3255b 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/
lib/pleroma/web/mastodon_api/views/status_view.ex
@@
-21,6
+21,7
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
alias Pleroma.Web.MastodonAPI.StatusView
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.PleromaAPI.EmojiReactionController
alias Pleroma.Web.MastodonAPI.StatusView
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.PleromaAPI.EmojiReactionController
+ require Logger
import Pleroma.Web.ActivityPub.Visibility, only: [get_visibility: 1, visible_for_user?: 2]
import Pleroma.Web.ActivityPub.Visibility, only: [get_visibility: 1, visible_for_user?: 2]
@@
-87,6
+88,7
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
defp reblogged?(_activity, _user), do: false
def render("index.json", opts) do
defp reblogged?(_activity, _user), do: false
def render("index.json", opts) do
+ Logger.debug("Rendering index")
reading_user = opts[:for]
# To do: check AdminAPIControllerTest on the reasons behind nil activities in the list
activities = Enum.filter(opts.activities, & &1)
reading_user = opts[:for]
# To do: check AdminAPIControllerTest on the reasons behind nil activities in the list
activities = Enum.filter(opts.activities, & &1)
@@
-136,8
+138,10
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
def render(
"show.json",
def render(
"show.json",
- %{activity: %{data: %{"type" => "Announce", "object" => _object}} = activity} = opts
+ %{activity: %{id: id, data: %{"type" => "Announce", "object" => _object}} = activity} =
+ opts
) do
) do
+ Logger.debug("Rendering reblog #{id}")
user = CommonAPI.get_user(activity.data["actor"])
created_at = Utils.to_masto_date(activity.data["published"])
object = Object.normalize(activity, fetch: false)
user = CommonAPI.get_user(activity.data["actor"])
created_at = Utils.to_masto_date(activity.data["published"])
object = Object.normalize(activity, fetch: false)
@@
-209,7
+213,9
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
}
end
}
end
- def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
+ def render("show.json", %{activity: %{id: id, data: %{"object" => _object}} = activity} = opts) do
+ Logger.debug("Rendering status #{id}")
+
with %Object{} = object <- Object.normalize(activity, fetch: false) do
user = CommonAPI.get_user(activity.data["actor"])
user_follower_address = user.follower_address
with %Object{} = object <- Object.normalize(activity, fetch: false) do
user = CommonAPI.get_user(activity.data["actor"])
user_follower_address = user.follower_address
@@
-428,6
+434,7
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
end
def render("history.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
end
def render("history.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
+ Logger.debug("Rendering history for #{activity.id}")
object = Object.normalize(activity, fetch: false)
hashtags = Object.hashtags(object)
object = Object.normalize(activity, fetch: false)
hashtags = Object.hashtags(object)
@@
-614,6
+621,8
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
def render("attachment_meta.json", _), do: nil
def render("context.json", %{activity: activity, activities: activities, user: user}) do
def render("attachment_meta.json", _), do: nil
def render("context.json", %{activity: activity, activities: activities, user: user}) do
+ Logger.debug("Rendering context for #{activity.id}")
+
%{ancestors: ancestors, descendants: descendants} =
activities
|> Enum.reverse()
%{ancestors: ancestors, descendants: descendants} =
activities
|> Enum.reverse()