messages.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_messages',
  8. description: `List Viber messages`,
  9. requiresBackup: true,
  10. // Run on a v3 lib / backup object.
  11. run (lib, { backup }) {
  12. return viberMessagesReport(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.ZDISPLAYFULLNAME,
  19. 'Text': el => el.ZTEXT,
  20. 'State': el => el.ZSTATE
  21. }
  22. }
  23. const viberMessagesReport = (backup) => {
  24. return new Promise((resolve, reject) => {
  25. console.log(database)
  26. backup.openDatabase(database).then(database => {
  27. const query = `
  28. SELECT *, ${apple_timestamp.parse('ZVIBERMESSAGE.ZDATE')} AS ZDATE_STRING FROM ZVIBERMESSAGE
  29. INNER JOIN ZCONVERSATION
  30. ON ZCONVERSATION.Z_PK = ZVIBERMESSAGE.ZCONVERSATION
  31. INNER JOIN ZMEMBER
  32. ON ZCONVERSATION.ZINTERLOCUTOR = ZMEMBER.Z_PK
  33. ORDER BY ZVIBERMESSAGE.Z_PK DESC;
  34. `
  35. database.all(query, async function (err, rows) {
  36. if (err) reject(err)
  37. resolve(rows)
  38. })
  39. }).catch(reject)
  40. })
  41. }