accounts.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.accounts',
  7. description: `Show Skype accounts`,
  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. 'Skype Name': el => el.skypename
  16. }
  17. }
  18. const skypeAccountsReport = (backup) => {
  19. return new Promise((resolve, reject) => {
  20. backup.getManifest()
  21. .then((items) => {
  22. let filename = 'main.db'
  23. let fileitem = items.find((file) => {
  24. if (file && file.relativePath) {
  25. return ~file.relativePath.indexOf(filename) && file.domain === domain
  26. }
  27. return false
  28. })
  29. if (fileitem) {
  30. let filepath = fileitem.relativePath
  31. let file = fileHash(filepath, domain)
  32. backup.openDatabase(file).then(database => {
  33. database.all(`SELECT * FROM Accounts `, (err, rows) => {
  34. if (err) resolve(err)
  35. resolve(rows);
  36. })
  37. }).catch(reject)
  38. } else reject("Cannot find main.db"); // Return an empty array to the formatter, since no main.db file can be found in the manifest
  39. });
  40. })
  41. }