Skip to content
Snippets Groups Projects

changes in various places to clean the code and fix small problems

Merged Andrzej Lisak requested to merge abw_code_cleanup into develop
5 files
+ 93
89
Compare changes
  • Side-by-side
  • Inline
Files
5
  • 3c1a653c
    mutes_get_blacklists_for_observer slightly modified: added filter flags and explicit information if accounts are blacklisted or muted
    fixed get_relationship_between_account: is_blacklisted in results was misleading, replaced with blacklists
    does_user_follow_any_lists and get_follow_list reimplemented with use of get_blacklists_for_observer
DROP FUNCTION IF EXISTS mutes_get_blacklists_for_observer;
CREATE FUNCTION mutes_get_blacklists_for_observer( in _observer VARCHAR )
CREATE FUNCTION mutes_get_blacklists_for_observer( in _observer VARCHAR, in _flags INTEGER )
RETURNS TABLE(
account hive_accounts.name%TYPE,
source VARCHAR
source VARCHAR,
is_blacklisted BOOLEAN -- False means muted
)
AS
$function$
@@ -10,42 +11,54 @@ DECLARE
__observer_id INT;
BEGIN
__observer_id = find_account_id( _observer, True );
RETURN QUERY SELECT -- mutes_get_blacklists_for_observer (local observer blacklist)
ha.name AS account,
_observer AS source
FROM
hive_follows hf
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.blacklisted;
RETURN QUERY SELECT -- mutes_get_blacklists_for_observer (indirect observer blacklists)
ha_i.name AS account,
ha.name AS source
FROM
hive_follows hf
JOIN hive_follows hf_i ON hf_i.follower = hf.following
JOIN hive_accounts ha_i ON ha_i.id = hf_i.following
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.follow_blacklists AND hf_i.blacklisted;
RETURN QUERY SELECT-- mutes_get_blacklists_for_observer (local observer mute list)
ha.name AS account,
CONCAT( _observer, ' (mute list)' )::VARCHAR AS source
FROM
hive_follows hf
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.state = 2;
RETURN QUERY SELECT-- mutes_get_blacklists_for_observer (indirect observer mute list)
ha_i.name AS account,
CONCAT( ha.name, ' (mute list)' )::VARCHAR AS source
FROM
hive_follows hf
JOIN hive_follows hf_i ON hf_i.follower = hf.following
JOIN hive_accounts ha_i ON ha_i.id = hf_i.following
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.follow_muted AND hf_i.state = 2;
IF (_flags & 1)::BOOLEAN THEN
RETURN QUERY SELECT -- mutes_get_blacklists_for_observer (local observer blacklist)
ha.name AS account,
_observer AS source,
True
FROM
hive_follows hf
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.blacklisted;
END IF;
IF (_flags & 2)::BOOLEAN THEN
RETURN QUERY SELECT -- mutes_get_blacklists_for_observer (indirect observer blacklists)
ha_i.name AS account,
ha.name AS source,
True
FROM
hive_follows hf
JOIN hive_follows hf_i ON hf_i.follower = hf.following
JOIN hive_accounts ha_i ON ha_i.id = hf_i.following
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.follow_blacklists AND hf_i.blacklisted;
END IF;
IF (_flags & 4)::BOOLEAN THEN
RETURN QUERY SELECT-- mutes_get_blacklists_for_observer (local observer mute list)
ha.name AS account,
_observer AS source,
False
FROM
hive_follows hf
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.state = 2;
END IF;
IF (_flags & 8)::BOOLEAN THEN
RETURN QUERY SELECT-- mutes_get_blacklists_for_observer (indirect observer mute list)
ha_i.name AS account,
ha.name AS source,
False
FROM
hive_follows hf
JOIN hive_follows hf_i ON hf_i.follower = hf.following
JOIN hive_accounts ha_i ON ha_i.id = hf_i.following
JOIN hive_accounts ha ON ha.id = hf.following
WHERE
hf.follower = __observer_id AND hf.follow_muted AND hf_i.state = 2;
END IF;
END
$function$
language plpgsql STABLE;
Loading