aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <rbraun@Bobble.local>2017-09-14 13:22:09 +0200
committerRoger Braun <rbraun@Bobble.local>2017-09-14 13:22:09 +0200
commitfc85c9f086cd5dd73effa28cb68fb245a554fa98 (patch)
tree070041e5c5a1b9be254448f6aff732867b8828bb /lib
parentb0363e80556b4c8271ab69d2680166ca844f660c (diff)
downloadpleroma-fc85c9f086cd5dd73effa28cb68fb245a554fa98.tar.gz
Add tag timelines.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex7
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex12
-rw-r--r--lib/pleroma/web/router.ex1
3 files changed, 20 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 5acbb859e..2a8034457 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -111,6 +111,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
defp restrict_since(query, _), do: query
+ defp restrict_tag(query, %{"tag" => tag}) do
+ from activity in query,
+ where: fragment("? <@ (? #> '{\"object\",\"tag\"}')", ^tag, activity.data)
+ end
+ defp restrict_tag(query, _), do: query
+
defp restrict_recipients(query, recipients) do
Enum.reduce(recipients, query, fn (recipient, q) ->
map = %{ to: [recipient] }
@@ -148,6 +154,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
base_query
|> restrict_recipients(recipients)
+ |> restrict_tag(opts)
|> restrict_since(opts)
|> restrict_local(opts)
|> restrict_max(opts)
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 0f7674f5d..4a5bbb7b6 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -230,6 +230,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
+ def hashtag_timeline(%{assigns: %{user: user}} = conn, params) do
+ params = params
+ |> Map.put("type", "Create")
+ |> Map.put("local_only", !!params["local"])
+
+ activities = ActivityPub.fetch_public_activities(params)
+ |> Enum.reverse
+
+ conn
+ |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
+ end
+
def empty_array(conn, _) do
Logger.debug("Unimplemented, returning an empty array")
json(conn, [])
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 05d1e54b5..5c46d3ca2 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -65,6 +65,7 @@ defmodule Pleroma.Web.Router do
post "/apps", MastodonAPIController, :create_app
get "/timelines/public", MastodonAPIController, :public_timeline
+ get "/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline
get "/statuses/:id", MastodonAPIController, :get_status
get "/statuses/:id/context", MastodonAPIController, :get_context