1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Feed.TagController do
6 use Pleroma.Web, :controller
9 alias Pleroma.Web.ActivityPub.ActivityPub
10 alias Pleroma.Web.Feed.FeedView
12 def feed(conn, %{"tag" => raw_tag} = params) do
13 {format, tag} = parse_tag(raw_tag)
16 %{type: ["Create"], tag: tag}
17 |> Pleroma.Maps.put_if_present(:max_id, params["max_id"])
18 |> ActivityPub.fetch_public_activities()
21 |> put_resp_content_type("application/#{format}+xml")
23 |> render("tag.#{format}",
24 activities: activities,
26 feed_config: Config.get([:feed])
30 @spec parse_tag(binary() | any()) :: {format :: String.t(), tag :: String.t()}
31 defp parse_tag(raw_tag) when is_binary(raw_tag) do
32 case Enum.reverse(String.split(raw_tag, ".")) do
33 [format | tag] when format in ["atom", "rss"] -> {format, Enum.join(tag, ".")}
38 defp parse_tag(raw_tag), do: {"rss", raw_tag}