aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-03-20 14:52:58 +0100
committerlain <lain@soykaf.club>2020-03-20 14:52:58 +0100
commit1aa8aa7d7f14c553a8f0bf1ae82f1a1169cb0fc2 (patch)
treef69f8dbf3a012bab253fe267daf967616eefcc0a /lib
parent9b9d67bbec537df6f7c5729e81da6deeaf896bd9 (diff)
parentd63dca8d99196c91dc3e20e2d27f61ea753b84af (diff)
downloadpleroma-1aa8aa7d7f14c553a8f0bf1ae82f1a1169cb0fc2.tar.gz
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-2
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex9
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api.ex23
-rw-r--r--lib/pleroma/web/nodeinfo/nodeinfo_controller.ex1
3 files changed, 17 insertions, 16 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 60dba3434..3ef3b3f58 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -77,7 +77,6 @@ defmodule Pleroma.Notification do
|> exclude_notification_muted(user, exclude_notification_muted_opts)
|> exclude_blocked(user, exclude_blocked_opts)
|> exclude_visibility(opts)
- |> exclude_move(opts)
end
defp exclude_blocked(query, user, opts) do
@@ -107,14 +106,6 @@ defmodule Pleroma.Notification do
|> where([n, a, o, tm], is_nil(tm.user_id))
end
- defp exclude_move(query, %{with_move: true}) do
- query
- end
-
- defp exclude_move(query, _opts) do
- where(query, [n, a], fragment("?->>'type' != 'Move'", a.data))
- end
-
@valid_visibilities ~w[direct unlisted public private]
defp exclude_visibility(query, %{exclude_visibilities: visibility})
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api.ex b/lib/pleroma/web/mastodon_api/mastodon_api.ex
index 3fe2be521..70da64a7a 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api.ex
@@ -55,6 +55,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
user
|> Notification.for_user_query(options)
+ |> restrict(:include_types, options)
|> restrict(:exclude_types, options)
|> restrict(:account_ap_id, options)
|> Pagination.fetch_paginated(params)
@@ -69,10 +70,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
defp cast_params(params) do
param_types = %{
exclude_types: {:array, :string},
+ include_types: {:array, :string},
exclude_visibilities: {:array, :string},
reblogs: :boolean,
with_muted: :boolean,
- with_move: :boolean,
account_ap_id: :string
}
@@ -80,14 +81,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
changeset.changes
end
+ defp restrict(query, :include_types, %{include_types: mastodon_types = [_ | _]}) do
+ ap_types = convert_and_filter_mastodon_types(mastodon_types)
+
+ where(query, [q, a], fragment("? @> ARRAY[?->>'type']::varchar[]", ^ap_types, a.data))
+ end
+
defp restrict(query, :exclude_types, %{exclude_types: mastodon_types = [_ | _]}) do
- ap_types =
- mastodon_types
- |> Enum.map(&Activity.from_mastodon_notification_type/1)
- |> Enum.filter(& &1)
+ ap_types = convert_and_filter_mastodon_types(mastodon_types)
- query
- |> where([q, a], not fragment("? @> ARRAY[?->>'type']::varchar[]", ^ap_types, a.data))
+ where(query, [q, a], not fragment("? @> ARRAY[?->>'type']::varchar[]", ^ap_types, a.data))
end
defp restrict(query, :account_ap_id, %{account_ap_id: account_ap_id}) do
@@ -95,4 +98,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
end
defp restrict(query, _, _), do: query
+
+ defp convert_and_filter_mastodon_types(types) do
+ types
+ |> Enum.map(&Activity.from_mastodon_notification_type/1)
+ |> Enum.filter(& &1)
+ end
end
diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
index 18eb41333..30838b1eb 100644
--- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
+++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
@@ -60,6 +60,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
"pleroma_explicit_addressing",
"shareable_emoji_packs",
"multifetch",
+ "pleroma:api/v1/notifications:include_types_filter",
if Config.get([:media_proxy, :enabled]) do
"media_proxy"
end,