From ae837256f61a616b455dc2c2b9a8589ba3326554 Mon Sep 17 00:00:00 2001 From: Vladislav Yashin Date: Fri, 20 Apr 2018 19:16:23 +0300 Subject: [PATCH 01/25] WIP --- app/models/settings_template.rb | 2 +- .../intouch/issue_update/_common.html.erb | 2 +- .../intouch/reminder/_common.html.erb | 2 +- .../intouch/reminder/_overdue.html.erb | 2 +- .../intouch/reminder/_unassigned.html.erb | 2 +- app/views/settings/_common.html.erb | 2 +- app/workers/slack_live_worker.rb | 20 +++++++ app/workers/telegram_live_sender_worker.rb | 51 ++--------------- init.rb | 11 +++- lib/intouch.rb | 31 ++++++----- lib/intouch/issue_decorator.rb | 55 ++++++++++--------- lib/intouch/issue_update.rb | 55 +++++++++++++++++++ lib/intouch/live/handler/updated_issue.rb | 20 ++----- lib/intouch/patches/project_patch.rb | 12 ++-- lib/intouch/protocols/base.rb | 18 ++++++ lib/intouch/protocols/email.rb | 0 lib/intouch/protocols/slack.rb | 11 ++++ lib/intouch/protocols/telegram.rb | 20 +++++++ 18 files changed, 196 insertions(+), 120 deletions(-) create mode 100644 app/workers/slack_live_worker.rb create mode 100644 lib/intouch/issue_update.rb create mode 100644 lib/intouch/protocols/base.rb create mode 100644 lib/intouch/protocols/email.rb create mode 100644 lib/intouch/protocols/slack.rb create mode 100644 lib/intouch/protocols/telegram.rb diff --git a/app/models/settings_template.rb b/app/models/settings_template.rb index caaead6..5918a3a 100644 --- a/app/models/settings_template.rb +++ b/app/models/settings_template.rb @@ -3,7 +3,7 @@ class SettingsTemplate < ActiveRecord::Base attr_accessible :name, :intouch_settings - store :intouch_settings, accessors: %w[assigner_groups assigner_roles reminder_settings telegram_settings email_settings] + store :intouch_settings, accessors: %w[assigner_groups assigner_roles reminder_settings] | Intouch.protocols.keys.map { |p| "#{p}_settings" } def copy_from(settings_template) self.attributes = settings_template.attributes.dup.except('id', 'created_on', 'updated_on') diff --git a/app/views/projects/settings/intouch/issue_update/_common.html.erb b/app/views/projects/settings/intouch/issue_update/_common.html.erb index c24b4bd..a6f680e 100644 --- a/app/views/projects/settings/intouch/issue_update/_common.html.erb +++ b/app/views/projects/settings/intouch/issue_update/_common.html.erb @@ -47,7 +47,7 @@ <% IssuePriority.order(:position).each do |priority| %> - <% Intouch.active_protocols.each do |protocol| %> + <% Intouch.active_protocols.each do |protocol, _| %> <%= check_box_tag "intouch_settings[#{protocol}_settings][#{kind}][#{status.id}][]", priority.id, settings_source.send("#{protocol}_settings").try(:[], kind). diff --git a/app/views/projects/settings/intouch/reminder/_common.html.erb b/app/views/projects/settings/intouch/reminder/_common.html.erb index 75d2a6b..d0c6d7d 100644 --- a/app/views/projects/settings/intouch/reminder/_common.html.erb +++ b/app/views/projects/settings/intouch/reminder/_common.html.erb @@ -10,7 +10,7 @@ <% %w(author assigned_to watchers).each do |receiver| %> - <% Intouch.active_protocols.each do |protocol| %> + <% Intouch.active_protocols.each do |protocol, _| %> <%= check_box_tag "intouch_settings[#{protocol}_settings][#{status}][#{receiver}]", '1', settings_source.send("#{protocol}_settings").try(:[], status).try(:[], receiver), class: "#{protocol}_#{receiver}", diff --git a/app/views/projects/settings/intouch/reminder/_overdue.html.erb b/app/views/projects/settings/intouch/reminder/_overdue.html.erb index 8483de8..0fb4238 100644 --- a/app/views/projects/settings/intouch/reminder/_overdue.html.erb +++ b/app/views/projects/settings/intouch/reminder/_overdue.html.erb @@ -23,7 +23,7 @@ <% %w(author assigned_to watchers).each do |receiver| %> - <% Intouch.active_protocols.each do |protocol| %> + <% Intouch.active_protocols.each do |protocol, _| %> <%= check_box_tag "intouch_settings[#{protocol}_settings][overdue][#{receiver}]", '1', settings_source.send("#{protocol}_settings").try(:[], 'overdue').try(:[], receiver), diff --git a/app/views/projects/settings/intouch/reminder/_unassigned.html.erb b/app/views/projects/settings/intouch/reminder/_unassigned.html.erb index e3e491b..c4ab984 100644 --- a/app/views/projects/settings/intouch/reminder/_unassigned.html.erb +++ b/app/views/projects/settings/intouch/reminder/_unassigned.html.erb @@ -22,7 +22,7 @@ <% %w(author watchers).each do |receiver| %> - <% Intouch.active_protocols.each do |protocol| %> + <% Intouch.active_protocols.each do |protocol, _| %> <%= check_box_tag "intouch_settings[#{protocol}_settings][unassigned][#{receiver}]", '1', settings_source.send("#{protocol}_settings").try(:[], 'unassigned').try(:[], receiver), class: "#{protocol}_#{receiver}", diff --git a/app/views/settings/_common.html.erb b/app/views/settings/_common.html.erb index fea52f6..ab22420 100644 --- a/app/views/settings/_common.html.erb +++ b/app/views/settings/_common.html.erb @@ -4,7 +4,7 @@

<%= t 'intouch.settings.common.protocols.description' %>