Use indexed split_part/3 to get a hostname rather than ts_ functions
This commit is contained in:
parent
01bd6a1e54
commit
1be6b3056e
1 changed files with 1 additions and 6 deletions
|
@ -25,22 +25,17 @@ def up do
|
||||||
RETURNS TRIGGER AS
|
RETURNS TRIGGER AS
|
||||||
$$
|
$$
|
||||||
DECLARE
|
DECLARE
|
||||||
token_id smallint;
|
|
||||||
hostname character varying(255);
|
hostname character varying(255);
|
||||||
visibility_new character varying(64);
|
visibility_new character varying(64);
|
||||||
visibility_old character varying(64);
|
visibility_old character varying(64);
|
||||||
actor character varying(255);
|
actor character varying(255);
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT "tokid" INTO "token_id" FROM ts_token_type('default') WHERE "alias" = 'host';
|
|
||||||
IF TG_OP = 'DELETE' THEN
|
IF TG_OP = 'DELETE' THEN
|
||||||
actor := OLD.actor;
|
actor := OLD.actor;
|
||||||
ELSE
|
ELSE
|
||||||
actor := NEW.actor;
|
actor := NEW.actor;
|
||||||
END IF;
|
END IF;
|
||||||
SELECT "token" INTO "hostname" FROM ts_parse('default', actor) WHERE "tokid" = token_id;
|
hostname := split_part(actor, '/', 3);
|
||||||
IF hostname IS NULL THEN
|
|
||||||
hostname := split_part(actor, '/', 3);
|
|
||||||
END IF;
|
|
||||||
IF TG_OP = 'INSERT' THEN
|
IF TG_OP = 'INSERT' THEN
|
||||||
visibility_new := activity_visibility(NEW.actor, NEW.recipients, NEW.data);
|
visibility_new := activity_visibility(NEW.actor, NEW.recipients, NEW.data);
|
||||||
IF NEW.data->>'type' = 'Create'
|
IF NEW.data->>'type' = 'Create'
|
||||||
|
|
Loading…
Reference in a new issue