Skip to content

Commit

Permalink
Small fixes after PROD testing
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Oct 23, 2024
1 parent 6840c4f commit 50ca8c5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def nice_datetime(datetime)
end
end

def nice_datetime_with_time(datetime, keep_year: false)
if datetime.today?
def nice_datetime_with_time(datetime, full_date: false)
if datetime.today? && !full_date
l(datetime, format: '%H:%M')
elsif datetime.year == Date.current.year && !keep_year
elsif datetime.year == Date.current.year && !full_date
l(datetime, format: '%e. %b %H:%M')
else
l(datetime, format: '%e. %b %Y %H:%M')
Expand Down
6 changes: 4 additions & 2 deletions app/jobs/fs/download_sent_message_job.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module Fs
class DownloadSentMessageJob < ApplicationJob
def perform(fs_message_id, box:, fs_client: FsEnvironment.fs_client)
return if box.messages.where("metadata ->> 'fs_message_id' = ?", fs_message_id).any?
return if box.messages.where.not(type: 'Fs::MessageDraft').where("metadata ->> 'fs_message_id' = ?", fs_message_id).any?

fs_api = fs_client.api(api_connection: box.api_connection, box: box)

raw_message = fs_api.fetch_sent_message(fs_message_id)

Fs::Message.create_outbox_message_with_thread!(raw_message, box: box)
message = Fs::Message.create_outbox_message_with_thread!(raw_message, box: box)

DownloadSentMessageRelatedMessagesJob.set(wait: 3.minutes).perform_later(message)
end
end
end
6 changes: 3 additions & 3 deletions app/jobs/fs/download_sent_message_related_messages_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def perform(outbox_message, from: nil, to: nil, fs_client: FsEnvironment.fs_clie
0.step do |k|
received_messages = fs_api.fetch_received_messages(sent_message_id: outbox_message.metadata['fs_message_id'], page: k + 1, count: batch_size, from: from, to: to)

received_messages['messages'].each do |received_message|
::Fs::DownloadReceivedMessageJob.perform_later(received_message['message_id'], box: outbox_message.box)
end
received_messages['messages'].each do |received_message|
::Fs::DownloadReceivedMessageJob.perform_later(received_message['message_id'], box: outbox_message.box)
end

break if received_messages['messages'].size < batch_size
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/fs/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def self.create_outbox_message_with_thread!(raw_message, box:)
update_html_visualization(message)

EventBus.publish(:message_created, message)

message
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/views/fs/messages/_delivery_report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<td>
<b>
<time class="md:hidden" datetime="<%= message.metadata['fs_submission_created_at'] %>">
<%= ApplicationController.helpers.nice_datetime_with_time(Time.parse(message.metadata['fs_submission_created_at']), keep_year: true) %>
<%= ApplicationController.helpers.nice_datetime_with_time(Time.parse(message.metadata['fs_submission_created_at']), full_date: true) %>
</time>
</b>
</td>
Expand All @@ -62,7 +62,7 @@
<td>
<b>
<time class="md:hidden" datetime="<%= message.delivered_at %>">
<%= ApplicationController.helpers.nice_datetime_with_time(message.delivered_at, keep_year: true) %>
<%= ApplicationController.helpers.nice_datetime_with_time(message.delivered_at, full_date: true) %>
</time>
</b>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/fs/messages/_generic_message.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<td>
<b>
<time class="md:hidden" datetime="<%= message.metadata['fs_submission_created_at'] %>">
<%= ApplicationController.helpers.nice_datetime_with_time(Time.parse(message.metadata['fs_submission_created_at']), keep_year: true) %>
<%= ApplicationController.helpers.nice_datetime_with_time(Time.parse(message.metadata['fs_submission_created_at']), full_date: true) %>
</time>
</b>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/fs/messages/_submission.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td>
<b>
<time class="md:hidden" datetime="<%= message.delivered_at %>">
<%= ApplicationController.helpers.nice_datetime_with_time(message.delivered_at, keep_year: true) %>
<%= ApplicationController.helpers.nice_datetime_with_time(message.delivered_at, full_date: true) %>
</time>
</b>
</td>
Expand Down

0 comments on commit 50ca8c5

Please sign in to comment.