conversations_full.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. module.exports.name = 'conversations_full'
  2. module.exports.description = 'List all SMS and iMessage conversations and their messages (dump only)'
  3. // Specify this reporter requires a backup.
  4. // The second parameter to func() is now a backup instead of the path to one.
  5. module.exports.requiresBackup = true
  6. // Specify this reporter supports the promises API for allowing chaining of reports.
  7. module.exports.usesPromises = true
  8. module.exports.func = async function (program, backup, resolve, reject) {
  9. // if (program.dump) {
  10. // return new Promise(async (resolve, reject) => {
  11. let conversations = await backup.getConversations()
  12. let conversations_full = []
  13. for (let el of conversations) {
  14. let messages = await backup.getMessages(el.ROWID, true)
  15. for (let message of messages) {
  16. message.conversation = el
  17. message.attachments = await backup.getMessageAttachments(message.ROWID)
  18. }
  19. conversations_full.push(...messages)
  20. }
  21. // Use the configured formatter to print the rows.
  22. const result = program.formatter.format(conversations_full, {
  23. // Color formatting?
  24. program: program,
  25. // Columns to be displayed in human-readable printouts.
  26. // Some formatters, like raw or CSV, ignore these.
  27. columns: {
  28. 'conversation_id': el => el.conversation.ROWID,
  29. 'date': el => el.conversation.XFORMATTEDDATESTRING || '??',
  30. 'service': el => el.conversation.service_name + '',
  31. 'chat_name': el => el.conversation.chat_identifier + '',
  32. 'display_name': el => el.conversation.display_name + '',
  33. 'message_id': el => el.ROWID + '',
  34. 'content': el => el.text + '',
  35. 'date': el => el.date + '',
  36. 'date_read': el => el.date_read + '',
  37. 'date_delivered': el => el.date_delivered + '',
  38. 'is_delivered': el => el.is_delivered + '',
  39. 'is_finished': el => el.is_finished + '',
  40. 'is_from_me': el => el.is_from_me + '',
  41. 'is_read': el => el.is_read + '',
  42. 'is_sent': el => el.is_sent + '',
  43. 'attachments': el => el.attachments.map((at) => at.filename)
  44. }
  45. })
  46. resolve(result)
  47. }