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:
Renato Alcara
2026-01-23 15:33:46 -03:00
parent 54549c4fc1
commit 688739239a
2 changed files with 16 additions and 4 deletions
+5 -1
View File
@@ -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
}