conversations_full.js 2.1 KB

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