forked from AkkomaGang/akkoma
thread visibility function: significantly improve efficiency
This commit is contained in:
parent
f09c3afdf5
commit
71fa7eeb6f
1 changed files with 9 additions and 18 deletions
|
@ -10,8 +10,8 @@ def up do
|
||||||
child objects%ROWTYPE;
|
child objects%ROWTYPE;
|
||||||
activity activities%ROWTYPE;
|
activity activities%ROWTYPE;
|
||||||
actor_user users%ROWTYPE;
|
actor_user users%ROWTYPE;
|
||||||
author users%ROWTYPE;
|
|
||||||
author_fa varchar;
|
author_fa varchar;
|
||||||
|
valid_recipients varchar[];
|
||||||
BEGIN
|
BEGIN
|
||||||
--- Fetch our actor.
|
--- Fetch our actor.
|
||||||
SELECT * INTO actor_user FROM users WHERE users.ap_id = actor;
|
SELECT * INTO actor_user FROM users WHERE users.ap_id = actor;
|
||||||
|
@ -36,26 +36,17 @@ def up do
|
||||||
INNER JOIN activities ON COALESCE(activities.data->'object'->>'id', activities.data->>'object') = objects.data->>'id'
|
INNER JOIN activities ON COALESCE(activities.data->'object'->>'id', activities.data->>'object') = objects.data->>'id'
|
||||||
WHERE COALESCE(activity.data->'object'->>'id', activity.data->>'object') = objects.data->>'id';
|
WHERE COALESCE(activity.data->'object'->>'id', activity.data->>'object') = objects.data->>'id';
|
||||||
|
|
||||||
--- Fetch the author.
|
--- Fetch the author's AS2 following collection.
|
||||||
SELECT * INTO author FROM users WHERE users.ap_id = activity.actor;
|
SELECT COALESCE(author.follower_address, '') INTO author_fa FROM users WHERE users.ap_id = activity.actor;
|
||||||
|
|
||||||
--- Prepare author's AS2 followers collection.
|
--- Prepare valid recipients array.
|
||||||
SELECT COALESCE(author.follower_address, '') INTO author_fa;
|
valid_recipients := ARRAY[actor, public];
|
||||||
|
IF ARRAY[author_fa] && actor_user.following THEN
|
||||||
|
valid_recipients := valid_recipients || author_fa;
|
||||||
|
END IF;
|
||||||
|
|
||||||
--- Check visibility.
|
--- Check visibility.
|
||||||
IF activity.actor = actor THEN
|
IF NOT valid_recipients && activity.recipients THEN
|
||||||
--- activity visible
|
|
||||||
NULL;
|
|
||||||
ELSIF ARRAY[public] && activity.recipients THEN
|
|
||||||
--- activity visible
|
|
||||||
NULL;
|
|
||||||
ELSIF ARRAY[author_fa] && activity.recipients AND ARRAY[author_fa] && actor_user.following THEN
|
|
||||||
--- activity visible
|
|
||||||
NULL;
|
|
||||||
ELSIF ARRAY[actor] && activity.recipients THEN
|
|
||||||
--- activity visible
|
|
||||||
NULL;
|
|
||||||
ELSE
|
|
||||||
--- activity not visible, break out of the loop
|
--- activity not visible, break out of the loop
|
||||||
RETURN false;
|
RETURN false;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
Loading…
Reference in a new issue