add notificationId to every broadcast notification
This commit is contained in:
@@ -2,9 +2,9 @@ export const adminNotificationsListener = (echo, userData, setNotifications, set
|
|||||||
if (userData.isAdmin) {
|
if (userData.isAdmin) {
|
||||||
const channelName = "users.admin";
|
const channelName = "users.admin";
|
||||||
|
|
||||||
const handleNotification = (content) => {
|
const handleNotification = (id, content) => {
|
||||||
const newNotification = {
|
const newNotification = {
|
||||||
id: Date.now(),
|
id,
|
||||||
content,
|
content,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
pivot: { unread: 1 }
|
pivot: { unread: 1 }
|
||||||
@@ -15,7 +15,7 @@ export const adminNotificationsListener = (echo, userData, setNotifications, set
|
|||||||
|
|
||||||
echo.private(channelName)
|
echo.private(channelName)
|
||||||
.listen(".users.registration", (event) => {
|
.listen(".users.registration", (event) => {
|
||||||
handleNotification(`Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`);
|
handleNotification(event.notificationId, `Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`);
|
||||||
updatePendingMembers();
|
updatePendingMembers();
|
||||||
});
|
});
|
||||||
return channelName;
|
return channelName;
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ export const userNotificationsListener = (echo, userData, setNotifications, setU
|
|||||||
|
|
||||||
const channelName = `user.${userData.id}`;
|
const channelName = `user.${userData.id}`;
|
||||||
|
|
||||||
const handleNotification = (content) => {
|
const handleNotification = (id, content) => {
|
||||||
|
|
||||||
const newNotification = {
|
const newNotification = {
|
||||||
id: Date.now(),
|
id,
|
||||||
content,
|
content,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
pivot: { unread: 1 }
|
pivot: { unread: 1 }
|
||||||
@@ -17,21 +17,21 @@ export const userNotificationsListener = (echo, userData, setNotifications, setU
|
|||||||
|
|
||||||
return echo.private(channelName)
|
return echo.private(channelName)
|
||||||
.listen('.event.participation.cancelled', (event) => {
|
.listen('.event.participation.cancelled', (event) => {
|
||||||
handleNotification(`L'événement ${event.event.name} a été supprimé. Vous n'y participez donc plus.`);
|
handleNotification(event.notificationId,`L'événement ${event.event.name} a été supprimé. Vous n'y participez donc plus.`);
|
||||||
})
|
})
|
||||||
.listen(`.task.participation.cancelled`, (event) => {
|
.listen(`.task.participation.cancelled`, (event) => {
|
||||||
handleNotification(`La tâche ${event.task.name} de l'événement ${event.event.name} a été supprimée. Vous n'y participez donc plus.`);
|
handleNotification(event.notificationId,`La tâche ${event.task.name} de l'événement ${event.event.name} a été supprimée. Vous n'y participez donc plus.`);
|
||||||
})
|
})
|
||||||
.listen('.volunteer.assigned.to.task', (event) => {
|
.listen('.volunteer.assigned.to.task', (event) => {
|
||||||
handleNotification(`Vous avez été assigné à la tâche ${event.task.name} de l'événement ${event.event.name}.`);
|
handleNotification(event.notificationId,`Vous avez été assigné à la tâche ${event.task.name} de l'événement ${event.event.name}.`);
|
||||||
})
|
})
|
||||||
.listen('.volunteer.unassigned.to.task', (event) => {
|
.listen('.volunteer.unassigned.to.task', (event) => {
|
||||||
handleNotification(`Vous avez été désassigné de la tâche ${event.task.name} de l'événement ${event.event.name}.`);
|
handleNotification(event.notificationId,`Vous avez été désassigné de la tâche ${event.task.name} de l'événement ${event.event.name}.`);
|
||||||
})
|
})
|
||||||
.listen('.volunteer.role.updated', (event) => {
|
.listen('.volunteer.role.updated', (event) => {
|
||||||
handleNotification(`Votre rôle a changé pour : ${event.role} `);
|
handleNotification(`Votre rôle a changé pour : ${event.role} `);
|
||||||
})
|
})
|
||||||
.listen('.task.date.updated', (event) => {
|
.listen('.task.date.updated', (event) => {
|
||||||
handleNotification(`La date de la tâche ${event.task.name} de l'événement ${event.event.name} à été mis à jour. Cette tâche aura maintenant lieu du ${event.start} au ${event.end}.`);
|
handleNotification(event.notificationId,`La date de la tâche ${event.task.name} de l'événement ${event.event.name} à été mis à jour. Cette tâche aura maintenant lieu du ${event.start} au ${event.end}.`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user