mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-09-01 12:26:08 +08:00
chore: dont log errors for webhooks we dont care about
This commit is contained in:
parent
b5036b7313
commit
f33fd40de4
2 changed files with 11 additions and 3 deletions
|
@ -91,7 +91,8 @@ export default class TelnyxTextProvider extends TextProvider {
|
|||
}
|
||||
|
||||
// https://www.twilio.com/docs/messaging/guides/webhook-request
|
||||
parseInbound(inbound: any): InboundTextMessage {
|
||||
parseInbound(inbound: any): InboundTextMessage | undefined {
|
||||
if (inbound.data.event_type !== 'message.received') return
|
||||
const payload = inbound.data.payload
|
||||
return {
|
||||
to: payload.to,
|
||||
|
|
|
@ -13,7 +13,7 @@ export type TextProviderName = 'nexmo' | 'plivo' | 'twilio' | 'logger'
|
|||
|
||||
export abstract class TextProvider extends Provider {
|
||||
abstract send(message: TextMessage): Promise<TextResponse>
|
||||
abstract parseInbound(inbound: any): InboundTextMessage
|
||||
abstract parseInbound(inbound: any): InboundTextMessage | undefined
|
||||
|
||||
static get group() { return 'text' as ProviderGroup }
|
||||
|
||||
|
@ -27,7 +27,14 @@ export abstract class TextProvider extends Provider {
|
|||
const channel = await loadTextChannel(provider.id)
|
||||
const project = await getProject(provider.project_id)
|
||||
const message = channel?.provider.parseInbound(ctx.request.body)
|
||||
if (!channel || !project || !message) ctx.throw(404)
|
||||
if (!channel || !project) ctx.throw(404)
|
||||
|
||||
// If undefined message, we can't parse the body but don't want to
|
||||
// keep getting the request
|
||||
if (!message) {
|
||||
ctx.status = 204
|
||||
return
|
||||
}
|
||||
|
||||
// Find the user from the inbound text message
|
||||
const user = await getUserFromPhone(provider.project_id, message.from)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue