fix insert messages queue, insert messages with an id and no unnecessary field

This commit is contained in:
m5r 2021-08-28 14:16:14 +08:00
parent 1a5fdf5a0e
commit 13b8dd895a

View File

@ -22,7 +22,8 @@ const insertMessagesQueue = Queue<Payload>(
} }
const sms = messages const sms = messages
.map<Omit<Message, "id">>((message) => ({ .map<Message>((message) => ({
id: message.sid,
organizationId, organizationId,
phoneNumberId: phoneNumber.id, phoneNumberId: phoneNumber.id,
content: encrypt(message.body, phoneNumber.organization.encryptionKey), content: encrypt(message.body, phoneNumber.organization.encryptionKey),
@ -30,7 +31,6 @@ const insertMessagesQueue = Queue<Payload>(
to: message.to, to: message.to,
status: translateStatus(message.status), status: translateStatus(message.status),
direction: translateDirection(message.direction), direction: translateDirection(message.direction),
twilioSid: message.sid,
sentAt: new Date(message.dateCreated), sentAt: new Date(message.dateCreated),
})) }))
.sort((a, b) => a.sentAt.getTime() - b.sentAt.getTime()); .sort((a, b) => a.sentAt.getTime() - b.sentAt.getTime());