Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

Commit b9c26e3

Browse files
authored
Adds phone number metadata before insert (#656)
1 parent c528c06 commit b9c26e3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

apps/platform/src/providers/text/TextJob.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { updateSendState } from '../../campaigns/CampaignService'
55
import { failSend, finalizeSend, loadSendJob, messageLock, prepareSend } from '../MessageTriggerService'
66
import { loadTextChannel } from '.'
77
import App from '../../app'
8-
import { UnsubscribeTextError } from './TextError'
8+
import { UndeliverableTextError, UnsubscribeTextError } from './TextError'
99
import { releaseLock } from '../../core/Lock'
1010

1111
export default class TextJob extends Job {
@@ -45,7 +45,7 @@ export default class TextJob extends Job {
4545
const result = await channel.send(template, data)
4646
await finalizeSend(data, result)
4747
} catch (error: any) {
48-
await failSend(data, error, (error: any) => !(error instanceof UnsubscribeTextError))
48+
await failSend(data, error, (error: any) => !(error instanceof UnsubscribeTextError || error instanceof UndeliverableTextError))
4949
} finally {
5050
await releaseLock(messageLock(campaign, user))
5151
}

apps/platform/src/users/User.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ export class User extends Model {
8686
return this.data.last_name ?? this.data.lastName ?? this.data.surname
8787
}
8888

89+
static formatJson(json: Record<string, any>): Record<string, unknown> {
90+
if (json.phone) {
91+
const parsedNumber = parsePhoneNumber(json.phone)
92+
if (parsedNumber) {
93+
json.data = {
94+
...json.data,
95+
phone_country: parsedNumber.country,
96+
phone_is_valid: parsedNumber.isValid(),
97+
}
98+
}
99+
}
100+
return super.formatJson(json)
101+
}
102+
89103
toJSON() {
90104
const json = super.toJSON()
91105

0 commit comments

Comments
 (0)