pg_merchant_send_signup_notification.sql (2263B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2026 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 16 -- @file pg_merchant_send_signup_notification.sql 17 -- @brief Queue a report telling the merchant the details of a new instance 18 -- @author Christian Grothoff 19 20 21 DROP PROCEDURE IF EXISTS merchant.merchant_send_signup_notification; 22 CREATE PROCEDURE merchant.merchant_send_signup_notification( 23 in_merchant_serial INT8 24 ,in_email TEXT 25 ) 26 LANGUAGE plpgsql 27 AS $$ 28 BEGIN 29 -- Unlike the KYC and account alerts, this does not check 30 -- notification_language: the message tells the merchant their 31 -- login name, which they need whether or not they want alerts. 32 -- Runs from the INSERT trigger on merchant.merchant_instances, 33 -- so the per-instance schema must be named explicitly. 34 EXECUTE format( 35 'INSERT INTO %I.merchant_reports' 36 ' (report_program_section' 37 ' ,report_description' 38 ' ,mime_type' 39 ' ,report_token' 40 ' ,data_source' 41 ' ,target_address' 42 ' ,frequency' 43 ' ,frequency_shift' 44 ' ,next_transmission' 45 ' ,one_shot_hidden' 46 ' ) VALUES ($1, $2, $3, $4, $5, $6, 0, 0, 0, TRUE)' 47 ,'merchant_instance_' || in_merchant_serial::TEXT) 48 USING 'email' 49 ,'Your GNU Taler merchant account' 50 ,'text/plain' 51 ,merchant.random_bytea(32) 52 ,'/private' 53 ,in_email; 54 -- Notify taler-merchant-report-generator 55 NOTIFY XSSAB8NCBQR1K2VK7H2M6SMY3V5TNJT1C3BW0SN4F2QV0KHR3PRB0; 56 END $$; 57 COMMENT ON PROCEDURE merchant.merchant_send_signup_notification(INT8, TEXT) 58 IS 'Queues a one-shot e-mail report with the details (including the' 59 ' login name) of the instance with the given merchant_serial.';