diff --git a/app/models/govbox/message.rb b/app/models/govbox/message.rb index 8d30da4d..fb48bb93 100644 --- a/app/models/govbox/message.rb +++ b/app/models/govbox/message.rb @@ -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' @@ -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? diff --git a/db/migrate/20240916130319_update_replyable_values_on_messages.rb b/db/migrate/20240916130319_update_replyable_values_on_messages.rb new file mode 100644 index 00000000..3782777e --- /dev/null +++ b/db/migrate/20240916130319_update_replyable_values_on_messages.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index b22c56b6..d35fee4b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_08_20_143244) do +ActiveRecord::Schema[7.1].define(version: 2024_09_16_130319) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql"