1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Preload.Providers.Timelines do
6 alias Pleroma.Web.ActivityPub.ActivityPub
7 alias Pleroma.Web.MastodonAPI.StatusView
8 alias Pleroma.Web.Preload.Providers.Provider
11 @public_url "/api/v1/timelines/public"
14 def generate_terms(params) do
15 build_public_tag(%{}, params)
18 def build_public_tag(acc, params) do
19 if Pleroma.Config.restrict_unauthenticated_access?(:timelines, :federated) do
22 Map.put(acc, @public_url, public_timeline(params))
26 defp public_timeline(%{"path" => ["main", "all"]}), do: get_public_timeline(false)
28 defp public_timeline(_params), do: get_public_timeline(true)
30 defp get_public_timeline(local_only) do
32 ActivityPub.fetch_public_activities(%{
34 local_only: local_only
37 StatusView.render("index.json", activities: activities, for: nil, as: :activity)