slim templates, subdirectory bug fixed #9, other solution of #12 included

This commit is contained in:
Alexander Meindl
2018-01-24 12:03:28 +01:00
parent c16dec39e4
commit 593d7055e0
17 changed files with 278 additions and 297 deletions

View File

@@ -1,46 +1,60 @@
Changelog
=========
## 1.0.1
1.0.2
-----
* Japanese translation has been added - thanks @Yoto
* Default mentions has been added - thanks @xstasi
- Bug fixed with issue urls, if Redmine is in subdirectory
- slim is used as template engine
## 1.0.0
1.0.1
-----
* Redmine 3.4.x compatibility
* Commit message issue bug fix
* Some code cleanups
- Japanese translation has been added - thanks @Yoto
- Default mentions has been added - thanks @xstasi
## 0.9.9
1.0.0
-----
* All global messenger settings can be overwritten project based
* Locale support added
* Wiki added supported for notification
* Contact added/updated supported for notification (if redmine_contacts is installed)
* Password added/updated supported for notification (if redmine_passwords is installed)
* DB entry added/updated supported for notification (if redmine_db is installed)
* SSL verify can be disabled
* Lots of refactoring and code cleanups
* Swith from httpclient to net/http
* Fork of redmine_rocketchat, redmine_slack and redmine_mattermost (base functions for all three messenger)
- Redmine 3.4.x compatibility
- Commit message issue bug fix
- Some code cleanups
## v0.6.1
0.9.9
-----
- All global messenger settings can be overwritten project based
- Locale support added
- Wiki added supported for notification
- Contact added/updated supported for notification (if redmine_contacts is installed)
- Password added/updated supported for notification (if redmine_passwords is installed)
- DB entry added/updated supported for notification (if redmine_db is installed)
- SSL verify can be disabled
- Lots of refactoring and code cleanups
- Swith from httpclient to net/http
- Fork of redmine_rocketchat, redmine_slack and redmine_mattermost (base functions for all three messenger)
v0.6.1
------
unknown changes
## v0.4
v0.4
----
unknown changes
## v0.3
v0.3
----
unknown changes
## v0.2
v0.2
----
unknown changes
## v0.1
v0.1
----
unknown changes

1
Gemfile Normal file
View File

@@ -0,0 +1 @@
gem 'slim-rails'

View File

@@ -1,10 +1,12 @@
# Messenger plugin for Redmine
Messenger plugin for Redmine
============================
This plugin posts updates to issues in your Redmine installation to [Slack](https://slack.com/), [Rocket.Chat](https://rocket.chat/) or [Mattermost](https://about.mattermost.com/) channel.
[![Dependency Status](https://gemnasium.com/badges/github.com/AlphaNodes/redmine_messenger.svg)](https://gemnasium.com/github.com/AlphaNodes/redmine_messenger) ![Jenkins Build Status](https://pm.alphanodes.com/jenkins/buildStatus/icon?job=Devel-build-redmine-messenger)
## Features
Features
--------
* Post information to messenger channel
* post issue updates
@@ -19,7 +21,8 @@ This plugin posts updates to issues in your Redmine installation to [Slack](http
* parent project support (inherit messenger settings from parent project)
* multiple channel support (define one or more channels to deliver note)
## Screenshot
Screenshot
----------
Mattermost output:
@@ -29,7 +32,8 @@ Redmine configuration:
![screenshot](https://raw.githubusercontent.com/alphanodes/redmine_messenger/master/assets/images/screenshot_redmine_settings.png)
## Prepare your messenger service
Prepare your messenger service
------------------------------
### Slack
@@ -44,18 +48,21 @@ Go to Mattermost documentation [Incoming Webhooks](https://docs.mattermost.com/d
Go to Rocket.Chat documentation [Incoming WebHook Scripting](https://rocket.chat/docs/administrator-guides/integrations/) for more information to set up Incoming WebHook
## Requirements
Requirements
------------
* Redmine version >= 3.0.0
* Ruby version >= 2.1.5
## Installation
Installation
------------
Install ``redmine_messenger`` plugin for `Redmine`
cd $REDMINE_ROOT
git clone git://github.com/alphanodes/redmine_messenger.git plugins/redmine_messenger
bundle install --without development test
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
Restart Redmine (application server) and you should see the plugin show up in the Plugins page.
@@ -66,7 +73,8 @@ visible to users, you can find each channel's handle by navigating inside the ch
and clicking the down-arrow and selecting view info).
## Uninstall
Uninstall
---------
Uninstall ``redmine_messenger``
@@ -77,7 +85,8 @@ Uninstall ``redmine_messenger``
Restart Redmine (application server)
## Credits
Credits
-------
The source code is forked from

View File

@@ -4,6 +4,10 @@ require 'net/http'
class Messenger
include Redmine::I18n
def self.default_url_options
{ only_path: true, script_name: Redmine::Utils.relative_url_root }
end
def self.speak(msg, channels, url, options)
url ||= RedmineMessenger.settings[:messenger_url]
@@ -32,18 +36,14 @@ class Messenger
uri = URI(url)
params[:channel] = channel
http_options = { use_ssl: uri.scheme == 'https' }
unless RedmineMessenger.setting?(:messenger_verify_ssl)
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
end
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless RedmineMessenger.setting?(:messenger_verify_ssl)
begin
req = Net::HTTP::Post.new(uri)
req.set_form_data(payload: params.to_json)
Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|
response = http.request(req)
unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
Rails.logger.warn(response)
end
Rails.logger.warn(response) unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
end
rescue StandardError => e
Rails.logger.warn("cannot connect to #{url}")
@@ -53,13 +53,13 @@ class Messenger
end
def self.object_url(obj)
if Setting.host_name.to_s =~ %r{/\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i}
if Setting.host_name.to_s =~ %r{\A(https?\://)?(.+?)(\:(\d+))?(/.+)?\z}i
host = Regexp.last_match(2)
port = Regexp.last_match(4)
prefix = Regexp.last_match(5)
Rails.application.routes.url_for(obj.event_url(host: host, protocol: Setting.protocol, port: port, script_name: prefix))
else
Rails.application.routes.url_for(obj.event_url(host: Setting.host_name, protocol: Setting.protocol))
Rails.application.routes.url_for(obj.event_url(host: Setting.host_name, protocol: Setting.protocol, script_name: ''))
end
end
@@ -88,9 +88,7 @@ class Messenger
# parent project based
parent_field = textfield_for_project(proj.parent, config)
return parent_field if parent_field.present?
if RedmineMessenger.settings[config].present?
return RedmineMessenger.settings[config]
end
return RedmineMessenger.settings[config] if RedmineMessenger.settings[config].present?
''
end

View File

@@ -28,27 +28,7 @@ class MessengerSetting < ActiveRecord::Base
'post_password',
'post_password_updates'
attr_accessible :messenger_url,
:messenger_icon,
:messenger_channel,
:messenger_username,
:messenger_verify_ssl,
:auto_mentions,
:default_mentions,
:display_watchers,
:post_updates,
:new_include_description,
:updated_include_description,
:post_private_issues,
:post_private_notes,
:post_wiki,
:post_wiki_updates,
:post_db,
:post_db_updates,
:post_contact,
:post_contact_updates,
:post_password,
:post_password_updates
attr_protected :id
def self.find_or_create(p_id)
setting = MessengerSetting.find_by(project_id: p_id)

View File

@@ -1,4 +0,0 @@
<p>
<%= f.select mf, project_messenger_options(@messenger_setting.send(mf)), label: l("label_settings_#{mf}") %>
<em class="info" style="display: inline;"><%= l(:label_default) %>: <%= project_setting_messenger_default_value(mf) %></em>
</p>

View File

@@ -0,0 +1,7 @@
p
= f.select mf, project_messenger_options(@messenger_setting.send(mf)), label: l("label_settings_#{mf}")
'
em.info[style="display: inline;"]
= l(:label_default)
' :
= project_setting_messenger_default_value(mf)

View File

@@ -1,4 +0,0 @@
<p>
<%= f.text_field mf, size: size, label: l("label_settings_#{mf}") %>
<em class="info"><%= l(:label_messenger_project_text_field_info) %> (<%= l(:label_default) %>: <%= Messenger.default_textfield(@project, mf) %>)</em>
</p>

View File

@@ -0,0 +1,9 @@
p
= f.text_field mf, size: size, label: l("label_settings_#{mf}")
em.info
= l(:label_messenger_project_text_field_info)
| (
= l(:label_default)
' :
= Messenger.default_textfield(@project, mf)
| )

View File

@@ -1,75 +0,0 @@
<div class="box tabular messenger_settings">
<%
@messenger_setting = MessengerSetting.find_or_create(@project.id)
%>
<%= labelled_form_for :setting, @messenger_setting,
url: { controller: 'messenger_settings',
action: 'save', id: @project, tab: 'messenger',
partial: 'messenger_settings/save',
setting_id: @messenger_setting.id } do |f| %>
<%= error_messages_for 'messenger_setting' %>
<div class="box">
<div class="info"><%= t(:messenger_settings_project_intro) %></div><br />
<p><%= f.text_field :messenger_url, size: 60, label: l(:label_settings_messenger_url) %><em class="info"><%= l(:label_messenger_project_text_field_info) %> (<%= l(:label_messenger_default_not_visible) %>)</em></p>
<%= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_icon, size: 60 } %>
<%= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_channel, size: 30 } %>
<%= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_username, size: 30 } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :messenger_verify_ssl } %>
<br />
<h3><%= l(:label_issue_plural) %></h3>
<div class="info"><%= t(:messenger_issue_intro) %></div><br />
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :auto_mentions } %>
<%= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :default_mentions, size: 30 } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :display_watchers } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_updates } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :new_include_description } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :updated_include_description } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_issues } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_notes } %>
<br />
<h3><%= l(:label_wiki) %></h3>
<div class="info"><%= t(:messenger_wiki_intro) %></div><br />
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki_updates } %>
<% if RedmineMessenger::REDMINE_DB_SUPPORT && User.current.allowed_to?(:view_db_entries, @project) %>
<br />
<h3><%= l(:label_db_entry_plural) %></h3>
<div class="info"><%= t(:messenger_db_intro) %></div><br />
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db_updates } %>
<% end %>
<% if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project) %>
<br />
<h3><%= l(:label_contact_plural) %></h3>
<div class="info"><%= t(:messenger_contacts_intro) %></div><br />
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact_updates } %>
<% end %>
<% if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project) %>
<br />
<h3><%= l(:label_settings_post_password) %></h3>
<div class="info"><%= t(:messenger_passwords_intro) %></div><br />
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password } %>
<%= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password_updates } %>
<% end %>
</div>
<%= submit_tag l(:button_save) %>
<% end %>
</div>

View File

@@ -0,0 +1,69 @@
.box.tabular.messenger_settings
- @messenger_setting = MessengerSetting.find_or_create(@project.id)
= labelled_form_for :setting,
@messenger_setting,
url: { controller: 'messenger_settings',
action: 'save', id: @project, tab: 'messenger',
partial: 'messenger_settings/save',
setting_id: @messenger_setting.id } do |f|
= error_messages_for 'messenger_setting'
.box
.info = t(:messenger_settings_project_intro)
br
p
= f.text_field :messenger_url, size: 60, label: l(:label_settings_messenger_url)
em.info
= l(:label_messenger_project_text_field_info)
| (
= l(:label_messenger_default_not_visible)
| )
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_icon, size: 60 }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_channel, size: 30 }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_username, size: 30 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :messenger_verify_ssl }
br
h3 = l(:label_issue_plural)
.info = t(:messenger_issue_intro)
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :auto_mentions }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :default_mentions, size: 30 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :display_watchers }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_updates }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :new_include_description }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :updated_include_description }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_issues }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_notes }
br
h3 = l(:label_wiki)
.info = t(:messenger_wiki_intro)
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki_updates }
- if RedmineMessenger::REDMINE_DB_SUPPORT && User.current.allowed_to?(:view_db_entries, @project)
br
h3 = l(:label_db_entry_plural)
.info = t(:messenger_db_intro)
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db_updates }
- if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project)
br
h3 = l(:label_contact_plural)
.info = t(:messenger_contacts_intro)
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact_updates }
- if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project)
br
h3 = l(:label_settings_post_password)
.info = t(:messenger_passwords_intro)
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password_updates }
= submit_tag l(:button_save)

View File

@@ -1,134 +0,0 @@
<% @settings = ActionController::Parameters.new(@settings) %>
<div class="info"><%= t(:messenger_settings_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_messenger_url)) %>
<%= text_field_tag('settings[messenger_url]', @settings[:messenger_url], size: 60, placeholder: 'https://rocket.chat/hooks/my_rocket_chat_token') %>
<em class="info"><%= t(:messenger_url_info_html) %></em>
</p>
<p>
<%= content_tag(:label, l(:label_settings_messenger_icon)) %>
<%= text_field_tag('settings[messenger_icon]', @settings[:messenger_icon], size: 60) %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_messenger_channel)) %>
<%= text_field_tag('settings[messenger_channel]', @settings[:messenger_channel], size: 30, placeholder: 'redmine') %>
<em class="info"><%= t(:messenger_channel_info_html) %></em>
</p>
<p>
<%= content_tag(:label, l(:label_settings_messenger_username)) %>
<%= text_field_tag('settings[messenger_username]', @settings[:messenger_username], size: 30) %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_messenger_verify_ssl)) %>
<%= check_box_tag 'settings[messenger_verify_ssl]', 1, @settings[:messenger_verify_ssl].to_i == 1 %>
<em class="info"><%= t(:messenger_verify_ssl_info_html) %></em>
</p>
<br />
<h3><%= l(:label_issue_plural) %></h3>
<div class="info"><%= t(:messenger_issue_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_auto_mentions)) %>
<%= check_box_tag 'settings[auto_mentions]', 1, @settings[:auto_mentions].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_default_mentions)) %>
<%= text_field_tag('settings[default_mentions]', @settings[:default_mentions], size: 30) %>
<em class="info"><%= t(:default_mentionsl_info) %></em>
</p>
<p>
<%= content_tag(:label, l(:label_settings_display_watchers)) %>
<%= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_updates)) %>
<%= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_new_include_description)) %>
<%= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_updated_include_description)) %>
<%= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_private_issues)) %>
<%= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_private_notes)) %>
<%= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes].to_i == 1 %>
</p>
<br />
<h3><%= l(:label_wiki) %></h3>
<div class="info"><%= t(:messenger_wiki_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_post_wiki)) %>
<%= check_box_tag 'settings[post_wiki]', 1, @settings[:post_wiki].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_wiki_updates)) %>
<%= check_box_tag 'settings[post_wiki_updates]', 1, @settings[:post_wiki_updates].to_i == 1 %>
</p>
<% if RedmineMessenger::REDMINE_DB_SUPPORT %>
<br />
<h3><%= l(:label_db_entry_plural) %></h3>
<div class="info"><%= t(:messenger_db_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_post_db)) %>
<%= check_box_tag 'settings[post_db]', 1, @settings[:post_db].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_db_updates)) %>
<%= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1 %>
</p>
<% end %>
<% if RedmineMessenger::REDMINE_CONTACTS_SUPPORT %>
<br />
<h3><%= l(:label_contact_plural) %></h3>
<div class="info"><%= t(:messenger_contacts_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_post_contact)) %>
<%= check_box_tag 'settings[post_contact]', 1, @settings[:post_contact].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_contact_updates)) %>
<%= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1 %>
</p>
<% end %>
<% if Redmine::Plugin.installed?('redmine_passwords') %>
<br />
<h3><%= l(:label_password_plural) %></h3>
<div class="info"><%= t(:messenger_passwords_intro) %></div><br />
<p>
<%= content_tag(:label, l(:label_settings_post_password)) %>
<%= check_box_tag 'settings[post_password]', 1, @settings[:post_password].to_i == 1 %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_password_updates)) %>
<%= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates].to_i == 1 %>
</p>
<% end %>

View File

@@ -0,0 +1,98 @@
- @settings = ActionController::Parameters.new(@settings)
.info = t(:messenger_settings_intro)
br
p
= content_tag(:label, l(:label_settings_messenger_url))
= text_field_tag('settings[messenger_url]', @settings[:messenger_url], size: 60, placeholder: 'https://rocket.chat/hooks/my_rocket_chat_token')
em.info = t(:messenger_url_info_html)
p
= content_tag(:label, l(:label_settings_messenger_icon))
= text_field_tag('settings[messenger_icon]', @settings[:messenger_icon], size: 60)
p
= content_tag(:label, l(:label_settings_messenger_channel))
= text_field_tag('settings[messenger_channel]', @settings[:messenger_channel], size: 30, placeholder: 'redmine')
em.info = t(:messenger_channel_info_html)
p
= content_tag(:label, l(:label_settings_messenger_username))
= text_field_tag('settings[messenger_username]', @settings[:messenger_username], size: 30)
p
= content_tag(:label, l(:label_settings_messenger_verify_ssl))
= check_box_tag 'settings[messenger_verify_ssl]', 1, @settings[:messenger_verify_ssl].to_i == 1
em.info = t(:messenger_verify_ssl_info_html)
br
h3 = l(:label_issue_plural)
.info = t(:messenger_issue_intro)
br
p
= content_tag(:label, l(:label_settings_auto_mentions))
= check_box_tag 'settings[auto_mentions]', 1, @settings[:auto_mentions].to_i == 1
p
= content_tag(:label, l(:label_settings_default_mentions))
= text_field_tag('settings[default_mentions]', @settings[:default_mentions], size: 30)
em.info = t(:default_mentionsl_info)
p
= content_tag(:label, l(:label_settings_display_watchers))
= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers].to_i == 1
p
= content_tag(:label, l(:label_settings_post_updates))
= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates].to_i == 1
p
= content_tag(:label, l(:label_settings_new_include_description))
= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description].to_i == 1
p
= content_tag(:label, l(:label_settings_updated_include_description))
= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description].to_i == 1
p
= content_tag(:label, l(:label_settings_post_private_issues))
= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues].to_i == 1
p
= content_tag(:label, l(:label_settings_post_private_notes))
= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes].to_i == 1
br
h3 = l(:label_wiki)
.info = t(:messenger_wiki_intro)
br
p
= content_tag(:label, l(:label_settings_post_wiki))
= check_box_tag 'settings[post_wiki]', 1, @settings[:post_wiki].to_i == 1
p
= content_tag(:label, l(:label_settings_post_wiki_updates))
= check_box_tag 'settings[post_wiki_updates]', 1, @settings[:post_wiki_updates].to_i == 1
- if RedmineMessenger::REDMINE_DB_SUPPORT
br
h3 = l(:label_db_entry_plural)
.info = t(:messenger_db_intro)
br
p
= content_tag(:label, l(:label_settings_post_db))
= check_box_tag 'settings[post_db]', 1, @settings[:post_db].to_i == 1
p
= content_tag(:label, l(:label_settings_post_db_updates))
= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1
- if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
br
h3 = l(:label_contact_plural)
.info = t(:messenger_contacts_intro)
br
p
= content_tag(:label, l(:label_settings_post_contact))
= check_box_tag 'settings[post_contact]', 1, @settings[:post_contact].to_i == 1
p
= content_tag(:label, l(:label_settings_post_contact_updates))
= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1
- if Redmine::Plugin.installed?('redmine_passwords')
br
h3 = l(:label_password_plural)
.info = t(:messenger_passwords_intro)
br
p
= content_tag(:label, l(:label_settings_post_password))
= check_box_tag 'settings[post_password]', 1, @settings[:post_password].to_i == 1
p
= content_tag(:label, l(:label_settings_post_password_updates))
= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates].to_i == 1

View File

@@ -9,7 +9,7 @@ Redmine::Plugin.register :redmine_messenger do
url 'https://github.com/alphanodes/redmine_messenger'
author_url 'https://alphanodes.com/'
description 'Messenger integration for Slack, Rocketchat and Mattermost support'
version '1.0.1'
version '1.0.2'
requires_redmine version_or_higher: '3.0.0'

View File

@@ -13,6 +13,7 @@ Rails.configuration.to_prepare do
def self.setting?(value)
return true if settings[value].to_i == 1
false
end
end

View File

@@ -25,19 +25,17 @@ module RedmineMessenger
if description.present? && Messenger.setting_for_project(project, :new_include_description)
attachment[:text] = ERB::Util.html_escape(description)
end
attachment[:fields] = [{
title: I18n.t(:field_status),
value: ERB::Util.html_escape(status.to_s),
short: true
}, {
title: I18n.t(:field_priority),
value: ERB::Util.html_escape(priority.to_s),
short: true
}, {
title: I18n.t(:field_assigned_to),
value: ERB::Util.html_escape(assigned_to.to_s),
short: true
}]
attachment[:fields] = [{ title: I18n.t(:field_status),
value: ERB::Util.html_escape(status.to_s),
short: true },
{ title: I18n.t(:field_priority),
value: ERB::Util.html_escape(priority.to_s),
short: true }]
if assigned_to.present?
attachment[:fields] << { title: I18n.t(:field_assigned_to),
value: ERB::Util.html_escape(assigned_to.to_s),
short: true }
end
if RedmineMessenger.setting?(:display_watchers)
attachment[:fields] << {
@@ -70,7 +68,23 @@ module RedmineMessenger
if current_journal.notes.present? && Messenger.setting_for_project(project, :updated_include_description)
attachment[:text] = ERB::Util.html_escape(current_journal.notes)
end
fields = current_journal.details.map { |d| Messenger.detail_to_field d }
if status_id != status_id_was
fields << { title: I18n.t(:field_status),
value: ERB::Util.html_escape(status.to_s),
short: true }
end
if priority_id != priority_id_was
fields << { title: I18n.t(:field_priority),
value: ERB::Util.html_escape(priority.to_s),
short: true }
end
if assigned_to.present?
fields << { title: I18n.t(:field_assigned_to),
value: ERB::Util.html_escape(assigned_to.to_s),
short: true }
end
attachment[:fields] = fields if fields.any?
Messenger.speak(l(:label_messenger_issue_updated,

View File

@@ -53,6 +53,4 @@ module RedmineMessenger
end
end
unless Issue.included_modules.include? RedmineMessenger::Patches::IssuePatch
Issue.send(:include, RedmineMessenger::Patches::IssuePatch)
end
Issue.send(:include, RedmineMessenger::Patches::IssuePatch) unless Issue.included_modules.include? RedmineMessenger::Patches::IssuePatch