diff options
author | eugenijm <eugenijm@protonmail.com> | 2020-05-18 18:46:04 +0300 |
---|---|---|
committer | eugenijm <eugenijm@protonmail.com> | 2020-06-14 18:27:11 +0300 |
commit | b15cfc3d365dcfa5f99159fe06e29de6f8aceb4f (patch) | |
tree | 156ff3c3c0fb6eb12064e536ae5a754048b48af4 /lib/pleroma/notification.ex | |
parent | 271ea5068f4e3b901cb3f682e132378246daf452 (diff) | |
download | pleroma-b15cfc3d365dcfa5f99159fe06e29de6f8aceb4f.tar.gz |
Mastodon API: ensure the notification endpoint doesn't return less than the requested amount of records unless it's the last page
Diffstat (limited to 'lib/pleroma/notification.ex')
-rw-r--r-- | lib/pleroma/notification.ex | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 3386a1933..9ee9606be 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -166,8 +166,16 @@ defmodule Pleroma.Notification do query |> join(:left, [n, a], mutated_activity in Pleroma.Activity, on: - fragment("?->>'context'", a.data) == - fragment("?->>'context'", mutated_activity.data) and + fragment( + "COALESCE((?->'object')->>'id', ?->>'object')", + a.data, + a.data + ) == + fragment( + "COALESCE((?->'object')->>'id', ?->>'object')", + mutated_activity.data, + mutated_activity.data + ) and fragment("(?->>'type' = 'Like' or ?->>'type' = 'Announce')", a.data, a.data) and fragment("?->>'type'", mutated_activity.data) == "Create", as: :mutated_activity @@ -541,6 +549,7 @@ defmodule Pleroma.Notification do def skip?(%Activity{} = activity, %User{} = user) do [ :self, + :invisible, :followers, :follows, :non_followers, @@ -557,6 +566,12 @@ defmodule Pleroma.Notification do activity.data["actor"] == user.ap_id end + def skip?(:invisible, %Activity{} = activity, _) do + actor = activity.data["actor"] + user = User.get_cached_by_ap_id(actor) + User.invisible?(user) + end + def skip?( :followers, %Activity{} = activity, |