Create backend for notifications#2957
Conversation
3b82bf2 to
cae2aaf
Compare
c61379d to
d6e23e1
Compare
d6e23e1 to
6c25f83
Compare
6c25f83 to
04e80f7
Compare
04e80f7 to
d21d581
Compare
d21d581 to
0cd8e9e
Compare
0cd8e9e to
ec90836
Compare
ec90836 to
8907be3
Compare
0e902a4 to
2a3952e
Compare
| async create(handle, notificationData) { | ||
| const { recipientIds, ...data } = notificationData | ||
| const notification = await handle.notification.create({ data }) | ||
| return notification | ||
| }, |
There was a problem hiding this comment.
Critical bug: recipientIds are extracted from notificationData but never used to create the recipient records. When a notification is created, no recipients will be added to the database, making the notification invisible to users.
Fix:
async create(handle, notificationData) {
const { recipientIds, ...data } = notificationData
const notification = await handle.notification.create({ data })
await this.addRecipients(handle, notification.id, recipientIds)
return notification
}| async create(handle, notificationData) { | |
| const { recipientIds, ...data } = notificationData | |
| const notification = await handle.notification.create({ data }) | |
| return notification | |
| }, | |
| async create(handle, notificationData) { | |
| const { recipientIds, ...data } = notificationData | |
| const notification = await handle.notification.create({ data }) | |
| await this.addRecipients(handle, notification.id, recipientIds) | |
| return notification | |
| }, | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
| async update(handle, notificationId, notificationData) { | ||
| const { recipientIds, ...data } = notificationData | ||
| const notification = await handle.notification.update({ | ||
| where: { id: notificationId }, | ||
| data, | ||
| }) | ||
| return notification | ||
| }, |
There was a problem hiding this comment.
Bug: recipientIds are extracted from notificationData but ignored during update. If the API allows passing recipientIds in updates, they will be silently ignored, causing unexpected behavior.
Either remove recipientIds from the destructuring if updates shouldn't modify recipients, or implement the recipient update logic:
async update(handle, notificationId, notificationData) {
const { recipientIds, ...data } = notificationData
const notification = await handle.notification.update({
where: { id: notificationId },
data,
})
if (recipientIds !== undefined) {
await this.addRecipients(handle, notification.id, recipientIds)
}
return notification
}| async update(handle, notificationId, notificationData) { | |
| const { recipientIds, ...data } = notificationData | |
| const notification = await handle.notification.update({ | |
| where: { id: notificationId }, | |
| data, | |
| }) | |
| return notification | |
| }, | |
| async update(handle, notificationId, notificationData) { | |
| const { recipientIds, ...data } = notificationData | |
| const notification = await handle.notification.update({ | |
| where: { id: notificationId }, | |
| data, | |
| }) | |
| if (recipientIds !== undefined) { | |
| await this.addRecipients(handle, notification.id, recipientIds) | |
| } | |
| return notification | |
| }, | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
24a10f4 to
11bd0a5
Compare
11bd0a5 to
b36a014
Compare

No description provided.