fix(album): improve validation consistency and result clarity
Addresses additional PR review suggestions:
1. **Consistent media type validation**
- Changed from `'image' in m` to `hasNonNullishProperty(m, 'image')`
- Aligns with validation in generateWAMessageContent
- Prevents counting items with undefined image/video properties
2. **Explicit interrupted send indication**
- Added `attemptedItems: number` - how many items were actually tried
- Added `stoppedEarly: boolean` - true if interrupted by continueOnFailure=false
- Updated `success` to be false if stoppedEarly (even if no failures in attempted items)
- Helps automated integrations understand partial sends
Example result when interrupted:
```json
{
"totalItems": 5,
"attemptedItems": 3,
"successCount": 2,
"failedCount": 1,
"stoppedEarly": true,
"success": false
}
```
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -363,8 +363,10 @@ export type AlbumSendResult = {
|
||||
albumKey: WAMessageKey
|
||||
/** Results for each media item */
|
||||
results: AlbumMediaResult[]
|
||||
/** Total number of items */
|
||||
/** Total number of items in the album */
|
||||
totalItems: number
|
||||
/** Number of items that were actually attempted (may be < totalItems if stoppedEarly) */
|
||||
attemptedItems: number
|
||||
/** Number of successfully sent items */
|
||||
successCount: number
|
||||
/** Number of failed items */
|
||||
@@ -373,6 +375,8 @@ export type AlbumSendResult = {
|
||||
failedIndices: number[]
|
||||
/** Overall success (all items sent) */
|
||||
success: boolean
|
||||
/** Whether the send was interrupted early due to continueOnFailure=false */
|
||||
stoppedEarly: boolean
|
||||
/** Total time taken in ms */
|
||||
totalLatencyMs: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user