-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #546 from slovensko-digital/GO-181/filter_only_del…
…ivered_messages GO-181 Create InboxTag in order to filter only delivered significant messages
- Loading branch information
Showing
10 changed files
with
204 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AddInboxTagToThreadJob < ApplicationJob | ||
def perform(message_thread) | ||
message_thread.assign_tag(message_thread.tenant.inbox_tag) if message_thread.messages.any?{ |message| significant_inbox_message?(message) } | ||
end | ||
|
||
private | ||
|
||
def significant_inbox_message?(message) | ||
!message.outbox? && !Govbox::Message::INSIGNIFICANT_MESSAGE_CLASSES.include?(message.metadata.dig('edesk_class')) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInboxTagToThreadsJob < ApplicationJob | ||
def perform | ||
MessageThread.find_each { |message_thread| AddInboxTagToThreadJob.perform_later(message_thread) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :bigint not null, primary key | ||
# color :enum | ||
# external_name :string | ||
# icon :string | ||
# name :string not null | ||
# tag_groups_count :integer default(0), not null | ||
# type :string not null | ||
# visible :boolean default(TRUE), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# owner_id :bigint | ||
# tenant_id :bigint not null | ||
# | ||
class InboxTag < Tag | ||
def destroyable? | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateInboxTag < ActiveRecord::Migration[7.1] | ||
def up | ||
Tenant.find_each do |tenant| | ||
tenant.create_inbox_tag!(name: "Doručené", visible: false) unless tenant.inbox_tag | ||
AddInboxTagToThreadsJob.set(job_context: :later).perform_later | ||
end | ||
end | ||
|
||
def down | ||
# noop | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters