(payload: Payload, logger: Logger)
| 14 | } |
| 15 | |
| 16 | async function task(payload: Payload, logger: Logger) { |
| 17 | const { threadId, userId } = payload; |
| 18 | logger.info({ 'Setting remind me later for thread': threadId, user: userId }); |
| 19 | const status = await prisma.userThreadStatus.findFirst({ |
| 20 | where: { |
| 21 | threadId, |
| 22 | userId, |
| 23 | reminder: true, |
| 24 | }, |
| 25 | }); |
| 26 | |
| 27 | if (status) { |
| 28 | await prisma.userThreadStatus.deleteMany({ |
| 29 | where: { |
| 30 | threadId, |
| 31 | userId, |
| 32 | reminder: true, |
| 33 | }, |
| 34 | }); |
| 35 | |
| 36 | const thread = await prisma.threads.findUnique({ |
| 37 | where: { id: threadId }, |
| 38 | include: { messages: true }, |
| 39 | }); |
| 40 | if (thread && thread.messages.length > 0) { |
| 41 | const message = thread.messages[0]; |
| 42 | try { |
| 43 | await push({ |
| 44 | channelId: thread.channelId, |
| 45 | threadId, |
| 46 | messageId: message.id, |
| 47 | isThread: true, |
| 48 | isReply: false, |
| 49 | }); |
| 50 | } catch (exception) {} |
| 51 | |
| 52 | logger.info({ 'Push websocket for thread': threadId }); |
| 53 | } |
| 54 | } |
| 55 | } |
no test coverage detected