-
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.
Mark only new significant inbox messages unread & mark their threads …
…with InboxTag
- Loading branch information
1 parent
7437ec3
commit 8031370
Showing
7 changed files
with
65 additions
and
3 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::INFORMATIONAL_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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.