Skip to content

Commit

Permalink
Update message replyable? rules
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Sep 16, 2024
1 parent 6a7ef9d commit 8d35575
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/models/govbox/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Govbox::Message < ApplicationRecord
EGOV_DOCUMENT_CLASS = 'EGOV_DOCUMENT'
EGOV_NOTIFICATION_CLASS = 'EGOV_NOTIFICATION'
COLLAPSED_BY_DEFAULT_MESSAGE_CLASSES = ['ED_DELIVERY_REPORT', 'POSTING_CONFIRMATION', 'POSTING_INFORMATION']
GENERAL_AGENDA_SCHEMA = 'http://schemas.gov.sk/form/App.GeneralAgenda/1.9'

DELIVERY_NOTIFICATION_TAG = 'delivery_notification'

Expand Down Expand Up @@ -51,7 +52,9 @@ def self.create_message_with_thread!(govbox_message)
end

def replyable?
folder.inbox? && [EGOV_DOCUMENT_CLASS, EGOV_NOTIFICATION_CLASS].include?(payload["class"])
folder.inbox? &&
[EGOV_DOCUMENT_CLASS, EGOV_NOTIFICATION_CLASS].include?(payload["class"]) &&
Upvs::ServiceWithFormAllowRule.where(institution_uri: payload["sender_uri"]).where(schema_url: GENERAL_AGENDA_SCHEMA).any?
end

def collapsed?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class UpdateReplyableValuesOnMessages < ActiveRecord::Migration[7.0]
def change
Message.find_each do |message|
govbox_message = Govbox::Message.find_by(message_id: message.uuid)
message.update(replyable: govbox_message&.replyable? || false)
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d35575

Please sign in to comment.