calls.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Derive filenames based on domain + file path
  2. const fileHash = require('../../../util/backup_filehash')
  3. const apple_timestamp = require('../../../util/apple_timestamp')
  4. const database = fileHash('com.viber/database/Contacts.data', 'AppDomainGroup-group.viber.share.container')
  5. module.exports = {
  6. version: 4,
  7. name: 'viber_calls',
  8. description: `List Viber calls`,
  9. requiresBackup: true,
  10. // Run on a v3 lib / backup object.
  11. run (lib, { backup }) {
  12. return viberCallsReport(backup)
  13. },
  14. // Fields for apps report
  15. output: {
  16. 'PK': el => el.Z_PK,
  17. 'Date': el => el.ZDATE_STRING,
  18. 'Name': el => el.ZMAINNAME + ' ' + el.ZSUFFIXNAME,
  19. 'Phone': el => el.ZPHONENUMBER,
  20. 'Call Type': el => el.ZCALLTYPE
  21. }
  22. }
  23. const viberCallsReport = (backup) => {
  24. return new Promise((resolve, reject) => {
  25. backup.openDatabase(database).then(database => {
  26. const query = `
  27. SELECT *, ${apple_timestamp.parse('ZRECENTSLINE.ZDATE')} AS ZDATE_STRING FROM ZRECENTSLINE
  28. INNER JOIN ZABCONTACT
  29. ON ZABCONTACT.Z_PK = ZRECENTSLINE.ZCONTACT
  30. ORDER BY ZABCONTACT.Z_PK;
  31. `
  32. database.all(query, (err, rows) => {
  33. if (err) resolve(err)
  34. resolve(rows);
  35. })
  36. }).catch(reject)
  37. })
  38. }