29 lines
780 B
MySQL
29 lines
780 B
MySQL
|
DROP FUNCTION IF EXISTS `util`.`notification_send`;
|
||
|
DELIMITER $$
|
||
|
CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT)
|
||
|
RETURNS INT
|
||
|
MODIFIES SQL DATA
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Sends a notification.
|
||
|
*
|
||
|
* @param vNotificationName The notification name
|
||
|
* @param vParams The notification parameters formatted as JSON
|
||
|
* @param vAuthorFk The notification author or %NULL if there is no author
|
||
|
* @return The notification id
|
||
|
*/
|
||
|
DECLARE vNotificationFk INT;
|
||
|
|
||
|
SELECT id INTO vNotificationFk
|
||
|
FROM `notification`
|
||
|
WHERE `name` = vNotificationName;
|
||
|
|
||
|
INSERT INTO notificationQueue
|
||
|
SET notificationFk = vNotificationFk,
|
||
|
params = vParams,
|
||
|
authorFk = vAuthorFk;
|
||
|
|
||
|
RETURN LAST_INSERT_ID();
|
||
|
END$$
|
||
|
DELIMITER ;
|