calls.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Derive filenames based on domain + file path
  2. const fileHash = require('../../../util/backup_filehash')
  3. const domain = 'AppDomain-com.skype.skype'
  4. module.exports = {
  5. version: 4,
  6. name: 'skype_calls',
  7. description: `Show Skype calls`,
  8. requiresBackup: true,
  9. // Run on a v3 lib / backup object.
  10. run (lib, { backup }) {
  11. return skypeAccountsReport(backup)
  12. },
  13. // Fields for apps report
  14. output: {
  15. 'Begin Timestamp': el => (new Date((el.begin_timestamp) * 1000).toDateString()) + ' ' + (new Date((el.begin_timestamp) * 1000).toTimeString()),
  16. 'Host Identity': el => el.host_identity,
  17. 'Duration': el => el.duration ? el.duration : 'N/A',
  18. 'Is Incoming': el => el.is_incoming === 1 ? 'Yes' : 'No',
  19. 'Caller': el => el.caller_mri_identity
  20. }
  21. }
  22. const skypeAccountsReport = (backup, file) => {
  23. return new Promise((resolve, reject) => {
  24. backup.getManifest()
  25. .then((items) => {
  26. let filename = 'main.db'
  27. let fileitem = items.find((file) => {
  28. if (file && file.filename) {
  29. return ~file.filename.indexOf(filename) && file.domain === domain
  30. }
  31. return false
  32. })
  33. if (fileitem) {
  34. let filepath = fileitem.filename
  35. let file = fileHash(filepath, domain)
  36. backup.openDatabase(file).then(database => {
  37. database.all(` SELECT * FROM Calls `,
  38. (err, rows) => {
  39. if (err) return reject(err)
  40. resolve(rows)
  41. })
  42. }).catch(reject)
  43. } else reject("Cannot find main.db") // Return an empty array to the formatter, since no main.db file can be found in the manifest
  44. })
  45. })
  46. }