conversations.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. const stripAnsi = require('strip-ansi')
  2. const chalk = require('chalk')
  3. const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
  4. const normalizeCols = require('../util/normalize.js')
  5. module.exports.name = 'conversations'
  6. module.exports.description = 'List all SMS and iMessage conversations'
  7. // Specify this reporter requires a backup.
  8. // The second parameter to func() is now a backup instead of the path to one.
  9. module.exports.requiresBackup = true
  10. // Specify this reporter supports the promises API for allowing chaining of reports.
  11. module.exports.usesPromises = true
  12. module.exports.func = function (program, backup, resolve, reject) {
  13. backup.getConversations()
  14. .then((items) => {
  15. var result = program.formatter.format(items, {
  16. program: program,
  17. columns: {
  18. 'ID': el => el.ROWID,
  19. 'Date': el => el.XFORMATTEDDATESTRING || '??',
  20. 'Service': el => el.service_name + '',
  21. 'Chat Name': el => el.chat_identifier + '',
  22. 'Display Name': el => el.display_name + '',
  23. }
  24. })
  25. resolve(result)
  26. })
  27. .catch(reject)
  28. }