diff --git a/wai-server/api/messages/message.controller.js b/wai-server/api/messages/message.controller.js index bd10cea..c388889 100644 --- a/wai-server/api/messages/message.controller.js +++ b/wai-server/api/messages/message.controller.js @@ -23,9 +23,12 @@ exports.sendText = async ctx => { } // return wsToSend; try { - const sockMsg = wsToSend.sendTextMessage(to, content); + const sockMsg = await wsToSend.sendTextMessage(to, content); + const { + key: { id }, + } = sockMsg; console.log(JSON.stringify(sockMsg, undefined, 2)); - await upsertOutboundMessage(null, { ...ctx.request.body, id: sockMsg.key || sockMsg.id }); + await upsertOutboundMessage(null, { ...ctx.request.body, id }); return 'Message sent successfully'; // { wsToSend, ret: 'Message sent successfully' }; } catch (error) { console.error('Error sending message:', error);