Add a simple API for hiding messages containing viruses etc.
authorDave Page <dpage@pgadmin.org>
Sat, 15 Jun 2013 19:56:44 +0000 (20:56 +0100)
committerDave Page <dpage@pgadmin.org>
Sat, 15 Jun 2013 19:56:44 +0000 (20:56 +0100)
loader/sql/schema.sql

index 97585f0160eb445300b13f44d0d79c2077b9d460..be0c758ecf8e5c0475f93e6ac4d4197a09a5c822 100644 (file)
@@ -134,4 +134,25 @@ CREATE TABLE legacymap(
 CONSTRAINT legacymap_pk PRIMARY KEY (listid, year, month, msgnum)
 );
 
+/* Simple API for hiding messages */
+CREATE OR REPLACE FUNCTION hide_message(msgid_txt text, reason_code integer, user_txt text, reason_txt text)
+  RETURNS integer AS
+$BODY$
+DECLARE
+    returned_id integer;
+BEGIN
+    UPDATE messages SET hiddenstatus = reason_code WHERE messageid = msgid_txt RETURNING id INTO returned_id;
+
+    IF NOT FOUND THEN
+       RAISE EXCEPTION 'The specified message (%) could not be found.', msgid_txt;
+    END IF;
+
+    INSERT INTO message_hide_reasons (message, dt, reason, by) VALUES (returned_id, now(), reason_txt, user_txt);
+
+    RETURN returned_id;
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE
+  COST 100;
+
 \echo Dont forget to commit!