Browse Source
Merge pull request #82 from vernu/fix-cases
ensure status is saved in lowercases
pull/83/head
Israel Abebe
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
9 additions and
9 deletions
-
api/src/gateway/gateway.service.ts
-
api/src/gateway/schemas/sms-batch.schema.ts
-
api/src/gateway/schemas/sms.schema.ts
|
|
|
@ -728,19 +728,19 @@ export class GatewayService { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// Normalize status to uppercase for comparison
|
|
|
|
const normalizedStatus = dto.status.toUpperCase(); |
|
|
|
// Normalize status to lowercase for comparison
|
|
|
|
const normalizedStatus = dto.status.toLowerCase(); |
|
|
|
|
|
|
|
const updateData: any = { |
|
|
|
status: normalizedStatus, // Store normalized status
|
|
|
|
}; |
|
|
|
|
|
|
|
// Update timestamps based on status
|
|
|
|
if (normalizedStatus === 'SENT' && dto.sentAtInMillis) { |
|
|
|
if (normalizedStatus === 'sent' && dto.sentAtInMillis) { |
|
|
|
updateData.sentAt = new Date(dto.sentAtInMillis); |
|
|
|
} else if (normalizedStatus === 'DELIVERED' && dto.deliveredAtInMillis) { |
|
|
|
} else if (normalizedStatus === 'delivered' && dto.deliveredAtInMillis) { |
|
|
|
updateData.deliveredAt = new Date(dto.deliveredAtInMillis); |
|
|
|
} else if (normalizedStatus === 'FAILED' && dto.failedAtInMillis) { |
|
|
|
} else if (normalizedStatus === 'failed' && dto.failedAtInMillis) { |
|
|
|
updateData.failedAt = new Date(dto.failedAtInMillis); |
|
|
|
updateData.errorCode = dto.errorCode; |
|
|
|
updateData.errorMessage = dto.errorMessage || 'Unknown error'; |
|
|
|
|
|
|
|
@ -32,8 +32,8 @@ export class SMSBatch { |
|
|
|
@Prop({ type: Number, default: 0 }) |
|
|
|
failureCount: number |
|
|
|
|
|
|
|
@Prop({ type: String, default: 'PENDING' }) |
|
|
|
status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'PARTIAL_SUCCESS' | 'FAILED' |
|
|
|
@Prop({ type: String, default: 'pending' }) |
|
|
|
status: 'pending' | 'processing' | 'completed' | 'partial_success' | 'failed' |
|
|
|
|
|
|
|
@Prop({ type: String }) |
|
|
|
error: string |
|
|
|
|
|
|
|
@ -59,8 +59,8 @@ export class SMS { |
|
|
|
// @Prop({ type: String })
|
|
|
|
// failureReason: string
|
|
|
|
|
|
|
|
@Prop({ type: String, default: 'PENDING' }) |
|
|
|
status: 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED' |
|
|
|
@Prop({ type: String, default: 'pending' }) |
|
|
|
status: 'pending' | 'sent' | 'delivered' | 'failed' |
|
|
|
|
|
|
|
// misc metadata for debugging
|
|
|
|
@Prop({ type: Object }) |
|
|
|
|