aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-12-08 13:07:05 +0000
committerrinpatch <rinpatch@sdf.org>2019-12-08 13:07:05 +0000
commit8404f8c8fbc4a60473df0977bc05e2587207d811 (patch)
treebff0ee7f5d0280722cfc49748103204d08394d6b /lib/pleroma
parent29a3f70cba7bed31e6777832c4d2dc5c326b70c1 (diff)
parentd4953474ac5546d771879c32d3a7ec40675a00a1 (diff)
downloadpleroma-8404f8c8fbc4a60473df0977bc05e2587207d811.tar.gz
Merge branch 'improve-move-notificaions-api' into 'develop'
Add `with_move` query param to the notifications API See merge request pleroma/pleroma!2032
Diffstat (limited to 'lib/pleroma')
-rw-r--r--lib/pleroma/following_relationship.ex8
-rw-r--r--lib/pleroma/notification.ex9
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api.ex3
3 files changed, 17 insertions, 3 deletions
diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex
index a03c9bd30..0b0219b82 100644
--- a/lib/pleroma/following_relationship.ex
+++ b/lib/pleroma/following_relationship.ex
@@ -121,8 +121,12 @@ defmodule Pleroma.FollowingRelationship do
Pleroma.Web.CommonAPI.follow(following_relationship.follower, target)
end)
|> case do
- [] -> :ok
- _ -> move_following(origin, target)
+ [] ->
+ User.update_follower_count(origin)
+ :ok
+
+ _ ->
+ move_following(origin, target)
end
end
end
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 43719b962..71423ce5e 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -77,6 +77,7 @@ 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
@@ -106,6 +107,14 @@ 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 ee253a342..b1816370e 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api.ex
@@ -70,7 +70,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
exclude_types: {:array, :string},
exclude_visibilities: {:array, :string},
reblogs: :boolean,
- with_muted: :boolean
+ with_muted: :boolean,
+ with_move: :boolean
}
changeset = cast({%{}, param_types}, params, Map.keys(param_types))