Add tag timelines.
This commit is contained in:
parent
b0363e8055
commit
fc85c9f086
4 changed files with 34 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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, [])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue