imsg-grep 0.1.2-darwin → 0.1.4-darwin

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cef5eafcce4406fd5d337becf68f32ac9a2f40a20895231792054220106e763
4
- data.tar.gz: 6a6a717d0c20fa8f5cf17ac7c61e9967bee3ee3880b1ac5846df621807599e94
3
+ metadata.gz: 0e9003c398da31639dbfde03aaec593b2f165940563851b5e6941d4a55a3ac7d
4
+ data.tar.gz: 98155da94f986fc1a3455f368d40c2b418d2e077980d9fbb536d375f1e3fffd4
5
5
  SHA512:
6
- metadata.gz: 7dc965a315ffae770ed3a8e15d4c58db6fa6480ba33c3219a377beef5c216f7cb963c9dc2e9ee8cf4dda0c76e551a57f0032bd9e25ca6ee656dd192d0bdc3a3e
7
- data.tar.gz: 4ffcf9b52f30390cf20f5da84ee5bddbaa2f4002eafa6c869cc7704dbddf783dc9362918e13c5120ae2a8b42a30461d22e02ee3fc88cfa25dec625780611856c
6
+ metadata.gz: 4992137950786e7a8e3040f50378a8d8b285d6894913ae7aa8ec6c7b539048bf11be519cd5db8f3cd10fd888438a2707d1ba2b77f2de5ed387c788b317c76a4e
7
+ data.tar.gz: 319ef0da83aa8c21b8bc71f934744604def1b6b8e28b2ff361cdb34710e4d8a04787f9cc14a63fa1270fda60bc0f30adfbc96fef2fe2e489da5b8b3f0c64e5cf
data/README.md CHANGED
@@ -17,7 +17,11 @@ Search iMessage history with regex patterns, date ranges, and participant filter
17
17
 
18
18
  macOS, ruby 3.4+, SQLite.
19
19
 
20
- iTerm or Ghostty (or other kitty) for image support.
20
+ Full Disk Access must be enabled for terminal.
21
+
22
+ iTerm or Ghostty (or other kitty) for image support.
23
+
24
+ swiftc for development. (run `rake build:lib`)
21
25
 
22
26
  ## Installing
23
27
 
data/bin/imsg-grep CHANGED
@@ -371,6 +371,16 @@ begin
371
371
  sorted_singles = keyed_singles.sort_by{|k,| filter_order.index(k) || Float::INFINITY }.map(&:last)
372
372
  groups = sorted_singles + grouped # put it back together
373
373
 
374
+ begin
375
+ Messages.init_fs
376
+ rescue Errno::EPERM, Errno::EACCES
377
+ $stderr.print "You must grant #{ENV['TERM_PROGRAM']} Full Disk Access so #{PROG} can access the chat database. Open System Settings pane? [y/N] "
378
+ $stdin.gets.to_s.strip.downcase == "y" and system 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"'
379
+ exit 1
380
+ rescue => e
381
+ err! e.message
382
+ exit 1
383
+ end
374
384
  Messages.init
375
385
 
376
386
  @file_filters = []
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.4
@@ -1,6 +1,5 @@
1
1
  require "io/console"
2
2
  require "concurrent-ruby"
3
- require_relative "img2png"
4
3
 
5
4
  module Imaginator
6
5
  begin
@@ -10,29 +10,36 @@ require_relative 'apple/attr_str'
10
10
  module Messages
11
11
  APPLE_EPOCH = 978307200
12
12
 
13
- ADDY_DB = Dir[File.expand_path("~/Library/Application Support/AddressBook/Sources/*/AddressBook-*.abcddb")][0]
14
- IMSG_DB = File.expand_path("~/Library/Messages/chat.db")
15
- CACHE_DB = File.expand_path("~/.cache/imsg-grep/cache.db")
16
-
17
- def self.reset_cache = FileUtils.rm_f(CACHE_DB)
13
+ def self.reset_cache = FileUtils.rm_f(@cache_db)
18
14
  def self.db = @db
19
15
 
20
- def self.init
21
- ################################################################################
22
- ### DB Setup ###################################################################
23
- ################################################################################
24
- FileUtils.mkdir_p File.dirname(CACHE_DB)
25
- FileUtils.touch(CACHE_DB)
16
+ def self.init_fs
17
+ return if @addy_db # already ran
18
+ @addy_db = Dir[File.expand_path("~/Library/Application Support/AddressBook/Sources/*/AddressBook-*.abcddb")][0]
19
+ @imsg_db = File.expand_path("~/Library/Messages/chat.db")
20
+ @cache_db = File.expand_path("~/.cache/imsg-grep/cache.db")
21
+
22
+ raise "Contacts database not found" unless @addy_db
23
+
24
+ FileUtils.mkdir_p File.dirname(@cache_db)
25
+ FileUtils.touch(@cache_db)
26
26
 
27
- [ADDY_DB, IMSG_DB, CACHE_DB].each do |db|
27
+ [@addy_db, @imsg_db, @cache_db].each do |db|
28
28
  raise "Database not found: #{db}" unless File.exist?(db)
29
29
  raise "Database not readable: #{db}" unless File.readable?(db)
30
30
  end
31
+ end
32
+
33
+ def self.init
34
+ ################################################################################
35
+ ### DB Setup ###################################################################
36
+ ################################################################################
31
37
 
38
+ init_fs
32
39
  @db = SQLite3::Database.new(":memory:")
33
- @db.execute "ATTACH DATABASE '#{ADDY_DB}' AS _addy"
34
- @db.execute "ATTACH DATABASE '#{IMSG_DB}' AS _imsg"
35
- @db.execute "ATTACH DATABASE '#{CACHE_DB}' AS _cache"
40
+ @db.execute "ATTACH DATABASE '#{@addy_db}' AS _addy"
41
+ @db.execute "ATTACH DATABASE '#{@imsg_db}' AS _imsg"
42
+ @db.execute "ATTACH DATABASE '#{@cache_db}' AS _cache"
36
43
 
37
44
  def @db.select_hashes(sql) = prepare(sql).execute.enum_for(:each_hash).map{ it.transform_keys(&:to_sym) }
38
45
  def @db.ƒ(f, &) = define_function_with_flags(f.to_s, SQLite3::Constants::TextRep::UTF8 | SQLite3::Constants::TextRep::DETERMINISTIC, &)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imsg-grep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: darwin
6
6
  authors:
7
7
  - Caio Chassot