contacts.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Derive filenames based on domain + file path
  2. const fileHash = require('../../../util/backup_filehash')
  3. const database = fileHash('com.viber/database/Contacts.data', 'AppDomainGroup-group.viber.share.container')
  4. module.exports = {
  5. version: 4,
  6. name: 'viber_contacts',
  7. description: `List Viber contacts`,
  8. requiresBackup: true,
  9. // Run on a v3 lib / backup object.
  10. run (lib, { backup }) {
  11. return viberContactsReport(backup)
  12. },
  13. // Fields for apps report
  14. output: {
  15. 'PK': el => el.Z_PK,
  16. 'Name': el => el.ZDISPLAYFULLNAME,
  17. 'Phone': el => el.ZPHONE
  18. }
  19. }
  20. const viberContactsReport = (backup) => {
  21. return new Promise((resolve, reject) => {
  22. backup.openDatabase(database).then(database => {
  23. const query = `
  24. SELECT * FROM ZMEMBER
  25. INNER JOIN ZPHONENUMBER
  26. ON ZPHONENUMBER.ZMEMBER = ZMEMBER.Z_PK
  27. ORDER BY ZMEMBER.Z_PK;
  28. `
  29. database.all(query, async function (err, rows) {
  30. if (err) reject(err)
  31. resolve(rows)
  32. })
  33. }).catch(reject)
  34. })
  35. }