X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Ftimeline_controller.ex;h=1d4e734a40d811f18ddd52bc542835173b490773;hb=f12d3cce39e6bdfbe4aa8364ba1051a6b72155fc;hp=c9960187d5df352b1fe006b88c9c4c9cd08ae2e0;hpb=dd44387f1addcad910dae3a148b55e53157004c0;p=akkoma diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index c9960187d..1d4e734a4 100644 --- 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] ) + 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 + %{nickname: nickname} = user + + Logger.debug("TimelineController.home: #{nickname}") + 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) + Logger.debug("TimelineController.home: #{nickname} - fetching activities") + 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", @@ -75,6 +85,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController 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") @@ -82,11 +94,15 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do |> 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) + Logger.debug("TimelineController.direct: #{user.nickname} - rendering") + 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 + Logger.debug("TimelineController.public") 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 + Logger.debug("TimelineController.public: fetching activities") + 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() + Logger.debug("TimelineController.public: rendering") + 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 + Logger.debug("TimelineController.bubble") + 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()] ) + Logger.debug("TimelineController.bubble: fetching activities") + 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() + Logger.debug("TimelineController.bubble: rendering") + conn |> add_link_headers(activities) |> render("index.json",