minor fixes

This commit is contained in:
fbsanchez 2021-02-19 13:57:39 +01:00
parent 0fb3ba9232
commit 925f456ef7
1 changed files with 16 additions and 13 deletions

View File

@ -161,10 +161,8 @@ function notifications_get_subtypes(?string $source=null)
'NOTIF.ALLOWOVERRIDE.MESSAGE', 'NOTIF.ALLOWOVERRIDE.MESSAGE',
'NOTIF.HAMASTER.MESSAGE', 'NOTIF.HAMASTER.MESSAGE',
'NOTIF.SERVER.STATUS', 'NOTIF.SERVER.STATUS',
'NOTIF.SERVER.STATUS.ID_SERVER', 'NOTIF.SERVER.QUEUE',
'NOTIF.SERVER.QUEUE.ID_SERVER',
'NOTIF.SERVER.MASTER', 'NOTIF.SERVER.MASTER',
'NOTIF.SERVER.STATUS.ID_SERVER',
], ],
]; ];
@ -233,9 +231,15 @@ function get_notification_source_targets(int $id_source, ?string $subtype=null)
{ {
$ret = []; $ret = [];
$filter = '';
if ($subtype !== null) { if ($subtype !== null) {
$matches = [];
if (preg_match('/(.*)\.\d+$/', $subtype, $matches) > 0) {
$subtype = $matches[1];
}
$filter = sprintf( $filter = sprintf(
' AND ns.`subtype_blacklist` NOT LIKE "%s"', ' AND ns.`subtype_blacklist` NOT LIKE "%%%s%%"',
$subtype $subtype
); );
} }
@ -248,13 +252,12 @@ function get_notification_source_targets(int $id_source, ?string $subtype=null)
FROM tnotification_source_user nsu FROM tnotification_source_user nsu
INNER JOIN tnotification_source ns INNER JOIN tnotification_source ns
ON ns.id=nsu.id_source ON ns.id=nsu.id_source
%s
WHERE ns.id = %d WHERE ns.id = %d
AND ((ns.enabled is NULL OR ns.enabled != 0) AND ((ns.enabled is NULL OR ns.enabled != 0)
OR (nsu.enabled is NULL OR nsu.enabled != 0)) OR (nsu.enabled is NULL OR nsu.enabled != 0))',
%s $filter,
', $id_source
$id_source,
$filter
) )
); );
@ -272,11 +275,11 @@ function get_notification_source_targets(int $id_source, ?string $subtype=null)
FROM tnotification_source_group nsg FROM tnotification_source_group nsg
INNER JOIN tnotification_source ns INNER JOIN tnotification_source ns
ON ns.id=nsg.id_source ON ns.id=nsg.id_source
%s
WHERE ns.id = %d WHERE ns.id = %d
AND (ns.enabled is NULL OR ns.enabled != 0) AND (ns.enabled is NULL OR ns.enabled != 0)',
%s', $filter,
$id_source, $id_source
$filter
) )
); );