diff --git a/lib/pleroma/emails/admin_email.ex b/lib/pleroma/emails/admin_email.ex
index b15e4041b..d7dd4b2e0 100644
--- a/lib/pleroma/emails/admin_email.ex
+++ b/lib/pleroma/emails/admin_email.ex
@@ -17,7 +17,7 @@ defp instance_notify_email do
end
defp user_url(user) do
- Helpers.feed_url(Pleroma.Web.Endpoint, :feed_redirect, user.id)
+ Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, user.id)
end
def report(to, reporter, account, statuses, comment) do
diff --git a/lib/pleroma/web/feed/tag_controller.ex b/lib/pleroma/web/feed/tag_controller.ex
new file mode 100644
index 000000000..66abc186b
--- /dev/null
+++ b/lib/pleroma/web/feed/tag_controller.ex
@@ -0,0 +1,36 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors
+# 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
diff --git a/lib/pleroma/web/feed/feed_controller.ex b/lib/pleroma/web/feed/user_controller.ex
similarity index 89%
rename from lib/pleroma/web/feed/feed_controller.ex
rename to lib/pleroma/web/feed/user_controller.ex
index d0e23007d..e5d8427ce 100644
--- a/lib/pleroma/web/feed/feed_controller.ex
+++ b/lib/pleroma/web/feed/user_controller.ex
@@ -2,13 +2,14 @@
# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Web.Feed.FeedController do
+defmodule Pleroma.Web.Feed.UserController do
use Pleroma.Web, :controller
alias Fallback.RedirectController
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.ActivityPubController
+ alias Pleroma.Web.Feed.FeedView
plug(Pleroma.Plugs.SetFormatPlug when action in [:feed_redirect])
@@ -27,7 +28,7 @@ def feed_redirect(%{assigns: %{format: format}} = conn, _params)
def feed_redirect(conn, %{"nickname" => nickname}) do
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
- redirect(conn, external: "#{feed_url(conn, :feed, user.nickname)}.atom")
+ redirect(conn, external: "#{user_feed_url(conn, :feed, user.nickname)}.atom")
end
end
@@ -44,7 +45,8 @@ def feed(conn, %{"nickname" => nickname} = params) do
conn
|> put_resp_content_type("application/atom+xml")
- |> render("feed.xml",
+ |> put_view(FeedView)
+ |> render("user.xml",
user: user,
activities: activities,
feed_config: Pleroma.Config.get([:feed])
diff --git a/lib/pleroma/web/metadata/feed.ex b/lib/pleroma/web/metadata/feed.ex
index 8043e6c54..ee48913a7 100644
--- a/lib/pleroma/web/metadata/feed.ex
+++ b/lib/pleroma/web/metadata/feed.ex
@@ -16,7 +16,7 @@ def build_tags(%{user: user}) do
[
rel: "alternate",
type: "application/atom+xml",
- href: Helpers.feed_path(Endpoint, :feed, user.nickname) <> ".atom"
+ href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom"
], []}
]
end
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index e6c4f6f14..871f3bf85 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -526,8 +526,10 @@ defmodule Pleroma.Web.Router do
get("/notice/:id", OStatus.OStatusController, :notice)
get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
- get("/users/:nickname/feed", Feed.FeedController, :feed)
- get("/users/:nickname", Feed.FeedController, :feed_redirect)
+ get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
+ get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
+
+ get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
end
diff --git a/lib/pleroma/web/templates/feed/feed/tag.xml.eex b/lib/pleroma/web/templates/feed/feed/tag.xml.eex
new file mode 100644
index 000000000..52b1d7b7d
--- /dev/null
+++ b/lib/pleroma/web/templates/feed/feed/tag.xml.eex
@@ -0,0 +1,10 @@
+
+
+
+ TAGS
+
diff --git a/lib/pleroma/web/templates/feed/feed/feed.xml.eex b/lib/pleroma/web/templates/feed/feed/user.xml.eex
similarity index 67%
rename from lib/pleroma/web/templates/feed/feed/feed.xml.eex
rename to lib/pleroma/web/templates/feed/feed/user.xml.eex
index 5ae36d345..d274c08ae 100644
--- a/lib/pleroma/web/templates/feed/feed/feed.xml.eex
+++ b/lib/pleroma/web/templates/feed/feed/user.xml.eex
@@ -6,16 +6,16 @@
xmlns:poco="http://portablecontacts.net/spec/1.0"
xmlns:ostatus="http://ostatus.org/schema/1.0">
- <%= feed_url(@conn, :feed, @user.nickname) <> ".atom" %>
+ <%= user_feed_url(@conn, :feed, @user.nickname) <> ".atom" %>
<%= @user.nickname <> "'s timeline" %>
<%= most_recent_update(@activities, @user) %>
<%= logo(@user) %>
-
+
<%= render @view_module, "_author.xml", assigns %>
<%= if last_activity(@activities) do %>
-
+
<% end %>
<%= for activity <- @activities do %>
diff --git a/test/emails/admin_email_test.exs b/test/emails/admin_email_test.exs
index ad89f9213..383cc3459 100644
--- a/test/emails/admin_email_test.exs
+++ b/test/emails/admin_email_test.exs
@@ -19,8 +19,8 @@ test "build report email" do
AdminEmail.report(to_user, reporter, account, [%{name: "Test", id: "12"}], "Test comment")
status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, "12")
- reporter_url = Helpers.feed_url(Pleroma.Web.Endpoint, :feed_redirect, reporter.id)
- account_url = Helpers.feed_url(Pleroma.Web.Endpoint, :feed_redirect, account.id)
+ reporter_url = Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, reporter.id)
+ account_url = Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, account.id)
assert res.to == [{to_user.name, to_user.email}]
assert res.from == {config[:name], config[:notify_email]}
diff --git a/test/user_test.exs b/test/user_test.exs
index bfa8faafa..7b0842e24 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -548,7 +548,7 @@ test "returns an ap_id for a user" do
user = insert(:user)
assert User.ap_id(user) ==
- Pleroma.Web.Router.Helpers.feed_url(
+ Pleroma.Web.Router.Helpers.user_feed_url(
Pleroma.Web.Endpoint,
:feed_redirect,
user.nickname
@@ -559,7 +559,7 @@ test "returns an ap_followers link for a user" do
user = insert(:user)
assert User.ap_followers(user) ==
- Pleroma.Web.Router.Helpers.feed_url(
+ Pleroma.Web.Router.Helpers.user_feed_url(
Pleroma.Web.Endpoint,
:feed_redirect,
user.nickname
diff --git a/test/web/feed/tag_controller_test.exs b/test/web/feed/tag_controller_test.exs
new file mode 100644
index 000000000..82115f811
--- /dev/null
+++ b/test/web/feed/tag_controller_test.exs
@@ -0,0 +1,31 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Feed.TagControllerTest do
+ use Pleroma.Web.ConnCase
+
+ import Pleroma.Factory
+
+ clear_config([:feed])
+
+ test "gets a feed", %{conn: conn} do
+ Pleroma.Config.put(
+ [:feed, :post_title],
+ %{max_length: 10, omission: "..."}
+ )
+
+ user = insert(:user)
+ {:ok, _activity1} = Pleroma.Web.CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
+
+ {:ok, _activity2} =
+ Pleroma.Web.CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
+
+ {:ok, _activity3} = Pleroma.Web.CommonAPI.post(user, %{"status" => "This is :moominmamma"})
+
+ assert conn
+ |> put_req_header("content-type", "application/atom+xml")
+ |> get("/tags/pleromaart.rss")
+ |> response(200)
+ end
+end
diff --git a/test/web/feed/feed_controller_test.exs b/test/web/feed/user_controller_test.exs
similarity index 99%
rename from test/web/feed/feed_controller_test.exs
rename to test/web/feed/user_controller_test.exs
index 6f61acf43..e4386ff2c 100644
--- a/test/web/feed/feed_controller_test.exs
+++ b/test/web/feed/user_controller_test.exs
@@ -2,7 +2,7 @@
# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Web.Feed.FeedControllerTest do
+defmodule Pleroma.Web.Feed.UserControllerTest do
use Pleroma.Web.ConnCase
import Pleroma.Factory