1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.UpdateActivityVisibility do
7 @disable_ddl_transaction true
11 create or replace function activity_visibility(actor varchar, recipients varchar[], data jsonb) returns varchar as $$
14 public varchar := 'https://www.w3.org/ns/activitystreams#Public';
16 SELECT COALESCE(users.follower_address, '') into fa from users where users.ap_id = actor;
18 IF data->'to' ? public THEN
20 ELSIF data->'cc' ? public THEN
22 ELSIF ARRAY[fa] && recipients THEN
24 ELSIF not(ARRAY[fa, public] && recipients) THEN
30 $$ LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE SECURITY DEFINER;