Skip to content
Snippets Groups Projects
Commit 509ba466 authored by Martin Lees's avatar Martin Lees Committed by Howo
Browse files

fix plsql function to accomodate the new haf bindings

parent 3b1b621a
No related branches found
No related tags found
1 merge request!539Update SetRole/SetUserTitle so that you have to be subscribed to get it, also...
This commit is part of merge request !539. Comments created here will be created in the context of that merge request.
DROP FUNCTION IF EXISTS set_community_role_or_title;
CREATE OR REPLACE FUNCTION set_community_role_or_title(_community_id hive_posts.community_id%TYPE, _account_id hive_posts.author_id%TYPE, _role_id integer, _title varchar(140), _created_at timestamp)
DROP FUNCTION IF EXISTS hivemind_app.set_community_role_or_title;
CREATE OR REPLACE FUNCTION hivemind_app.set_community_role_or_title(_community_id hivemind_app.hive_posts.community_id%TYPE, _account_id hivemind_app.hive_posts.author_id%TYPE, _role_id integer, _title varchar(140), _created_at timestamp)
RETURNS bool
LANGUAGE plpgsql
as
......@@ -8,11 +8,11 @@ declare
__subscription_id INTEGER;
__role_id SMALLINT;
BEGIN
SELECT id INTO __subscription_id FROM hive_subscriptions WHERE account_id = _account_id AND community_id = _community_id;
SELECT id INTO __subscription_id FROM hivemind_app.hive_subscriptions WHERE account_id = _account_id AND community_id = _community_id;
IF _role_id IS NOT NULL THEN
-- We allow setting the MUTED role even if you're not subscribed
IF _role_id > 0 THEN
SELECT role_id INTO __role_id FROM hive_roles WHERE account_id = _account_id AND community_id = _community_id;
SELECT role_id INTO __role_id FROM hivemind_app.hive_roles WHERE account_id = _account_id AND community_id = _community_id;
-- We don't allow setting a higher role than the current one if you aren't subscribed
IF __subscription_id IS NULL AND ((__role_id IS NOT NULL AND __role_id < _role_id ) OR __role_id IS NULL) THEN
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment