Media Sync & Deep Sync
Purpose
Media sync downloads photos, videos, documents, and audio from WhatsApp conversations into organized local folders. Deep sync extends this by using the headless browser to load older message history that isn’t in the recent cache.
File Organization
Each contact’s media folder has subfolders:
| Subfolder | Contents |
|---|---|
photos/ |
JPEG, PNG, WebP images |
videos/ |
MP4, 3GP videos |
docs/ |
PDF, DOCX, XLSX, etc. |
audio/ |
OGG voice notes, MP3 |
thumbs/ |
200px JPEG thumbnails |
micro/ |
80px JPEG micro-thumbnails |
links.json |
Extracted URLs with context |
transcript.txt |
Media event log |
Deduplication
- On startup:
mergeDuplicateFolders()consolidates folders for the same contact - By timestamp: Files with matching timestamp prefix are skipped during sync
- By hash:
findDuplicatesByHash()scans all folders for identical MD5 hashes - Canonical folder:
media_foldercolumn in contacts table prevents duplicate creation
Status
Complete and deployed. Both sync modes working with CRM panel refresh.