chronicle-imessage 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcaf59959a65537025a3ec616fc7edfed08aebcd6a9aca59569e8102553ada41
4
- data.tar.gz: c78cc1e83b6fef4d41b710944484c935409e7833a30c5269792d59872579f4f4
3
+ metadata.gz: 8e5b5b2c2b15c1a26c52871284d921960d825d24303b1d872d4d25c8d8782229
4
+ data.tar.gz: 5597cc2177ae72c86c2cc9a96b75f29dc5c07b0fe2053304e0e880b4d93919c5
5
5
  SHA512:
6
- metadata.gz: a71a3c50cad2861c304b687c291fdcab1ef418c20a384f20c0a71ea2563a75ffec6937630288723d91620c5148224cf13ff143250b07e44bbd62dd893358421f
7
- data.tar.gz: 6b4948f26b2e9d4aced7326c9f6f7bb5e031b6447c1885be8b85912209fc440a03047af01833e536fd8f31c9cf9205885fa0ea3edd5f69cf1da2f930065b2f0d
6
+ metadata.gz: bbae018587ad66e2a3ed05a5d7e878058cfac6c747fc283fbc54995f07bbbfc6aacaeddfaa16ae6ceb9d9547f0b4c20d692ce6a4fc059d542ca4621dec0b819c
7
+ data.tar.gz: ffc6247be044ebe0cfc58f545b10e7d622ebff3c82dc230c8f412abb61f971bce981bb6edcb58fbbe507a7cb8d639e8b19063ec6b66c2e332584e2c416357ab6
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ Gemfile.lock
data/README.md CHANGED
@@ -15,5 +15,5 @@ IMessage importer for [chronicle-etl](https://github.com/chronicle-app/chronicle
15
15
  gem install chronicle-etl
16
16
  chronicle-etl connectors:install imessage
17
17
 
18
- chronicle-etl --extractor imessage --extractor-opts load_since:"2022-02-07" --transformer imessage --loader table
18
+ chronicle-etl --extractor imessage --since:"2022-02-07" --transformer imessage --loader table
19
19
  ```
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
37
 
38
- spec.add_dependency "chronicle-etl", "~> 0.3"
38
+ spec.add_dependency "chronicle-etl", "~> 0.4"
39
39
  spec.add_dependency "sqlite3", "~> 1.4.2"
40
40
  spec.add_dependency "phonelib", "~> 0.6.54"
41
41
 
@@ -10,14 +10,11 @@ module Chronicle
10
10
  r.description = 'a local imessage database'
11
11
  end
12
12
 
13
- DEFAULT_OPTIONS = {
14
- db: File.join(Dir.home, 'Library', 'Messages', 'chat.db'),
15
- load_attachments: false,
16
- load_since: Time.now - 5000000
17
- }.freeze
18
-
19
- def initialize(options = {})
20
- super(DEFAULT_OPTIONS.merge(options))
13
+ setting :db, default: File.join(Dir.home, 'Library', 'Messages', 'chat.db'), required: true
14
+ setting :load_attachments, default: false
15
+ setting :only_attachments, default: false
16
+
17
+ def prepare
21
18
  prepare_data
22
19
  end
23
20
 
@@ -38,34 +35,40 @@ module Chronicle
38
35
  private
39
36
 
40
37
  def prepare_data
41
- @db = SQLite3::Database.new(@options[:db], results_as_hash: true)
42
- @messages = load_messages(
43
- load_since: @options[:load_since],
44
- load_until: @options[:load_until],
45
- limit: @options[:limit]
46
- )
38
+ @db = SQLite3::Database.new(@config.db, results_as_hash: true)
39
+ @messages = load_messages
47
40
  @contacts = LocalContacts.new.contacts
48
41
  @chats = load_chats
49
42
 
50
- if @options[:load_attachments]
43
+ if @config.load_attachments
51
44
  @attachments = load_attachments(@messages.map{|m| m['message_id']})
52
45
  end
53
46
  end
54
47
 
55
- def load_messages(load_since: nil, load_until: nil, limit: nil)
56
- load_since_ios = unix_to_ios_timestamp(load_since.to_i) * 1000000000 if load_since
57
- load_until_ios = unix_to_ios_timestamp(load_until.to_i) * 1000000000 if load_until
48
+ def load_messages
49
+ conditions = []
50
+
51
+ if @config.until
52
+ load_until_ios = unix_to_ios_timestamp(@config.until.to_i) * 1000000000
53
+ conditions << "date < #{load_until_ios}"
54
+ end
55
+
56
+ if @config.since
57
+ load_since_ios = unix_to_ios_timestamp(@config.since.to_i) * 1000000000
58
+ conditions << "date > #{load_since_ios}"
59
+ end
60
+
61
+ if @config.only_attachments
62
+ conditions << "cache_has_attachments = true"
63
+ end
58
64
 
59
65
  sql = "SELECT * from message as m
60
66
  LEFT OUTER JOIN handle as h ON m.handle_id=h.ROWID
61
67
  INNER JOIN chat_message_join as cm ON m.ROWID = cm.message_id"
62
68
 
63
- conditions = []
64
- conditions << "date < #{load_until_ios}" if load_until
65
- conditions << "date > #{load_since_ios}" if load_since
66
69
  sql += " WHERE #{conditions.join(" AND ")}" if conditions.any?
67
70
  sql += " ORDER BY date DESC"
68
- sql += " LIMIT #{limit}" if limit
71
+ sql += " LIMIT #{@config.limit}" if @config.limit
69
72
 
70
73
  messages = @db.execute(sql)
71
74
  end
@@ -8,13 +8,8 @@ module Chronicle
8
8
  r.description = 'a row from a local imessage database'
9
9
  end
10
10
 
11
- DEFAULT_OPTIONS = {
12
- }.freeze
13
-
14
- def initialize(*args)
15
- super(*args)
16
- @options = @options.reverse_merge(DEFAULT_OPTIONS)
17
- end
11
+ setting :my_phone_slug, required: true
12
+ setting :my_name, required: true
18
13
 
19
14
  def transform
20
15
  @message = @extraction.data
@@ -125,8 +120,8 @@ module Chronicle
125
120
  def build_identity_mine
126
121
  record = ::Chronicle::ETL::Models::Entity.new({
127
122
  represents: 'identity',
128
- slug: @options[:my_phone_slug],
129
- title: @options[:my_name],
123
+ slug: @config.my_phone_slug,
124
+ title: @config.my_name,
130
125
  provider: identity_provider(@message['service']),
131
126
  provider_id: @message['account_guid']
132
127
  })
@@ -1,5 +1,5 @@
1
1
  module Chronicle
2
2
  module Imessage
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -5,7 +5,5 @@ require "chronicle/imessage/local_contacts"
5
5
 
6
6
  module Chronicle
7
7
  module Imessage
8
- class Error < StandardError; end
9
- # Your code goes here...
10
8
  end
11
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronicle-imessage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Louis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronicle-etl
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +90,6 @@ files:
90
90
  - ".gitignore"
91
91
  - CODE_OF_CONDUCT.md
92
92
  - Gemfile
93
- - Gemfile.lock
94
93
  - README.md
95
94
  - Rakefile
96
95
  - bin/console
@@ -123,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
124
  requirements: []
126
- rubygems_version: 3.1.2
125
+ rubygems_version: 3.1.6
127
126
  signing_key:
128
127
  specification_version: 4
129
128
  summary: iMessage importer for Chronicle
data/Gemfile.lock DELETED
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- chronicle-imessage (0.1.0)
5
- chronicle-etl (~> 0.3)
6
- phonelib (~> 0.6.54)
7
- sqlite3 (~> 1.4.2)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- activesupport (7.0.1)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 1.6, < 2)
15
- minitest (>= 5.1)
16
- tzinfo (~> 2.0)
17
- chronic_duration (0.10.6)
18
- numerizer (~> 0.1.1)
19
- chronicle-etl (0.3.0)
20
- activesupport
21
- chronic_duration (~> 0.10.6)
22
- colorize (~> 0.8.1)
23
- marcel (~> 1.0.2)
24
- mini_exiftool (~> 2.10)
25
- nokogiri (~> 1.13)
26
- runcom (~> 6.2)
27
- sequel (~> 5.35)
28
- sqlite3 (~> 1.4)
29
- thor (~> 0.20)
30
- tty-progressbar (~> 0.17)
31
- tty-table (~> 0.11)
32
- colorize (0.8.1)
33
- concurrent-ruby (1.1.9)
34
- i18n (1.9.1)
35
- concurrent-ruby (~> 1.0)
36
- marcel (1.0.2)
37
- mini_exiftool (2.10.2)
38
- mini_portile2 (2.7.1)
39
- minitest (5.15.0)
40
- nokogiri (1.13.1)
41
- mini_portile2 (~> 2.7.0)
42
- racc (~> 1.4)
43
- numerizer (0.1.1)
44
- pastel (0.8.0)
45
- tty-color (~> 0.5)
46
- phonelib (0.6.55)
47
- racc (1.6.0)
48
- rake (13.0.6)
49
- refinements (7.18.0)
50
- runcom (6.6.0)
51
- refinements (~> 7.16)
52
- xdg (~> 4.4)
53
- sequel (5.53.0)
54
- sqlite3 (1.4.2)
55
- strings (0.2.1)
56
- strings-ansi (~> 0.2)
57
- unicode-display_width (>= 1.5, < 3.0)
58
- unicode_utils (~> 1.4)
59
- strings-ansi (0.2.0)
60
- thor (0.20.3)
61
- tty-color (0.6.0)
62
- tty-cursor (0.7.1)
63
- tty-progressbar (0.18.2)
64
- strings-ansi (~> 0.2)
65
- tty-cursor (~> 0.7)
66
- tty-screen (~> 0.8)
67
- unicode-display_width (>= 1.6, < 3.0)
68
- tty-screen (0.8.1)
69
- tty-table (0.12.0)
70
- pastel (~> 0.8)
71
- strings (~> 0.2.0)
72
- tty-screen (~> 0.8)
73
- tzinfo (2.0.4)
74
- concurrent-ruby (~> 1.0)
75
- unicode-display_width (2.1.0)
76
- unicode_utils (1.4.0)
77
- xdg (4.5.0)
78
-
79
- PLATFORMS
80
- ruby
81
-
82
- DEPENDENCIES
83
- bundler (~> 2.3)
84
- chronicle-imessage!
85
- rake (~> 13.0.6)
86
-
87
- BUNDLED WITH
88
- 2.3.6