1 defmodule Pleroma.Repo.Migrations.UpdateActivityVisibility do
3 @disable_ddl_transaction true
7 create or replace function activity_visibility(actor varchar, recipients varchar[], data jsonb) returns varchar as $$
10 public varchar := 'https://www.w3.org/ns/activitystreams#Public';
12 SELECT COALESCE(users.follower_address, '') into fa from users where users.ap_id = actor;
14 IF data->'to' ? public THEN
16 ELSIF data->'cc' ? public THEN
18 ELSIF ARRAY[fa] && recipients THEN
20 ELSIF not(ARRAY[fa, public] && recipients) THEN
26 $$ LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE SECURITY DEFINER;