X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ffeed%2Ftag_controller.ex;h=8133f8480366bc2c14c6fa36538b0435e3d928d4;hb=e18958a5d7ed2d31026ee921dfcc0501b5d2881b;hp=66abc186b82a3a26922fe8e56ab46e9e31822077;hpb=22fc271e23a5dd1570ea7429b563f6edc42613c4;p=akkoma
diff --git a/lib/pleroma/web/feed/tag_controller.ex b/lib/pleroma/web/feed/tag_controller.ex
index 66abc186b..8133f8480 100644
--- a/lib/pleroma/web/feed/tag_controller.ex
+++ b/lib/pleroma/web/feed/tag_controller.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Feed.TagController do
@@ -9,28 +9,33 @@ defmodule Pleroma.Web.Feed.TagController do
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.Feed.FeedView
- def feed(conn, %{"tag" => tag} = params) do
+ import Pleroma.Web.ControllerHelper, only: [put_if_exist: 3]
+
+ def feed(conn, %{"tag" => raw_tag} = params) do
+ {format, tag} = parse_tag(raw_tag)
+
activities =
- %{
- "type" => ["Create"],
- "whole_db" => true,
- "tag" => parse_tag(tag)
- }
- |> Map.merge(Map.take(params, ["max_id"]))
+ %{"type" => ["Create"], "tag" => tag}
+ |> put_if_exist("max_id", params["max_id"])
|> ActivityPub.fetch_public_activities()
conn
- |> put_resp_content_type("application/atom+xml")
+ |> put_resp_content_type("application/#{format}+xml")
|> put_view(FeedView)
- |> render("tag.xml", activities: activities, feed_config: Config.get([:feed]))
+ |> render("tag.#{format}",
+ activities: activities,
+ tag: tag,
+ feed_config: Config.get([:feed])
+ )
end
+ @spec parse_tag(binary() | any()) :: {format :: String.t(), tag :: String.t()}
defp parse_tag(raw_tag) when is_binary(raw_tag) do
case Enum.reverse(String.split(raw_tag, ".")) do
- [format | tag] when format in ["atom", "rss"] -> Enum.join(tag, ".")
- _ -> raw_tag
+ [format | tag] when format in ["atom", "rss"] -> {format, Enum.join(tag, ".")}
+ _ -> {"rss", raw_tag}
end
end
- defp parse_tag(raw_tag), do: raw_tag
+ defp parse_tag(raw_tag), do: {"rss", raw_tag}
end