pleroma/lib/pleroma/web/feed/tag_controller.ex

37 lines
1.0 KiB
Elixir
Raw Normal View History

2019-12-06 07:32:29 +01:00
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Feed.TagController do
use Pleroma.Web, :controller
alias Pleroma.Config
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.Feed.FeedView
def feed(conn, %{"tag" => tag} = params) do
activities =
%{
"type" => ["Create"],
"whole_db" => true,
"tag" => parse_tag(tag)
}
|> Map.merge(Map.take(params, ["max_id"]))
|> ActivityPub.fetch_public_activities()
conn
|> put_resp_content_type("application/atom+xml")
|> put_view(FeedView)
|> render("tag.xml", activities: activities, feed_config: Config.get([:feed]))
end
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
end
end
defp parse_tag(raw_tag), do: raw_tag
end