messages.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const log = require('../util/log')
  2. module.exports.name = 'messages'
  3. module.exports.description = 'List all SMS and iMessage messages in a conversation'
  4. // Specify this reporter requires a backup.
  5. // The second parameter to func() is now a backup instead of the path to one.
  6. module.exports.requiresBackup = true
  7. // Specify this reporter supports the promises API for allowing chaining of reports.
  8. module.exports.usesPromises = true
  9. // Should this report be skipped in automated reports?
  10. // This is used when the 'all' report type is specified, and all possible reports are generated.
  11. // with this set to true, the report WILL NOT run when report type = 'all'
  12. module.exports.requiresInteractivity = true
  13. module.exports.func = function (program, backup, resolve, reject) {
  14. if (!program.id) {
  15. log.error('use -i or --id <id> to specify conversation ID.')
  16. process.exit(1)
  17. }
  18. backup.getMessages(program.id)
  19. .then((items) => {
  20. var result = program.formatter.format(items, {
  21. program: program,
  22. columns: {
  23. 'ID': el => el.ROWID,
  24. 'Date': el => el.XFORMATTEDDATESTRING,
  25. 'Sender': el => el.x_sender,
  26. 'Text': el => (el.text || '').trim()
  27. }
  28. })
  29. resolve(result)
  30. })
  31. .catch(reject)
  32. }