API Endpoints
All endpoints are mounted at /api/library.
CRUD Endpoints
| Method | Route | Description |
|---|---|---|
| GET | /api/library |
List all photos |
| POST | /api/library/upload |
Upload photo (multipart, field: photo) |
| POST | /api/library/save-from-message |
Save from conversation { chatId, messageId } |
| GET | /api/library/:id/file |
Serve full-size photo |
| GET | /api/library/:id/thumb |
Serve thumbnail |
| PATCH | /api/library/:id |
Update caption { caption } |
| DELETE | /api/library/:id |
Delete photo, thumbnail, and DB record |
Send Endpoint
| Method | Route | Description |
|---|---|---|
| POST | /api/library/:id/send |
Send photo to chat { chatId, caption? } |
Purge System
The purge removes a photo from every conversation it was sent to, using “delete for me” (recipients keep their copy).
Dual-Approach Algorithm
- Tracked sends – query
photo_library_sendsfor all messages sent from this library photo - Hash scan fallback – query
media_filestable for matchingmd5_hashto catch photos saved before the library existed or sent manually
For each found message:
- Load the WhatsApp message via
client.getMessageById(msg_wa_id) - Call
msg.delete(false)– “delete for me” - Delete from
messagestable in DB - Delete from
media_filestable if present - Clean up
photo_library_sendsrecords
Status
Complete and deployed.