calls.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.name = 'viber_calls'
  5. module.exports.description = 'List Viber calls'
  6. // Specify this reporter requires a backup.
  7. // The second parameter to func() is now a backup instead of the path to one.
  8. module.exports.requiresBackup = true
  9. // Specify this reporter supports the promises API for allowing chaining of reports.
  10. module.exports.usesPromises = true
  11. module.exports.func = function (program, backup, resolve, reject) {
  12. viberCallsReport(backup)
  13. .then((items) => {
  14. var result = program.formatter.format(items, {
  15. program: program,
  16. columns: {
  17. 'PK': el => el.Z_PK,
  18. 'Date': el => (new Date((el.ZDATE + 978307200) * 1000).toDateString()) + ' ' + (new Date((el.ZDATE + 978307200) * 1000).toTimeString()),
  19. 'Name': el => el.ZMAINNAME + ' ' + el.ZSUFFIXNAME,
  20. 'Phone': el => el.ZPHONENUMBER,
  21. 'Call Type': el => el.ZCALLTYPE
  22. }
  23. })
  24. resolve(result)
  25. })
  26. .catch(reject)
  27. }
  28. const viberCallsReport = (backup) => {
  29. return new Promise((resolve, reject) => {
  30. var vibercallsdb = backup.getDatabase(database)
  31. try {
  32. const query = `
  33. SELECT * FROM ZRECENTSLINE
  34. INNER JOIN ZABCONTACT
  35. ON ZABCONTACT.Z_PK = ZRECENTSLINE.ZCONTACT
  36. ORDER BY ZABCONTACT.Z_PK;
  37. `
  38. vibercallsdb.all(query, async function (err, rows) {
  39. if (err) reject(err)
  40. resolve(rows)
  41. })
  42. } catch (e) {
  43. reject(e)
  44. }
  45. })
  46. }