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
--- /dev/null
+# 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
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# 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])
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
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])
[
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
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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<feed
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:thr="http://purl.org/syndication/thread/1.0"
+ xmlns:activity="http://activitystrea.ms/spec/1.0/"
+ xmlns:poco="http://portablecontacts.net/spec/1.0"
+ xmlns:ostatus="http://ostatus.org/schema/1.0">
+
+ <title>TAGS</title>
+</feed>
xmlns:poco="http://portablecontacts.net/spec/1.0"
xmlns:ostatus="http://ostatus.org/schema/1.0">
- <id><%= feed_url(@conn, :feed, @user.nickname) <> ".atom" %></id>
+ <id><%= user_feed_url(@conn, :feed, @user.nickname) <> ".atom" %></id>
<title><%= @user.nickname <> "'s timeline" %></title>
<updated><%= most_recent_update(@activities, @user) %></updated>
<logo><%= logo(@user) %></logo>
- <link rel="self" href="<%= '#{feed_url(@conn, :feed, @user.nickname)}.atom' %>" type="application/atom+xml"/>
+ <link rel="self" href="<%= '#{user_feed_url(@conn, :feed, @user.nickname)}.atom' %>" type="application/atom+xml"/>
<%= render @view_module, "_author.xml", assigns %>
<%= if last_activity(@activities) do %>
- <link rel="next" href="<%= '#{feed_url(@conn, :feed, @user.nickname)}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
+ <link rel="next" href="<%= '#{user_feed_url(@conn, :feed, @user.nickname)}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
<% end %>
<%= for activity <- @activities 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]}
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
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
--- /dev/null
+# 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.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
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# 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