recents.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const log = require('../../../util/log')
  2. const path = require('path')
  3. const sqlite3 = require('sqlite3')
  4. const fs = require('fs')
  5. // Derive filenames based on domain + file path
  6. const fileHash = require('../../../util/backup_filehash')
  7. const database = fileHash('Documents/user.db', 'AppDomain-com.waze.iphone')
  8. module.exports = {
  9. version: 4,
  10. name: 'waze_recents',
  11. description: `List Waze app recent destinations`,
  12. requiresBackup: true,
  13. // Run on a v3 lib / backup object.
  14. run (lib, { backup }) {
  15. return wazeReport(backup)
  16. },
  17. // Fields for apps report
  18. output: {
  19. 'Id': el => el.id,
  20. 'Name': el => el.name,
  21. 'Created Date': el => (new Date((el.created_time) * 1000).toDateString()) + ' ' + (new Date((el.created_time) * 1000).toTimeString()) ,
  22. 'Access Date': el => (new Date((el.access_time) * 1000).toDateString()) + ' ' + (new Date((el.access_time) * 1000).toTimeString()) ,
  23. 'Latitude': el => el.latitude / 1000000,
  24. 'Longitude': el => el.longitude / 1000000,
  25. 'Street': el => el.street,
  26. 'City': el => el.city,
  27. 'State': el => el.state,
  28. 'Country': el => el.country
  29. }
  30. }
  31. function KeyValue (property, plist) {
  32. this.key = property
  33. this.value = plist[property] ? plist[property] : 'N/A'
  34. }
  35. const wazeReport = (backup) => {
  36. return new Promise((resolve, reject) => {
  37. backup.openDatabase(database).then(database => {
  38. const query = `
  39. select RECENTS.name, RECENTS.created_time, RECENTS.access_time, RECENTS.id, PLACES.latitude, PLACES.longitude, PLACES.street, PLACES.city, PLACES.state, PLACES.country from RECENTS
  40. left join PLACES on RECENTS.place_id = PLACES.id
  41. order by RECENTS.id
  42. `
  43. database.all(query, async function (err, rows) {
  44. if (err) reject(err)
  45. resolve(rows)
  46. })
  47. }).catch(reject)
  48. })
  49. }