messages.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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 = 'messages'
  6. module.exports.description = 'List all SMS and iMessage messages in a conversation'
  7. module.exports.requiresBackup = true
  8. module.exports.func = function (program, base) {
  9. if (!program.id) {
  10. console.log('use -i or --id <id> to specify conversation ID.')
  11. process.exit(1)
  12. }
  13. // Grab the backup
  14. var backup = iPhoneBackup.fromID(program.backup, base)
  15. backup.getMessages(program.id)
  16. .then((items) => {
  17. console.log(items.length)
  18. program.formatter.format(items, {
  19. color: program.color,
  20. columns: {
  21. 'ID' : el => el.ROWID,
  22. 'Date': el => el.XFORMATTEDDATESTRING,
  23. 'Sender': el => el.x_sender,
  24. 'Text': el => (el.text || '').trim()
  25. }
  26. })
  27. })
  28. .catch((e) => {
  29. console.log('[!] Encountered an Error:', e)
  30. })
  31. }