Skip to content

Commit

Permalink
Merge pull request #69 from centosadmin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vladislav-yashin authored Feb 20, 2018
2 parents 6c98c59 + 8836f13 commit 0eab9f8
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.0.2

* Fix circular dependency issues
* Add bot collision check
* Don't send notifications to non-active users
* Fix status update message

# 1.0.1

* Add Rails 5.1 support
Expand Down
4 changes: 4 additions & 0 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Примеры конфигурационного файла и скрипта для `init.d` находятся в папке `extras`

Нужно инициализировать бота на странице настроек плагина (вкладка Telegram).

*Примечание: каждый из наших плагинов требует наличие отдельного бота.*

### Обновление с 0.3 на 1.0.0+

Начиная с версии 1.0.0 этот плагин использует [redmine_telegram_common](https://github.com/centosadmin/redmine_telegram_common)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production

The `extras` folder has the examples of the plugin config files and the `init.d` startup script

You need to initialize bot on plugin settings page (tab Telegram).

*Note: each of our plugins requires separate bot. It won't work if you use the same bot for several plugins.*

### Upgrade from 0.3 to 1.0.0+

Since version 1.0.0 this plugin uses [redmine_telegram_common](https://github.com/centosadmin/redmine_telegram_common)
Expand Down
10 changes: 10 additions & 0 deletions app/views/settings/_telegram.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<label for="settings_telegram_bot_token">Bot Token</label>
<%= text_field_tag 'settings[telegram_bot_token]', @settings['telegram_bot_token'], size: 50 %>

<% if (bot_collisions = TelegramCommon.bot_collisions).present? %>
<br>
<strong style="color: red"><%= t 'telegram_common.settings.bot_collision' %></strong>
<% bot_collisions.each do |collision| %>
<p>
<strong><%= collision.join(', ') %><strong>
</p>
<% end %>
<% end %>

<div style="display: flex; align-items: center;">
<div style="flex: 1; padding: 0.5em;">
<h3>WebHooks</h3>
Expand Down
2 changes: 1 addition & 1 deletion app/workers/telegram_group_sender_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def notificable?
end

def groups
@groups ||= TelegramGroupChat.where(id: group_ids).uniq
@groups ||= ::TelegramGroupChat.where(id: group_ids).uniq
end

def send_message(group)
Expand Down
4 changes: 0 additions & 4 deletions app/workers/telegram_sender_worker.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require_relative '../../lib/intouch/regular/checker/base'
require_relative '../../lib/intouch/regular/recipients_list'
require_relative '../../lib/intouch/regular/message/private'

class TelegramSenderWorker
include Sidekiq::Worker

Expand Down
4 changes: 3 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
end
end

Rails.application.config.eager_load_paths += Dir.glob("#{Rails.application.config.root}/plugins/redmine_intouch/{lib,app/workers,app/models,app/controllers}")

Redmine::Plugin.register :redmine_intouch do
name 'Redmine Intouch plugin'
url 'https://github.com/centosadmin/redmine_intouch'
description 'This is a plugin for Redmine which sends a reminder email and Telegram messages to the assignee workign on a task, whose status is not updated with-in allowed duration'
version '1.0.1'
version '1.0.2'
author 'Southbridge'
author_url 'https://github.com/centosadmin'

Expand Down
4 changes: 0 additions & 4 deletions lib/intouch/live/handler/new_issue.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require_relative '../checker/base'
require_relative '../message/private'
require_relative '../message/group'

module Intouch::Live::Handler
class NewIssue
def initialize(issue)
Expand Down
4 changes: 0 additions & 4 deletions lib/intouch/live/handler/updated_issue.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require_relative '../checker/base'
require_relative '../message/private'
require_relative '../message/group'

module Intouch::Live::Handler
class UpdatedIssue
def initialize(journal)
Expand Down
4 changes: 2 additions & 2 deletions lib/intouch/live/message/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def required_recipients
def send_telegram_private_messages
return unless telegram_enabled?

IntouchSender.send_live_telegram_message(issue.id, required_recipients)
::IntouchSender.send_live_telegram_message(issue.id, required_recipients)
end

def send_email_messages
return unless email_enabled?

IntouchSender.send_live_email_message(issue.id, required_recipients)
::IntouchSender.send_live_email_message(issue.id, required_recipients)
end

def telegram_enabled?
Expand Down
2 changes: 1 addition & 1 deletion lib/intouch/patches/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def telegram_live_message

message += bold_for_alarm(updated_priority_text) if updated_details.include?('priority')

message += "\n#{I18n.t('field_status')}: #{updated_status_text}" if updated_details.include?('status')
message += "\n#{I18n.t('field_status')}: #{updated_status_text}" if updated_details.include?('status_id')

message += "\n#{I18n.t('intouch.telegram_message.issue.updated_details')}: #{updated_details_text}" if updated_details_text.present?

Expand Down
2 changes: 1 addition & 1 deletion lib/intouch/patches/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def active_intouch_settings
end

def settings_template
@settings_template ||= SettingsTemplate.find_by(id: settings_template_id)
@settings_template ||= ::SettingsTemplate.find_by(id: settings_template_id)
end

def title
Expand Down
2 changes: 1 addition & 1 deletion lib/intouch/regular/recipients_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(issue:, protocol:, state:)
def call
return [] unless recipient_ids.present?

User.where(id: recipient_ids)
User.where(id: recipient_ids).status(User::STATUS_ACTIVE)
end

def recipient_ids
Expand Down

0 comments on commit 0eab9f8

Please sign in to comment.