Triggering notifications for children of alert entities. Showing icons in alert entity search to distinguish networks and channels.
This commit is contained in:
@@ -57,7 +57,6 @@ async function notify(scenes) {
|
||||
LEFT JOIN users ON users.id = alerts.user_id
|
||||
LEFT JOIN releases_tags ON releases_tags.release_id = releases.id
|
||||
/* match updated IDs from input */
|
||||
WHERE users.id = :userId
|
||||
WHERE (releases.id = ANY(:sceneIds))
|
||||
/* match tags */
|
||||
AND (NOT EXISTS (SELECT alerts_tags.alert_id
|
||||
@@ -88,9 +87,25 @@ async function notify(scenes) {
|
||||
FROM alerts_entities
|
||||
WHERE alerts_entities.alert_id = alerts.id))
|
||||
OR (releases.entity_id
|
||||
= ANY(array(SELECT alerts_entities.entity_id
|
||||
FROM alerts_entities
|
||||
WHERE alerts_entities.alert_id = alerts.id))))
|
||||
= ANY(array(
|
||||
/* include children of entities */
|
||||
WITH RECURSIVE included AS (
|
||||
SELECT entities.*
|
||||
FROM alerts_entities
|
||||
LEFT JOIN entities ON entities.id = alerts_entities.entity_id
|
||||
WHERE alerts_entities.alert_id = alerts.id
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT entities.*
|
||||
FROM entities
|
||||
INNER JOIN included ON included.id = entities.parent_id
|
||||
)
|
||||
|
||||
SELECT included.id
|
||||
FROM included
|
||||
GROUP BY included.id
|
||||
))))
|
||||
GROUP BY releases.id, users.id, alerts.id;
|
||||
`, {
|
||||
sceneIds: scenes.map(scene => scene.id),
|
||||
@@ -117,7 +132,6 @@ async function updateNotification(notificationId, notification, sessionUser) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function updateNotifications(notification, sessionUser) {
|
||||
console.log(notification, sessionUser.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user