852d2cf304
* @remindme bot support support reminders via @remindme bot, just like @delete bot * minor cleanup * minor query cleanup * add db migration * various fixes and updates: * hasNewNotes implementation * actually return notification component in ui * delete reminder and job on item delete * other goodies * refactor to use prisma for deleting existing reminder * * switch to deleteMany to delete existing Reminders upon edit/delete of post to satisfy prisma * update wording in form toast for remindme bot usage * update wording in the push notification sent * transactional reminder inserts and expirein * set expirein on @delete too --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
19 lines
522 B
JavaScript
19 lines
522 B
JavaScript
import { notifyReminder } from '@/lib/webPush'
|
|
export async function remindUser ({ data: { itemId, userId }, models }) {
|
|
let item
|
|
try {
|
|
item = await models.item.findUnique({ where: { id: itemId } })
|
|
} catch (err) {
|
|
console.error('failed to lookup item by id', err)
|
|
}
|
|
try {
|
|
if (item) {
|
|
await notifyReminder({ userId, item, itemId })
|
|
} else {
|
|
await notifyReminder({ userId, itemId })
|
|
}
|
|
} catch (err) {
|
|
console.error('failed to send push notification for reminder', err)
|
|
}
|
|
}
|