diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e6b1609e..09f31d5a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Captcha: Support native provider
- Captcha: Enable by default
- Mastodon API: Add support for `account_id` param to filter notifications by the account
+- Mastodon API: Add `emoji_reactions` property to Statuses
### Fixed
diff --git a/config/config.exs b/config/config.exs
index a0d7a10fa..2c154eb45 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -500,7 +500,8 @@
mailer: 10,
transmogrifier: 20,
scheduled_activities: 10,
- background: 5
+ background: 5,
+ attachments_cleanup: 5
]
config :pleroma, :workers,
diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md
index bb62ed5f2..50076cf98 100644
--- a/docs/API/differences_in_mastoapi_responses.md
+++ b/docs/API/differences_in_mastoapi_responses.md
@@ -29,6 +29,7 @@ Has these additional fields under the `pleroma` object:
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
- `thread_muted`: true if the thread the post belongs to is muted
+- `emoji_reactions`: An object with all the emoji reactions with count. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint.
## Attachments
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 510d3273c..896cbb3c5 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -312,9 +312,7 @@ def restrict_deactivated_users(query) do
from(u in User.Query.build(deactivated: true), select: u.ap_id)
|> Repo.all()
- from(activity in query,
- where: activity.actor not in ^deactivated_users
- )
+ Activity.Queries.exclude_authors(query, deactivated_users)
end
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
diff --git a/lib/pleroma/activity/queries.ex b/lib/pleroma/activity/queries.ex
index 26bc1099d..79f305201 100644
--- a/lib/pleroma/activity/queries.ex
+++ b/lib/pleroma/activity/queries.ex
@@ -12,6 +12,7 @@ defmodule Pleroma.Activity.Queries do
@type query :: Ecto.Queryable.t() | Activity.t()
alias Pleroma.Activity
+ alias Pleroma.User
@spec by_ap_id(query, String.t()) :: query
def by_ap_id(query \\ Activity, ap_id) do
@@ -29,6 +30,11 @@ def by_actor(query \\ Activity, actor) do
)
end
+ @spec by_author(query, String.t()) :: query
+ def by_author(query \\ Activity, %User{ap_id: ap_id}) do
+ from(a in query, where: a.actor == ^ap_id)
+ end
+
@spec by_object_id(query, String.t() | [String.t()]) :: query
def by_object_id(query \\ Activity, object_id)
@@ -72,4 +78,8 @@ def exclude_type(query \\ Activity, activity_type) do
where: fragment("(?)->>'type' != ?", activity.data, ^activity_type)
)
end
+
+ def exclude_authors(query \\ Activity, actors) do
+ from(activity in query, where: activity.actor not in ^actors)
+ end
end
diff --git a/lib/pleroma/activity/search.ex b/lib/pleroma/activity/search.ex
index d30a5a6a5..f96e208da 100644
--- a/lib/pleroma/activity/search.ex
+++ b/lib/pleroma/activity/search.ex
@@ -26,18 +26,23 @@ def search(user, search_query, options \\ []) do
|> query_with(index_type, search_query)
|> maybe_restrict_local(user)
|> maybe_restrict_author(author)
+ |> maybe_restrict_blocked(user)
|> Pagination.fetch_paginated(%{"offset" => offset, "limit" => limit}, :offset)
|> maybe_fetch(user, search_query)
end
def maybe_restrict_author(query, %User{} = author) do
- from([a, o] in query,
- where: a.actor == ^author.ap_id
- )
+ Activity.Queries.by_author(query, author)
end
def maybe_restrict_author(query, _), do: query
+ def maybe_restrict_blocked(query, %User{} = user) do
+ Activity.Queries.exclude_authors(query, User.blocked_users_ap_ids(user))
+ end
+
+ def maybe_restrict_blocked(query, _), do: query
+
defp restrict_public(q) do
from([a, o] in q,
where: fragment("?->>'type' = 'Create'", a.data),
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 2452a7389..38e372f6d 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -19,6 +19,8 @@ defmodule Pleroma.Object do
@type t() :: %__MODULE__{}
+ @derive {Jason.Encoder, only: [:data]}
+
schema "objects" do
field(:data, :map)
@@ -180,85 +182,17 @@ def swap_object_with_tombstone(object) do
def delete(%Object{data: %{"id" => id}} = object) do
with {:ok, _obj} = swap_object_with_tombstone(object),
- :ok <- delete_attachments(object),
deleted_activity = Activity.delete_all_by_object_ap_id(id),
{:ok, true} <- Cachex.del(:object_cache, "object:#{id}"),
- {:ok, _} <- Cachex.del(:web_resp_cache, URI.parse(id).path) do
+ {:ok, _} <- Cachex.del(:web_resp_cache, URI.parse(id).path),
+ {:ok, _} <-
+ Pleroma.Workers.AttachmentsCleanupWorker.enqueue("cleanup_attachments", %{
+ "object" => object
+ }) do
{:ok, object, deleted_activity}
end
end
- defp delete_attachments(%{data: %{"attachment" => [_ | _] = attachments, "actor" => actor}}) do
- hrefs =
- Enum.flat_map(attachments, fn attachment ->
- Enum.map(attachment["url"], & &1["href"])
- end)
-
- names = Enum.map(attachments, & &1["name"])
-
- uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
-
- # find all objects for copies of the attachments, name and actor doesn't matter here
- delete_ids =
- from(o in Object,
- where:
- fragment(
- "to_jsonb(array(select jsonb_array_elements((?)#>'{url}') ->> 'href'))::jsonb \\?| (?)",
- o.data,
- ^hrefs
- )
- )
- |> Repo.all()
- # we should delete 1 object for any given attachment, but don't delete files if
- # there are more than 1 object for it
- |> Enum.reduce(%{}, fn %{
- id: id,
- data: %{
- "url" => [%{"href" => href}],
- "actor" => obj_actor,
- "name" => name
- }
- },
- acc ->
- Map.update(acc, href, %{id: id, count: 1}, fn val ->
- case obj_actor == actor and name in names do
- true ->
- # set id of the actor's object that will be deleted
- %{val | id: id, count: val.count + 1}
-
- false ->
- # another actor's object, just increase count to not delete file
- %{val | count: val.count + 1}
- end
- end)
- end)
- |> Enum.map(fn {href, %{id: id, count: count}} ->
- # only delete files that have single instance
- with 1 <- count do
- prefix =
- case Pleroma.Config.get([Pleroma.Upload, :base_url]) do
- nil -> "media"
- _ -> ""
- end
-
- base_url = Pleroma.Config.get([__MODULE__, :base_url], Pleroma.Web.base_url())
-
- file_path = String.trim_leading(href, "#{base_url}/#{prefix}")
-
- uploader.delete_file(file_path)
- end
-
- id
- end)
-
- from(o in Object, where: o.id in ^delete_ids)
- |> Repo.delete_all()
-
- :ok
- end
-
- defp delete_attachments(%{data: _data}), do: :ok
-
def prune(%Object{data: %{"id" => id}} = object) do
with {:ok, object} <- Repo.delete(object),
{:ok, true} <- Cachex.del(:object_cache, "object:#{id}"),
diff --git a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
index 0a929f55b..5a5db8e00 100644
--- a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
@@ -43,7 +43,7 @@ defp do_search(version, %{assigns: %{user: user}} = conn, %{"q" => query} = para
result =
default_values
|> Enum.map(fn {resource, default_value} ->
- if params["type"] == nil or params["type"] == resource do
+ if params["type"] in [nil, resource] do
{resource, fn -> resource_search(version, resource, query, options) end}
else
{resource, fn -> default_value end}
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index e9590224b..b59ac39bc 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -253,6 +253,16 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
nil
end
+ emoji_reactions =
+ with %{data: %{"reactions" => emoji_reactions}} <- object do
+ Enum.map(emoji_reactions, fn {emoji, users} ->
+ {emoji, length(users)}
+ end)
+ |> Enum.into(%{})
+ else
+ _ -> %{}
+ end
+
%{
id: to_string(activity.id),
uri: object.data["id"],
@@ -293,7 +303,8 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
spoiler_text: %{"text/plain" => summary_plaintext},
expires_at: expires_at,
direct_conversation_id: direct_conversation_id,
- thread_muted: thread_muted?
+ thread_muted: thread_muted?,
+ emoji_reactions: emoji_reactions
}
}
end
diff --git a/lib/pleroma/workers/attachments_cleanup_worker.ex b/lib/pleroma/workers/attachments_cleanup_worker.ex
new file mode 100644
index 000000000..3f421db40
--- /dev/null
+++ b/lib/pleroma/workers/attachments_cleanup_worker.ex
@@ -0,0 +1,88 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Workers.AttachmentsCleanupWorker do
+ import Ecto.Query
+
+ alias Pleroma.Object
+ alias Pleroma.Repo
+
+ use Pleroma.Workers.WorkerHelper, queue: "attachments_cleanup"
+
+ @impl Oban.Worker
+ def perform(
+ %{"object" => %{"data" => %{"attachment" => [_ | _] = attachments, "actor" => actor}}},
+ _job
+ ) do
+ hrefs =
+ Enum.flat_map(attachments, fn attachment ->
+ Enum.map(attachment["url"], & &1["href"])
+ end)
+
+ names = Enum.map(attachments, & &1["name"])
+
+ uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
+
+ # find all objects for copies of the attachments, name and actor doesn't matter here
+ delete_ids =
+ from(o in Object,
+ where:
+ fragment(
+ "to_jsonb(array(select jsonb_array_elements((?)#>'{url}') ->> 'href' where jsonb_typeof((?)#>'{url}') = 'array'))::jsonb \\?| (?)",
+ o.data,
+ o.data,
+ ^hrefs
+ )
+ )
+ # The query above can be time consumptive on large instances until we
+ # refactor how uploads are stored
+ |> Repo.all(timout: :infinity)
+ # we should delete 1 object for any given attachment, but don't delete
+ # files if there are more than 1 object for it
+ |> Enum.reduce(%{}, fn %{
+ id: id,
+ data: %{
+ "url" => [%{"href" => href}],
+ "actor" => obj_actor,
+ "name" => name
+ }
+ },
+ acc ->
+ Map.update(acc, href, %{id: id, count: 1}, fn val ->
+ case obj_actor == actor and name in names do
+ true ->
+ # set id of the actor's object that will be deleted
+ %{val | id: id, count: val.count + 1}
+
+ false ->
+ # another actor's object, just increase count to not delete file
+ %{val | count: val.count + 1}
+ end
+ end)
+ end)
+ |> Enum.map(fn {href, %{id: id, count: count}} ->
+ # only delete files that have single instance
+ with 1 <- count do
+ prefix =
+ case Pleroma.Config.get([Pleroma.Upload, :base_url]) do
+ nil -> "media"
+ _ -> ""
+ end
+
+ base_url = Pleroma.Config.get([__MODULE__, :base_url], Pleroma.Web.base_url())
+
+ file_path = String.trim_leading(href, "#{base_url}/#{prefix}")
+
+ uploader.delete_file(file_path)
+ end
+
+ id
+ end)
+
+ from(o in Object, where: o.id in ^delete_ids)
+ |> Repo.delete_all()
+ end
+
+ def perform(%{"object" => _object}, _job), do: :ok
+end
diff --git a/priv/static/adminfe/chunk-15fa.5a5f973d.css b/priv/static/adminfe/chunk-15fa.5a5f973d.css
new file mode 100644
index 000000000..30bf7de23
Binary files /dev/null and b/priv/static/adminfe/chunk-15fa.5a5f973d.css differ
diff --git a/priv/static/adminfe/chunk-18e1.dd09fe2e.css b/priv/static/adminfe/chunk-18e1.dd09fe2e.css
new file mode 100644
index 000000000..da819ca09
Binary files /dev/null and b/priv/static/adminfe/chunk-18e1.dd09fe2e.css differ
diff --git a/priv/static/adminfe/chunk-1ada.90dffac4.css b/priv/static/adminfe/chunk-1ada.90dffac4.css
new file mode 100644
index 000000000..c0074e6f7
Binary files /dev/null and b/priv/static/adminfe/chunk-1ada.90dffac4.css differ
diff --git a/priv/static/adminfe/chunk-2aa6.8ce63ac0.css b/priv/static/adminfe/chunk-2aa6.8ce63ac0.css
new file mode 100644
index 000000000..8bd6a2e50
Binary files /dev/null and b/priv/static/adminfe/chunk-2aa6.8ce63ac0.css differ
diff --git a/priv/static/adminfe/chunk-3d8e.48523459.css b/priv/static/adminfe/chunk-3d8e.48523459.css
new file mode 100644
index 000000000..8eefd9493
Binary files /dev/null and b/priv/static/adminfe/chunk-3d8e.48523459.css differ
diff --git a/priv/static/adminfe/chunk-4dc2.25d3bcab.css b/priv/static/adminfe/chunk-4dc2.25d3bcab.css
new file mode 100644
index 000000000..48784b9d2
Binary files /dev/null and b/priv/static/adminfe/chunk-4dc2.25d3bcab.css differ
diff --git a/priv/static/adminfe/chunk-6b7b.1ab4da3b.css b/priv/static/adminfe/chunk-6b7b.1ab4da3b.css
new file mode 100644
index 000000000..7124c9690
Binary files /dev/null and b/priv/static/adminfe/chunk-6b7b.1ab4da3b.css differ
diff --git a/priv/static/adminfe/chunk-6e77.57276c93.css b/priv/static/adminfe/chunk-6e77.57276c93.css
new file mode 100644
index 000000000..f0b3bf144
Binary files /dev/null and b/priv/static/adminfe/chunk-6e77.57276c93.css differ
diff --git a/priv/static/adminfe/chunk-7f83.f9f73c8e.css b/priv/static/adminfe/chunk-7f83.f9f73c8e.css
new file mode 100644
index 000000000..29f7b475d
Binary files /dev/null and b/priv/static/adminfe/chunk-7f83.f9f73c8e.css differ
diff --git a/priv/static/adminfe/chunk-7f8e.1d10e1c7.css b/priv/static/adminfe/chunk-7f8e.1d10e1c7.css
new file mode 100644
index 000000000..6cd674a28
Binary files /dev/null and b/priv/static/adminfe/chunk-7f8e.1d10e1c7.css differ
diff --git a/priv/static/adminfe/chunk-elementUI.1abbc9b8.css b/priv/static/adminfe/chunk-elementUI.1abbc9b8.css
new file mode 100644
index 000000000..c802d3a40
Binary files /dev/null and b/priv/static/adminfe/chunk-elementUI.1abbc9b8.css differ
diff --git a/priv/static/adminfe/chunk-elementUI.a842fb0a.css b/priv/static/adminfe/chunk-elementUI.a842fb0a.css
deleted file mode 100644
index 3fef5e5fd..000000000
Binary files a/priv/static/adminfe/chunk-elementUI.a842fb0a.css and /dev/null differ
diff --git a/priv/static/adminfe/index.html b/priv/static/adminfe/index.html
index d238accb5..e28125b5e 100644
--- a/priv/static/adminfe/index.html
+++ b/priv/static/adminfe/index.html
@@ -1 +1 @@
-
Admin FE
\ No newline at end of file
+Admin FE
\ No newline at end of file
diff --git a/priv/static/adminfe/static/js/app.19b7049e.js b/priv/static/adminfe/static/js/app.19b7049e.js
deleted file mode 100644
index d33589df4..000000000
Binary files a/priv/static/adminfe/static/js/app.19b7049e.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/app.19b7049e.js.map b/priv/static/adminfe/static/js/app.19b7049e.js.map
deleted file mode 100644
index 90c7816c0..000000000
Binary files a/priv/static/adminfe/static/js/app.19b7049e.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/app.3da0f475.js b/priv/static/adminfe/static/js/app.3da0f475.js
new file mode 100644
index 000000000..c6bd005d2
Binary files /dev/null and b/priv/static/adminfe/static/js/app.3da0f475.js differ
diff --git a/priv/static/adminfe/static/js/app.3da0f475.js.map b/priv/static/adminfe/static/js/app.3da0f475.js.map
new file mode 100644
index 000000000..999df6709
Binary files /dev/null and b/priv/static/adminfe/static/js/app.3da0f475.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js b/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js
deleted file mode 100644
index 71b39bb28..000000000
Binary files a/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js.map b/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js.map
deleted file mode 100644
index 4935ac41f..000000000
Binary files a/priv/static/adminfe/static/js/chunk-0cc4.35b47d0a.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-15fa.10871dbf.js b/priv/static/adminfe/static/js/chunk-15fa.34070731.js
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-15fa.10871dbf.js
rename to priv/static/adminfe/static/js/chunk-15fa.34070731.js
index 8c7b033cf..937908d00 100644
Binary files a/priv/static/adminfe/static/js/chunk-15fa.10871dbf.js and b/priv/static/adminfe/static/js/chunk-15fa.34070731.js differ
diff --git a/priv/static/adminfe/static/js/chunk-15fa.10871dbf.js.map b/priv/static/adminfe/static/js/chunk-15fa.34070731.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-15fa.10871dbf.js.map
rename to priv/static/adminfe/static/js/chunk-15fa.34070731.js.map
index a4b89ba68..d3830be7c 100644
Binary files a/priv/static/adminfe/static/js/chunk-15fa.10871dbf.js.map and b/priv/static/adminfe/static/js/chunk-15fa.34070731.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js b/priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js
similarity index 97%
rename from priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js
rename to priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js
index 237c35b90..e0561aa1a 100644
Binary files a/priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js and b/priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js differ
diff --git a/priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js.map b/priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js.map
similarity index 98%
rename from priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js.map
rename to priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js.map
index 2cfd1cfcc..27f79dceb 100644
Binary files a/priv/static/adminfe/static/js/chunk-18e1.9f7c9b0f.js.map and b/priv/static/adminfe/static/js/chunk-18e1.c5abe3f2.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js b/priv/static/adminfe/static/js/chunk-1ada.b41cb585.js
similarity index 97%
rename from priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js
rename to priv/static/adminfe/static/js/chunk-1ada.b41cb585.js
index 3e9a3e795..b7bc3b278 100644
Binary files a/priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js and b/priv/static/adminfe/static/js/chunk-1ada.b41cb585.js differ
diff --git a/priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js.map b/priv/static/adminfe/static/js/chunk-1ada.b41cb585.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js.map
rename to priv/static/adminfe/static/js/chunk-1ada.b41cb585.js.map
index 929c7ed14..27a2f8e5c 100644
Binary files a/priv/static/adminfe/static/js/chunk-9bb0.9c56835f.js.map and b/priv/static/adminfe/static/js/chunk-1ada.b41cb585.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js b/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js
new file mode 100644
index 000000000..21a0fde72
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js differ
diff --git a/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js.map b/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js.map
new file mode 100644
index 000000000..64ac03193
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-2aa6.be23b313.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js b/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js
new file mode 100644
index 000000000..57831d50d
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js differ
diff --git a/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js.map b/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js.map
new file mode 100644
index 000000000..a66a5fc00
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-3d8e.916ea1c1.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js b/priv/static/adminfe/static/js/chunk-4dc2.ec296292.js
similarity index 98%
rename from priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js
rename to priv/static/adminfe/static/js/chunk-4dc2.ec296292.js
index c63a38759..f7cbe90c4 100644
Binary files a/priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js and b/priv/static/adminfe/static/js/chunk-4dc2.ec296292.js differ
diff --git a/priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js.map b/priv/static/adminfe/static/js/chunk-4dc2.ec296292.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js.map
rename to priv/static/adminfe/static/js/chunk-4dc2.ec296292.js.map
index a0d4a6655..898961dd6 100644
Binary files a/priv/static/adminfe/static/js/chunk-1c46.b92c7c1b.js.map and b/priv/static/adminfe/static/js/chunk-4dc2.ec296292.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js b/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js
new file mode 100644
index 000000000..3a2a7694b
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js differ
diff --git a/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js.map b/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js.map
new file mode 100644
index 000000000..570df08e6
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-6b7b.e7ed7973.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-d01a.970cf312.js b/priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-d01a.970cf312.js
rename to priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js
index 7bbd51e24..9fef6e5dc 100644
Binary files a/priv/static/adminfe/static/js/chunk-d01a.970cf312.js and b/priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js differ
diff --git a/priv/static/adminfe/static/js/chunk-d01a.970cf312.js.map b/priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-d01a.970cf312.js.map
rename to priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js.map
index da3fbc95a..4b756b70a 100644
Binary files a/priv/static/adminfe/static/js/chunk-d01a.970cf312.js.map and b/priv/static/adminfe/static/js/chunk-6e77.d1988eaf.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js b/priv/static/adminfe/static/js/chunk-7f83.1321eab8.js
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js
rename to priv/static/adminfe/static/js/chunk-7f83.1321eab8.js
index 6311e5aa9..52c9efc2d 100644
Binary files a/priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js and b/priv/static/adminfe/static/js/chunk-7f83.1321eab8.js differ
diff --git a/priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js.map b/priv/static/adminfe/static/js/chunk-7f83.1321eab8.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js.map
rename to priv/static/adminfe/static/js/chunk-7f83.1321eab8.js.map
index 2172dcc92..5a7d9d6a2 100644
Binary files a/priv/static/adminfe/static/js/chunk-7de9.7b8cda50.js.map and b/priv/static/adminfe/static/js/chunk-7f83.1321eab8.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js b/priv/static/adminfe/static/js/chunk-7f8e.0505d295.js
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js
rename to priv/static/adminfe/static/js/chunk-7f8e.0505d295.js
index 06988ef73..43d8a02d8 100644
Binary files a/priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js and b/priv/static/adminfe/static/js/chunk-7f8e.0505d295.js differ
diff --git a/priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js.map b/priv/static/adminfe/static/js/chunk-7f8e.0505d295.js.map
similarity index 99%
rename from priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js.map
rename to priv/static/adminfe/static/js/chunk-7f8e.0505d295.js.map
index bf96082a8..d1100abb0 100644
Binary files a/priv/static/adminfe/static/js/chunk-7f8e.2c3e63e9.js.map and b/priv/static/adminfe/static/js/chunk-7f8e.0505d295.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js b/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js
deleted file mode 100644
index ae8abe56d..000000000
Binary files a/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js.map b/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js.map
deleted file mode 100644
index 34a06172f..000000000
Binary files a/priv/static/adminfe/static/js/chunk-7fe2.458f9da5.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-a601.cc880efe.js b/priv/static/adminfe/static/js/chunk-a601.cc880efe.js
deleted file mode 100644
index b30fe3033..000000000
Binary files a/priv/static/adminfe/static/js/chunk-a601.cc880efe.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-a601.cc880efe.js.map b/priv/static/adminfe/static/js/chunk-a601.cc880efe.js.map
deleted file mode 100644
index 5d2358da2..000000000
Binary files a/priv/static/adminfe/static/js/chunk-a601.cc880efe.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js b/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js
new file mode 100644
index 000000000..c76b0430b
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js differ
diff --git a/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js.map b/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js.map
new file mode 100644
index 000000000..fa9dc12f0
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-elementUI.2de79b84.js.map differ
diff --git a/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js b/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js
deleted file mode 100644
index 90ae35a35..000000000
Binary files a/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js.map b/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js.map
deleted file mode 100644
index 678122a98..000000000
Binary files a/priv/static/adminfe/static/js/chunk-elementUI.fa319e7b.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js b/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js
deleted file mode 100644
index 1c301e14a..000000000
Binary files a/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js.map b/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js.map
deleted file mode 100644
index 3b53caf53..000000000
Binary files a/priv/static/adminfe/static/js/chunk-f3c9.b3de53e2.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-libs.35c18287.js.map b/priv/static/adminfe/static/js/chunk-libs.35c18287.js.map
deleted file mode 100644
index 0a3580834..000000000
Binary files a/priv/static/adminfe/static/js/chunk-libs.35c18287.js.map and /dev/null differ
diff --git a/priv/static/adminfe/static/js/chunk-libs.35c18287.js b/priv/static/adminfe/static/js/chunk-libs.680db3fc.js
similarity index 94%
rename from priv/static/adminfe/static/js/chunk-libs.35c18287.js
rename to priv/static/adminfe/static/js/chunk-libs.680db3fc.js
index 4b76d98e6..478edf880 100644
Binary files a/priv/static/adminfe/static/js/chunk-libs.35c18287.js and b/priv/static/adminfe/static/js/chunk-libs.680db3fc.js differ
diff --git a/priv/static/adminfe/static/js/chunk-libs.680db3fc.js.map b/priv/static/adminfe/static/js/chunk-libs.680db3fc.js.map
new file mode 100644
index 000000000..f8c92c2fa
Binary files /dev/null and b/priv/static/adminfe/static/js/chunk-libs.680db3fc.js.map differ
diff --git a/priv/static/adminfe/static/js/runtime.cab03b3e.js b/priv/static/adminfe/static/js/runtime.cab03b3e.js
new file mode 100644
index 000000000..f700f7ccc
Binary files /dev/null and b/priv/static/adminfe/static/js/runtime.cab03b3e.js differ
diff --git a/priv/static/adminfe/static/js/runtime.cab03b3e.js.map b/priv/static/adminfe/static/js/runtime.cab03b3e.js.map
new file mode 100644
index 000000000..eca2ddd29
Binary files /dev/null and b/priv/static/adminfe/static/js/runtime.cab03b3e.js.map differ
diff --git a/priv/static/adminfe/static/js/runtime.d6d1aaab.js b/priv/static/adminfe/static/js/runtime.d6d1aaab.js
deleted file mode 100644
index ca1a91002..000000000
Binary files a/priv/static/adminfe/static/js/runtime.d6d1aaab.js and /dev/null differ
diff --git a/priv/static/adminfe/static/js/runtime.d6d1aaab.js.map b/priv/static/adminfe/static/js/runtime.d6d1aaab.js.map
deleted file mode 100644
index b938f1ba6..000000000
Binary files a/priv/static/adminfe/static/js/runtime.d6d1aaab.js.map and /dev/null differ
diff --git a/test/object_test.exs b/test/object_test.exs
index b002c2bae..9b4e6f0bf 100644
--- a/test/object_test.exs
+++ b/test/object_test.exs
@@ -4,12 +4,14 @@
defmodule Pleroma.ObjectTest do
use Pleroma.DataCase
+ use Oban.Testing, repo: Pleroma.Repo
import ExUnit.CaptureLog
import Pleroma.Factory
import Tesla.Mock
alias Pleroma.Activity
alias Pleroma.Object
alias Pleroma.Repo
+ alias Pleroma.Tests.ObanHelpers
alias Pleroma.Web.CommonAPI
setup do
@@ -99,6 +101,8 @@ test "in subdirectories" do
Object.delete(note)
+ ObanHelpers.perform(all_enqueued(worker: Pleroma.Workers.AttachmentsCleanupWorker))
+
assert Object.get_by_id(attachment.id) == nil
assert {:ok, []} == File.ls("#{uploads_dir}/#{path}")
@@ -133,10 +137,46 @@ test "with dedupe enabled" do
Object.delete(note)
+ ObanHelpers.perform(all_enqueued(worker: Pleroma.Workers.AttachmentsCleanupWorker))
+
assert Object.get_by_id(attachment.id) == nil
assert {:ok, files} = File.ls(uploads_dir)
refute filename in files
end
+
+ test "with objects that have legacy data.url attribute" do
+ Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+
+ file = %Plug.Upload{
+ content_type: "image/jpg",
+ path: Path.absname("test/fixtures/image.jpg"),
+ filename: "an_image.jpg"
+ }
+
+ user = insert(:user)
+
+ {:ok, %Object{} = attachment} =
+ Pleroma.Web.ActivityPub.ActivityPub.upload(file, actor: user.ap_id)
+
+ {:ok, %Object{}} = Object.create(%{url: "https://google.com", actor: user.ap_id})
+
+ %{data: %{"attachment" => [%{"url" => [%{"href" => href}]}]}} =
+ note = insert(:note, %{user: user, data: %{"attachment" => [attachment.data]}})
+
+ uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
+
+ path = href |> Path.dirname() |> Path.basename()
+
+ assert {:ok, ["an_image.jpg"]} == File.ls("#{uploads_dir}/#{path}")
+
+ Object.delete(note)
+
+ ObanHelpers.perform(all_enqueued(worker: Pleroma.Workers.AttachmentsCleanupWorker))
+
+ assert Object.get_by_id(attachment.id) == nil
+
+ assert {:ok, []} == File.ls("#{uploads_dir}/#{path}")
+ end
end
describe "normalizer" do
diff --git a/test/web/mastodon_api/controllers/search_controller_test.exs b/test/web/mastodon_api/controllers/search_controller_test.exs
index 7fedf42e5..effae130c 100644
--- a/test/web/mastodon_api/controllers/search_controller_test.exs
+++ b/test/web/mastodon_api/controllers/search_controller_test.exs
@@ -53,7 +53,8 @@ test "search", %{conn: conn} do
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
results =
- get(conn, "/api/v2/search", %{"q" => "2hu #private"})
+ conn
+ |> get("/api/v2/search", %{"q" => "2hu #private"})
|> json_response(200)
[account | _] = results["accounts"]
@@ -73,6 +74,30 @@ test "search", %{conn: conn} do
[status] = results["statuses"]
assert status["id"] == to_string(activity.id)
end
+
+ test "excludes a blocked users from search results", %{conn: conn} do
+ user = insert(:user)
+ user_smith = insert(:user, %{nickname: "Agent", name: "I love 2hu"})
+ user_neo = insert(:user, %{nickname: "Agent Neo", name: "Agent"})
+
+ {:ok, act1} = CommonAPI.post(user, %{"status" => "This is about 2hu private 天子"})
+ {:ok, act2} = CommonAPI.post(user_smith, %{"status" => "Agent Smith"})
+ {:ok, act3} = CommonAPI.post(user_neo, %{"status" => "Agent Smith"})
+ Pleroma.User.block(user, user_smith)
+
+ results =
+ conn
+ |> assign(:user, user)
+ |> assign(:token, insert(:oauth_token, user: user, scopes: ["read"]))
+ |> get("/api/v2/search", %{"q" => "Agent"})
+ |> json_response(200)
+
+ status_ids = Enum.map(results["statuses"], fn g -> g["id"] end)
+
+ assert act3.id in status_ids
+ refute act2.id in status_ids
+ refute act1.id in status_ids
+ end
end
describe ".account_search" do
@@ -146,11 +171,10 @@ test "search", %{conn: conn} do
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
- conn =
+ results =
conn
|> get("/api/v1/search", %{"q" => "2hu"})
-
- assert results = json_response(conn, 200)
+ |> json_response(200)
[account | _] = results["accounts"]
assert account["id"] == to_string(user_three.id)
@@ -168,11 +192,10 @@ test "search fetches remote statuses and prefers them over other results", %{con
"status" => "check out https://shitposter.club/notice/2827873"
})
- conn =
+ results =
conn
|> get("/api/v1/search", %{"q" => "https://shitposter.club/notice/2827873"})
-
- assert results = json_response(conn, 200)
+ |> json_response(200)
[status, %{"id" => ^activity_id}] = results["statuses"]
@@ -189,11 +212,10 @@ test "search doesn't show statuses that it shouldn't", %{conn: conn} do
})
capture_log(fn ->
- conn =
+ results =
conn
|> get("/api/v1/search", %{"q" => Object.normalize(activity).data["id"]})
-
- assert results = json_response(conn, 200)
+ |> json_response(200)
[] = results["statuses"]
end)
@@ -202,23 +224,23 @@ test "search doesn't show statuses that it shouldn't", %{conn: conn} do
test "search fetches remote accounts", %{conn: conn} do
user = insert(:user)
- conn =
+ results =
conn
|> assign(:user, user)
|> assign(:token, insert(:oauth_token, user: user, scopes: ["read"]))
|> get("/api/v1/search", %{"q" => "mike@osada.macgirvin.com", "resolve" => "true"})
+ |> json_response(200)
- assert results = json_response(conn, 200)
[account] = results["accounts"]
assert account["acct"] == "mike@osada.macgirvin.com"
end
test "search doesn't fetch remote accounts if resolve is false", %{conn: conn} do
- conn =
+ results =
conn
|> get("/api/v1/search", %{"q" => "mike@osada.macgirvin.com", "resolve" => "false"})
+ |> json_response(200)
- assert results = json_response(conn, 200)
assert [] == results["accounts"]
end
diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs
index 17b6ebcbc..b54b19c0b 100644
--- a/test/web/mastodon_api/views/status_view_test.exs
+++ b/test/web/mastodon_api/views/status_view_test.exs
@@ -24,6 +24,22 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
:ok
end
+ test "has an emoji reaction list" do
+ user = insert(:user)
+ other_user = insert(:user)
+ third_user = insert(:user)
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "dae cofe??"})
+
+ {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, user, "☕")
+ {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
+ {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
+ activity = Repo.get(Activity, activity.id)
+ status = StatusView.render("show.json", activity: activity)
+
+ assert status[:pleroma][:emoji_reactions]["🍵"] == 1
+ assert status[:pleroma][:emoji_reactions]["☕"] == 2
+ end
+
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
user = insert(:user)
@@ -172,7 +188,8 @@ test "a note activity" do
spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])},
expires_at: nil,
direct_conversation_id: nil,
- thread_muted: false
+ thread_muted: false,
+ emoji_reactions: %{}
}
}