Skip to content

Commit

Permalink
Save message datetimes attribute values with same timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Nov 15, 2024
1 parent 1e746ee commit 5511571
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/fs/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.create_inbox_message(raw_message)
title: raw_message['message_type_name'],
sender_name: FS_SUBJECT_NAME,
recipient_name: raw_message['subject'],
delivered_at: Time.parse(raw_message['created_at']).getlocal,
delivered_at: Time.parse(raw_message['created_at']).in_time_zone,
replyable: false,
collapsed: collapsed?,
outbox: false,
Expand All @@ -78,7 +78,7 @@ def self.create_inbox_message(raw_message)
"fs_submission_status": raw_message['submission_status'],
"fs_message_type": raw_message.dig('message_container', 'message_type'),
"fs_submission_type_id": raw_message['submission_type_id'], # TODO kde pouzit? asi napr. pri vytvarani nazvu suboru pri exporte
"fs_submission_created_at": Time.parse(raw_message['submission_created_at']).getlocal,
"fs_submission_created_at": Time.parse(raw_message['submission_created_at']).in_time_zone,
"fs_period": raw_message['period'],
"fs_dismissal_reason": raw_message['dismissal_reason'],
"fs_other_attributes": raw_message['other_attributes'],
Expand All @@ -93,7 +93,7 @@ def self.create_outbox_message(raw_message, associated_message_draft: nil)
title: raw_message['submission_type_name'],
sender_name: raw_message['subject'],
recipient_name: FS_SUBJECT_NAME,
delivered_at: Time.parse(raw_message['created_at']).getlocal,
delivered_at: Time.parse(raw_message['created_at']).in_time_zone,
replyable: false,
collapsed: collapsed?,
outbox: true,
Expand Down
55 changes: 55 additions & 0 deletions test/models/fs/message_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

require "test_helper"
require "active_support/all"

class Fs::MessageTest < ActiveSupport::TestCase
test "#create_inbox_messages save datetime attributes with the needed timezone" do
raw_messafe = {
"created_at" => "2024-11-11T23:28:11.790+01:00",
"message_id" => "12345689/2024",
"submission_type_id" => "3079",
"submission_type_name" => "Podanie pre FS  (Správa daní) – späťvzatie žiadosti",
"message_type_id" => "DRSR_POPP_v02",
"message_type_name" => "Informácia o podaní",
"sent_message_id" => "12345689/2024",
"seen" => true,
"is_ekr2" => true,
"status" => "Vybavená",
"submission_status" => "Prijaté a potvrdené",
"dic" => "1122222333",
"subject" => "xy",
"submitting_subject" => "xy",
"submission_created_at" => "2024-11-11T22:28:09.673+00:00",
"period" => nil,
"dismissal_reason" => nil,
"message_container" =>
{
"message_id" => SecureRandom.uuid,
"sender_id" => "FSSR",
"recipient_id" => "1122222333",
"message_type" => "ED.DeliveryReport",
"subject" => "x",
"objects" => [
{
"class" => "FORM",
"description" => "DeliveryReport",
"encoding" => "Base64",
"id" => SecureRandom.uuid,
"signed" => true,
"mime_type" => "application/vnd.etsi.asic-e+zip",
"name" => "DeliveryReport",
"content" =>
"content xy"
}
]
}
}

message = Fs::Message.create_inbox_message(raw_messafe)

assert_equal message.delivered_at.zone, Time.parse(message.metadata['fs_submission_created_at']).zone
assert_equal '2024-11-11 23:28:11 +0100', message.delivered_at.to_s
assert_equal '2024-11-11T23:28:09.673+01:00', message.metadata['fs_submission_created_at']
end
end

0 comments on commit 5511571

Please sign in to comment.