Created
July 4, 2023 11:19
-
-
Save matheuscouto/2ef51dee795ebf2ade2f5d72504f95d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const verifyIsFirstMessage = async (message) => { | |
const { conversationId, id: messageId } = message; | |
try { | |
const messagesAPI = `${BASE_API_URL}/messages?conversationId=${ | |
message.conversationId | |
}&toTimestamp=${Date.now()}`; | |
const options = { | |
method: 'GET', | |
headers: { | |
accept: 'application/json', | |
apikey: apiKey, | |
}, | |
}; | |
const response = await fetch(messagesAPI, options); | |
const parsedResponse = await response.json(); | |
return parsedResponse.data[0].id === messageId; | |
} catch (e) { | |
log.error( | |
`Error while listing chat messages for conversation id ${conversationId}`, | |
e, | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment