diff --git a/chronicle-imessage.gemspec b/chronicle-imessage.gemspec index 1b08242..8309b85 100644 --- a/chronicle-imessage.gemspec +++ b/chronicle-imessage.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "chronicle-etl", "~> 0.4.2" + spec.add_dependency "chronicle-etl", "~> 0.4.4" spec.add_dependency "sqlite3", "~> 1.4" spec.add_dependency "phonelib", "~> 0.6" diff --git a/lib/chronicle/imessage/imessage_extractor.rb b/lib/chronicle/imessage/imessage_extractor.rb index e50e3cf..56b9cf7 100644 --- a/lib/chronicle/imessage/imessage_extractor.rb +++ b/lib/chronicle/imessage/imessage_extractor.rb @@ -27,8 +27,8 @@ def extract meta = {} meta[:participants] = @chats[message['chat_id']] meta[:attachments] = @attachments[message['message_id']] if @attachments - meta[:my_phone_contact] = @my_phone_contact - meta[:my_icloud_account] = @my_icloud_account + meta[:my_phone_contact] = @my_phone_contact if @my_phone_contact.values.all? + meta[:my_icloud_account] = @my_icloud_account if @my_icloud_account.values.all? yield Chronicle::ETL::Extraction.new(data: message, meta: meta) end @@ -58,16 +58,16 @@ def prepare_data def load_my_phone_contact(local_contacts) { - phone_number: @config.my_phone_number || local_contacts.my_phone_contact.fetch(:phone_number), - name: @config.my_name || local_contacts.my_phone_contact.fetch(:full_name) + phone_number: @config.my_phone_number || local_contacts.my_phone_contact&.fetch(:phone_number), + name: @config.my_name || local_contacts.my_phone_contact&.fetch(:full_name) } end def load_my_icloud_account(local_contacts) { - id: @config.icloud_account_id || local_contacts.my_icloud_account.fetch(:AccountID), - dsid: @config.icloud_account_dsid || local_contacts.my_icloud_account.fetch(:AccountDSID), - display_name: @config.icloud_account_display_name || @config.my_name || local_contacts.my_icloud_account.fetch(:DisplayName) + id: nil, + dsid: @config.icloud_account_dsid || local_contacts.my_icloud_account&.fetch(:AccountDSID), + display_name: @config.icloud_account_display_name || @config.my_name || local_contacts.my_icloud_account&.fetch(:DisplayName) } end diff --git a/lib/chronicle/imessage/imessage_transformer.rb b/lib/chronicle/imessage/imessage_transformer.rb index 65c0a92..69c7f2a 100644 --- a/lib/chronicle/imessage/imessage_transformer.rb +++ b/lib/chronicle/imessage/imessage_transformer.rb @@ -102,7 +102,7 @@ def build_attachment(attachment) end def build_identity identity - raise ::Chronicle::ETL::UntransformableRecordError.new("Could not build identity", transformation: self) unless identity + raise(Chronicle::ETL::UntransformableRecordError, "Could not build record due to missing identity data") unless identity record = ::Chronicle::ETL::Models::Entity.new({ represents: 'identity', @@ -125,7 +125,7 @@ def build_identity_mine def build_identity_mine_icloud icloud_account = @extraction.meta[:my_icloud_account] - raise(UntransformableRecordError, "Missing iCloud account information") unless icloud_account + raise(Chronicle::ETL::UntransformableRecordError, "Could not build record due to missing iCloud details. Please provide them through the extractor settings.") unless icloud_account record = ::Chronicle::ETL::Models::Entity.new({ represent: 'identity', @@ -140,7 +140,7 @@ def build_identity_mine_icloud def build_identity_mine_phone phone_account = @extraction.meta[:my_phone_contact] - raise(UntransformableRecordError, "Missing own phone contact information") unless phone_account + raise(Chronicle::ETL::UntransformableRecordError, "Could not build record due to missing phone details. Please provide them through the extractor settings.") unless phone_account record = ::Chronicle::ETL::Models::Entity.new({ represent: 'identity', diff --git a/lib/chronicle/imessage/local_contacts.rb b/lib/chronicle/imessage/local_contacts.rb index 7219c86..fcb57b7 100644 --- a/lib/chronicle/imessage/local_contacts.rb +++ b/lib/chronicle/imessage/local_contacts.rb @@ -31,6 +31,8 @@ def my_icloud_account @my_icloud_account ||= load_my_icloud_account end + private + # The synced address book doesn't have a stable folder location so we # have to search for it def find_local_icloud_address_book