| 78 | } |
| 79 | |
| 80 | async function createThread({ |
| 81 | body, |
| 82 | channelId, |
| 83 | linenBotId, |
| 84 | }: { |
| 85 | body: string; |
| 86 | channelId: string; |
| 87 | linenBotId: string; |
| 88 | }) { |
| 89 | await prisma.threads.create({ |
| 90 | data: { |
| 91 | sentAt: new Date().getTime(), |
| 92 | feed: true, |
| 93 | lastReplyAt: new Date().getTime(), |
| 94 | channel: { connect: { id: channelId } }, |
| 95 | messages: { |
| 96 | create: { |
| 97 | body, |
| 98 | sentAt: new Date(), |
| 99 | author: { connect: { id: linenBotId } }, |
| 100 | channel: { connect: { id: channelId } }, |
| 101 | messageFormat: MessageFormat.LINEN, |
| 102 | }, |
| 103 | }, |
| 104 | }, |
| 105 | }); |
| 106 | } |