Skip to content

Commit

Permalink
Merge branch 'add-integrations'
Browse files Browse the repository at this point in the history
  • Loading branch information
celuchmarek committed Jun 13, 2024
2 parents 9ee71ad + 52993da commit 29a2abb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def set_key
@key = Base64.strict_decode64(key_b64)
end
rescue => e
raise AvmUnauthorizedError.new("ENCRYPTION_KEY_MALFORMED", "Encryption key Base64 decryption failed.", e.message)
raise AvmUnauthorizedError.new("ENCRYPTION_KEY_MALFORMED", "Encryption key Base64 decryption failed.", "Encryption key must be a base64 string encoding 32 bytes long key, but was: \"#{key_b64}\"")
end

raise AvmUnauthorizedError.new("ENCRYPTION_KEY_MISSING", "Encryption key not provided.", "Encryption key must be provided either in X-Encryption-Key header or as encryptionKey query parameter.") unless @key
Expand Down
14 changes: 10 additions & 4 deletions app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ class Device < ApplicationRecord


def notify(integration, document_guid, document_encryption_key)
encrpyted_message = encrypt_message({
# TODO: encrypt notifications
# encrpyted_message = encrypt_message({
# document_guid: document_guid,
# key: document_encryption_key
# }.to_json,
# integration.pushkey
# )

encrpyted_message = {
document_guid: document_guid,
key: document_encryption_key
}.to_json,
integration.pushkey
)
}.to_json

if ['ios', 'android'].include? platform
ApiEnvironment.fcm_notifier.notify(registration_id, encrpyted_message)
Expand Down

0 comments on commit 29a2abb

Please sign in to comment.