34 Commits
0.9.9 ... 1.0.2

Author SHA1 Message Date
Alexander Meindl
f44366bd75 Add documentation to use plugin with Discord #7 2018-01-25 18:47:28 +01:00
Alexander Meindl
7339e9e382 Add is_private support for db and contacts 2018-01-25 17:05:28 +01:00
Alexander Meindl
4d447f75ab Do not show watcher info, if no watcher is assigned 2018-01-25 15:37:12 +01:00
Alexander Meindl
593d7055e0 slim templates, subdirectory bug fixed #9, other solution of #12 included 2018-01-24 12:03:28 +01:00
Alexander Meindl
c16dec39e4 Remove comments 2018-01-02 13:07:27 +01:00
Alexander Meindl
0ee9fa36e6 Fix ignore file problem 2017-12-13 10:26:25 +01:00
Alexander Meindl
95a914f1ae stylelint configuration 2017-12-12 22:14:43 +01:00
Alexander Meindl
d683f08eef Add disable rule to rubocop for timestamp 2017-12-12 18:36:45 +01:00
Alexander Meindl
1085b042e5 add coverage to ignore list 2017-12-11 21:42:20 +01:00
Alexander Meindl
454437cbf5 Add eslintignore 2017-12-11 21:39:36 +01:00
Alexander Meindl
a53fd43ef4 add linter configuration 2017-12-11 21:11:18 +01:00
Alexander Meindl
7a3d335065 Updated, rails optimized common rubocop configuration 2017-10-15 09:33:41 +02:00
Alexander Meindl
b2d71d2a0e Use space in front of To 2017-10-10 19:21:36 +02:00
Alexander Meindl
2a1672f024 Fix issue with settings 2017-10-10 18:56:15 +02:00
Alexander Meindl
2c3b503f68 Some code cleanups 2017-10-10 18:25:17 +02:00
Alexander Meindl
0427b97a46 Support for existion database and some cosmetics 2017-10-10 18:15:11 +02:00
Alessandro Grassi
bbd6a69f8d Add support for default mentions
Signed-off-by: Alessandro Grassi <alessandro.grassi@2ndquadrant.com>
2017-10-10 16:52:38 +02:00
Alexander Meindl
763cf347f6 use references instead of belongs_to 2017-08-05 09:57:21 +02:00
Alexander Meindl
3687fbbe90 Update changelog 2017-08-05 07:20:47 +02:00
Alexander Meindl
9a8295247c Add unit test for parsing ja strings 2017-08-05 07:12:05 +02:00
Alexander Meindl
fe8d1fd856 Merge pull request #5 from Yoto/japanese
Add a Japanese support. Thanks for your help!
2017-08-05 06:52:29 +02:00
Yusuke Yoshimura
53e75212cb Add a Japanese support 2017-08-05 13:28:50 +09:00
Alexander Meindl
c98e4fc989 Add settings string 2017-07-31 13:27:57 +02:00
Alexander Meindl
18a2856aa2 Documentation fix for installation 2017-07-29 11:24:55 +02:00
Alexander Meindl
df46bf0f15 Improve installation and uninstall documentation 2017-07-29 06:59:43 +02:00
Alexander Meindl
5d6495f009 Redmine 3.4.x support and version bump to 1.0.0 2017-07-13 12:32:43 +02:00
Alexander Meindl
8162eeb01d Remove issue.save from changeset hook 2017-07-12 19:00:22 +02:00
Alexander Meindl
7e9a994c03 Merge pull request #3 from danfai/master
Send repository update message only if updates should be sent
2017-07-12 18:48:50 +02:00
danfai
2e2e2c4286 Send repository update message only if updates should be sent 2017-07-12 17:08:18 +02:00
Alexander Meindl
5882bad2cb Merge pull request #2 from TRIOTECH-fr/master
Fixed undefined project variable
2017-07-11 15:28:47 +02:00
qkdreyer
92f0c40b50 Merge branch 'master' of https://github.com/TRIOTECH-fr/redmine_messenger 2017-07-01 10:45:21 +02:00
qkdreyer
a91795a818 Fixed undefined project variable 2017-06-30 17:17:23 +02:00
Alexander Meindl
6295fb3b26 add_filter init.rb 2017-06-28 16:19:37 +02:00
Alexander Meindl
a68e3a2fb1 Add code coverage to tests 2017-06-28 15:21:30 +02:00
40 changed files with 673 additions and 372 deletions

17
.eslintrc.yml Normal file
View File

@@ -0,0 +1,17 @@
env:
browser: true
jquery: true
extends: 'eslint:recommended'
rules:
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.DS_Store
coverage/
.buildpath
.project
.settings/

View File

@@ -1,43 +1,42 @@
Rails:
Enabled: true
Rails/ApplicationRecord:
Enabled: false
AllCops:
TargetRubyVersion: 2.1
TargetRailsVersion: 4.2
Metrics/LineLength:
Max: 140
# Offense count: 34
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 60
# Offense count: 11
Metrics/CyclomaticComplexity:
Max: 13
# Offense count: 10
Metrics/PerceivedComplexity:
Max: 14
# Offense count: 15
Metrics/AbcSize:
Max: 65
Metrics/ModuleLength:
Max: 300
Metrics/BlockLength:
Max: 50
Metrics/ClassLength:
Max: 300
Metrics/CyclomaticComplexity:
Max: 13
Metrics/LineLength:
Max: 140
Metrics/MethodLength:
Max: 60
Metrics/ModuleLength:
Max: 300
Metrics/PerceivedComplexity:
Max: 14
Rails/SkipsModelValidations:
Enabled: false
Rails/CreateTableWithTimestamps:
Enabled: false
Style/AutoResourceCleanup:
Enabled: true
Style/Documentation:
Enabled: false
Rails/HttpPositionalArguments:
Enabled: false
Metrics/BlockLength:
Max: 50

3
.slim-lint.yml Normal file
View File

@@ -0,0 +1,3 @@
linters:
LineLength:
max: 140

163
.stylelintrc.json Normal file
View File

@@ -0,0 +1,163 @@
{
"rules": {
"at-rule-no-unknown": true,
"block-no-empty": true,
"color-no-invalid-hex": true,
"comment-no-empty": true,
"declaration-block-no-duplicate-properties": [
true,
{
"ignore": [
"consecutive-duplicates-with-different-values"
]
}
],
"declaration-block-no-redundant-longhand-properties": true,
"declaration-block-no-shorthand-property-overrides": true,
"font-family-no-duplicate-names": true,
"font-family-no-missing-generic-family-keyword": true,
"function-calc-no-unspaced-operator": true,
"function-linear-gradient-no-nonstandard-direction": true,
"keyframe-declaration-no-important": true,
"media-feature-name-no-unknown": true,
"no-descending-specificity": true,
"no-duplicate-at-import-rules": true,
"no-duplicate-selectors": true,
"no-empty-source": true,
"no-extra-semicolons": true,
"no-invalid-double-slash-comments": true,
"property-no-unknown": true,
"selector-pseudo-class-no-unknown": true,
"selector-pseudo-element-no-unknown": true,
"selector-type-no-unknown": true,
"string-no-newline": true,
"unit-no-unknown": true,
"at-rule-empty-line-before": [
"always",
{
"except": [
"blockless-after-same-name-blockless",
"first-nested"
],
"ignore": [
"after-comment"
]
}
],
"at-rule-name-case": "lower",
"at-rule-name-space-after": "always-single-line",
"at-rule-semicolon-newline-after": "always",
"block-closing-brace-empty-line-before": "never",
"block-closing-brace-newline-after": "always",
"block-closing-brace-newline-before": "always-multi-line",
"block-closing-brace-space-before": "always-single-line",
"block-opening-brace-newline-after": "always-multi-line",
"block-opening-brace-space-after": "always-single-line",
"block-opening-brace-space-before": "always",
"color-hex-case": "lower",
"color-hex-length": "short",
"comment-empty-line-before": [
"always",
{
"except": [
"first-nested"
],
"ignore": [
"stylelint-commands"
]
}
],
"comment-whitespace-inside": "always",
"custom-property-empty-line-before": [
"always",
{
"except": [
"after-custom-property",
"first-nested"
],
"ignore": [
"after-comment",
"inside-single-line-block"
]
}
],
"declaration-bang-space-after": "never",
"declaration-bang-space-before": "always",
"declaration-block-semicolon-newline-after": "always-multi-line",
"declaration-block-semicolon-space-after": "always-single-line",
"declaration-block-semicolon-space-before": "never",
"declaration-block-single-line-max-declarations": 1,
"declaration-block-trailing-semicolon": "always",
"declaration-colon-newline-after": "always-multi-line",
"declaration-colon-space-after": "always-single-line",
"declaration-colon-space-before": "never",
"declaration-empty-line-before": [
"always",
{
"except": [
"after-declaration",
"first-nested"
],
"ignore": [
"after-comment",
"inside-single-line-block"
]
}
],
"function-comma-newline-after": "always-multi-line",
"function-comma-space-after": "always-single-line",
"function-comma-space-before": "never",
"function-max-empty-lines": 0,
"function-name-case": "lower",
"function-parentheses-newline-inside": "always-multi-line",
"function-parentheses-space-inside": "never-single-line",
"function-whitespace-after": "always",
"indentation": 2,
"length-zero-no-unit": true,
"max-empty-lines": 1,
"media-feature-colon-space-after": "always",
"media-feature-colon-space-before": "never",
"media-feature-name-case": "lower",
"media-feature-parentheses-space-inside": "never",
"media-feature-range-operator-space-after": "always",
"media-feature-range-operator-space-before": "always",
"media-query-list-comma-newline-after": "always-multi-line",
"media-query-list-comma-space-after": "always-single-line",
"media-query-list-comma-space-before": "never",
"no-eol-whitespace": true,
"no-missing-end-of-source-newline": true,
"number-leading-zero": "always",
"number-no-trailing-zeros": true,
"property-case": "lower",
"rule-empty-line-before": [
"always-multi-line",
{
"except": [
"first-nested"
],
"ignore": [
"after-comment"
]
}
],
"selector-attribute-brackets-space-inside": "never",
"selector-attribute-operator-space-after": "never",
"selector-attribute-operator-space-before": "never",
"selector-combinator-space-after": "always",
"selector-combinator-space-before": "always",
"selector-descendant-combinator-no-non-space": true,
"selector-list-comma-newline-after": "always",
"selector-list-comma-space-before": "never",
"selector-max-empty-lines": 0,
"selector-pseudo-class-case": "lower",
"selector-pseudo-class-parentheses-space-inside": "never",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "double",
"selector-type-case": "lower",
"unit-case": "lower",
"value-list-comma-newline-after": "always-multi-line",
"value-list-comma-space-after": "always-single-line",
"value-list-comma-space-before": "never",
"value-list-max-empty-lines": 0
}
}

View File

@@ -1,35 +1,62 @@
Changelog
=========
## 0.9.9
1.0.2
-----
* 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)
- Bug fixed with issue urls, if Redmine is in subdirectory
- slim is used as template engine
- add private contacts, db and passwords support (if plugins are installed)
- Discord support added to documentation
## v0.6.1
1.0.1
-----
- Japanese translation has been added - thanks @Yoto
- Default mentions has been added - thanks @xstasi
1.0.0
-----
- Redmine 3.4.x compatibility
- Commit message issue bug fix
- Some code cleanups
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.
This plugin posts updates to issues in your Redmine installation to [Slack](https://slack.com/), [Rocket.Chat](https://rocket.chat/), [Discord](https://discordapp.com/) 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
@@ -39,24 +43,32 @@ Go to Slack documentation [Incoming Webhooks](https://api.slack.com/incoming-web
Go to Mattermost documentation [Incoming Webhooks](https://docs.mattermost.com/developer/webhooks-incoming.html) for more information to set up Incoming WebHook
### Discord
Go to Discord documentation [Intro to Webhooks ](https://support.discordapp.com/hc/en-us/articles/228383668) for more information to set up Incoming WebHook
You have to add /slack after your webhook url.
### Rocket.Chat
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 exec rake db:migrate_plugins
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.
Under the configuration options, set the Messenger API URL to the URL for an
@@ -66,18 +78,20 @@ 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``
cd $REDMINE_ROOT
bundle exec rake db:migrate_plugins NAME=redmine_messenger VERSION=0
bundle exec rake redmine:plugins:migrate NAME=redmine_messenger VERSION=0 RAILS_ENV=production
rm -rf plugins/redmine_messenger
Restart Redmine (application server)
## Credits
Credits
-------
The source code is forked from

View File

@@ -4,8 +4,12 @@ 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] unless url
url ||= RedmineMessenger.settings[:messenger_url]
return if url.blank?
return if channels.blank?
@@ -32,18 +36,14 @@ class Messenger
uri = URI(url)
params[:channel] = channel
http_options = { use_ssl: uri.scheme == 'https' }
if RedmineMessenger.settings[:messenger_verify_ssl] != 1
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
@@ -137,7 +135,7 @@ class Messenger
return parent_setting if @setting_found == 1
end
# system based
return true if RedmineMessenger.settings[config].present? && RedmineMessenger.settings[config] == '1'
return true if RedmineMessenger.settings[config].present? && RedmineMessenger.setting?(config)
false
end
@@ -219,10 +217,12 @@ class Messenger
result
end
def self.mentions(text)
return nil if text.nil?
names = extract_usernames(text)
names.present? ? '\nTo: ' + names.join(', ') : nil
def self.mentions(project, text)
names = []
Messenger.textfield_for_project(project, :default_mentions)
.split(',').each { |m| names.push m.strip }
names += extract_usernames(text) unless text.nil?
names.present? ? ' To: ' + names.uniq.join(', ') : nil
end
def self.extract_usernames(text)

View File

@@ -12,6 +12,7 @@ class MessengerSetting < ActiveRecord::Base
'messenger_username',
'messenger_verify_ssl',
'auto_mentions',
'default_mentions',
'display_watchers',
'post_updates',
'new_include_description',
@@ -22,31 +23,14 @@ class MessengerSetting < ActiveRecord::Base
'post_wiki_updates',
'post_db',
'post_db_updates',
'post_private_db',
'post_contact',
'post_contact_updates',
'post_private_contacts',
'post_password',
'post_password_updates'
attr_accessible :messenger_url,
:messenger_icon,
:messenger_channel,
:messenger_username,
:messenger_verify_ssl,
:auto_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,74 +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_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,71 @@
.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 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_db }
- 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 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_contacts }
- 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,126 +0,0 @@
<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] %>
<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] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_display_watchers)) %>
<%= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_updates)) %>
<%= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_new_include_description)) %>
<%= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_updated_include_description)) %>
<%= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_private_issues)) %>
<%= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_private_notes)) %>
<%= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes] %>
</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] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_wiki_updates)) %>
<%= check_box_tag 'settings[post_wiki_updates]', 1, @settings[:post_wiki_updates] %>
</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] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_db_updates)) %>
<%= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates] %>
</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] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_contact_updates)) %>
<%= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates] %>
</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] %>
</p>
<p>
<%= content_tag(:label, l(:label_settings_post_password_updates)) %>
<%= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates] %>
</p>
<% end %>

View File

@@ -0,0 +1,104 @@
- @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://webhook.url')
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
p
= content_tag(:label, l(:label_settings_post_private_db))
= check_box_tag 'settings[post_private_db]', 1, @settings[:post_private_db].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
p
= content_tag(:label, l(:label_settings_post_private_contacts))
= check_box_tag 'settings[post_private_contacts]', 1, @settings[:post_private_contacts].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

@@ -0,0 +1 @@
# eslint ignore file

View File

@@ -0,0 +1 @@
# stylelint ignore file

View File

@@ -18,6 +18,7 @@ de:
label_messenger_wiki_updated: "[%{project_url}] Wiki %{url} aktualisiert von *%{user}*"
label_messenger: Messenger
label_settings_auto_mentions: Namen für Mentions konvertiert?
label_settings_default_mentions: Standardbenutzer für Mentions
label_settings_display_watchers: Beobachter?
label_settings_messenger_channel: Messenger Channel
label_settings_messenger_icon: Messenger Icon
@@ -27,10 +28,12 @@ de:
label_settings_new_include_description: Neue Ticketeschreibung?
label_settings_post_contact_updates: Kontakt Updates?
label_settings_post_contact: Neue Kontakte?
label_settings_post_db_updates: DB entry Updates?
label_settings_post_db: Neue DB entries?
label_settings_post_db_updates: DB Einträge Updates?
label_settings_post_db: Neue DB Einträge?
label_settings_post_password_updates: Passwort Updates?
label_settings_post_password: Neue Passwörter?
label_settings_post_private_db: Private DB Einträge?
label_settings_post_private_contacts: Private Kontakte?
label_settings_post_private_issues: Private Ticket Updates?
label_settings_post_private_notes: Private Notizen?
label_settings_post_updates: Ticket Updates?
@@ -47,3 +50,5 @@ de:
messenger_url_info_html: 'Generiere eine <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> URL vom Messenger Service. Um nur aus bestimmten Projekten Nachrichten zu versenden, kann diese URL leer bleiben und in den Projekteinstellungen gesetzt werden.'
messenger_verify_ssl_info_html: 'Falls der Messenger Service ein ungültiges oder selbst erstelltes (self-signed) SSL Zertifikat verwendet bitte deaktivieren.'
messenger_wiki_intro: Legen Sie fest welche Einträge oder Änderungen für Wikis im angegebenen Messenger Channel versendet werden.
label_messenger_setting: Messenger Einstellung
default_mentionsl_info: Benutzer, die immer mit Mentions benachrichtet werden sollen. Mehrere Namen können mit Komma getrennt angegeben werden (z.B. @all, @here).

View File

@@ -18,6 +18,7 @@ en:
label_messenger_wiki_updated: "[%{project_url}] Wiki %{url} updated by *%{user}*"
label_messenger: Messenger
label_settings_auto_mentions: Convert names to mentions?
label_settings_default_mentions: Default people for mentions
label_settings_display_watchers: Display watchers?
label_settings_messenger_channel: Messenger Channel
label_settings_messenger_icon: Messenger Icon
@@ -31,6 +32,8 @@ en:
label_settings_post_db: DB entry added?
label_settings_post_password_updates: Password updates?
label_settings_post_password: Password added?
label_settings_post_private_db: Private DB entries?
label_settings_post_private_contacts: Private contacts?
label_settings_post_private_issues: Private issue updates?
label_settings_post_private_notes: Private notes updates?
label_settings_post_updates: Issue updates?
@@ -47,3 +50,5 @@ en:
messenger_url_info_html: 'Generate an <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> URL from the messenger service. Leave it empty, if you only want to activate specific projects with project based settings'
messenger_verify_ssl_info_html: 'If your Messenger service uses an invalid or self-signed SSL certificate, disable it.'
messenger_wiki_intro: Activate the changes for Wikis that should be sent to the pre-defined Messenger channel.
label_messenger_setting: Messenger Settings
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)

54
config/locales/ja.yml Normal file
View File

@@ -0,0 +1,54 @@
# Japanese strings
ja:
permission_manage_messenger: メッセンジャーの管理
label_messenger_contact_created: "[%{project_url}] コンタクト %{url} が *%{user}* によって作成されました。"
label_messenger_contact_updated: "[%{project_url}] コンタクト %{url} が*%{user}* によって更新されました。"
label_messenger_db_entry_created: "[%{project_url}] DB entry %{url} created by *%{user}*"
label_messenger_db_entry_updated: "[%{project_url}] DB entry %{url} updated by *%{user}*"
label_messenger_default_not_visible: デフォルトの設定はセキュリティ上の理由により表示されません。
label_messenger_issue_created: "[%{project_url}] チケット %{url} が *%{user}* によって作成されました。"
label_messenger_issue_updated: "[%{project_url}] チケット %{url} が *%{user}* によって更新されました。"
label_messenger_password_created: "[%{project_url}] Kennwort %{url} created by *%{user}*"
label_messenger_password_updated: "[%{project_url}] Kennwort %{url} updated by *%{user}*"
label_messenger_project_text_field_info: デフォルトの設定を使う場合空欄にしてください。
label_messenger_settings_default: デフォルト
label_messenger_settings_disabled: 無効
label_messenger_settings_enabled: 有効
label_messenger_wiki_created: "[%{project_url}] Wiki %{url} が by *%{user}* によって作成されました。"
label_messenger_wiki_updated: "[%{project_url}] Wiki %{url} が *%{user}* によって更新されました。"
label_messenger: メッセンジャー
label_settings_auto_mentions: ユーザー名をその人についての投稿(@ユーザー名)に変換する
label_settings_default_mentions: Default people for mentions
label_settings_display_watchers: ウォッチャーを表示する
label_settings_messenger_channel: メッセンジャーのチャンネル
label_settings_messenger_icon: メッセンジャーのアイコン
label_settings_messenger_url: メッセンジャーのURL
label_settings_messenger_username: メッセンジャーのユーザー名
label_settings_messenger_verify_ssl: SSL証明書の検証
label_settings_new_include_description: チケット作成時に説明を含める
label_settings_post_contact_updates: コンタクトの更新
label_settings_post_contact: コンタクトの作成
label_settings_post_db_updates: DB entry updates?
label_settings_post_db: DB entry added?
label_settings_post_password_updates: Password updates?
label_settings_post_password: Password added?
label_settings_post_private_db: Private DB entries?
label_settings_post_private_contacts: Private contacts?
label_settings_post_private_issues: プライベートチケットの更新
label_settings_post_private_notes: プライベート注記の更新
label_settings_post_updates: チケットの更新
label_settings_post_wiki_updates: Wikiの更新
label_settings_post_wiki: Wikiの作成
label_settings_updated_include_description: チケット更新時に説明を含める
messenger_channel_info_html: チャンネルを指定する必要があります。複数のチャンネルを指定する場合は,(カンマ)で区切って下さい。
messenger_contacts_intro: メッセンジャーに送信するチケットのイベントにチェックを入れて下さい。
messenger_db_intro: Activate the changes for DB that should be sent to the pre-defined Messenger channel.
messenger_issue_intro: メッセンジャーに送信するチケットのイベントにチェックを入れて下さい。
messenger_passwords_intro: Activate the changes for Passwords that should be sent to the pre-defined Messenger channel.
messenger_settings_intro: 管理画面でメッセンジャーのURLを指定した場合、全てのプロジェクトのデフォルトの送信先になります。プロジェクト毎の送信先を設定する場合はプロジェクトの設定画面で設定して下さい。
messenger_settings_project_intro: メッセンジャーのURLを指定しない場合、管理者が指定したチャンネルにメッセージが送信されます。(管理者がチャンネルを指定していない場合は、空欄にすると機能は無効になります)
messenger_url_info_html: 'メッセンジャー サービスで <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">内向きのウェブフック</a>のURLを作成して下さい。プロジェクト毎に設定を変えたい場合は空欄として下さい。'
messenger_verify_ssl_info_html: 'メッセンジャー サービスが自己署名証明書や不正な証明書を使っている場合、無効として下さい。'
messenger_wiki_intro: メッセンジャーに送信するWikiのイベントにチェックを入れて下さい。
label_messenger_setting: メッセンジャーの設定
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)

View File

@@ -3,7 +3,7 @@
class CreateMessengerSettings < ActiveRecord::Migration
def change
create_table :messenger_settings do |t|
t.belongs_to :project, null: false
t.references :project, null: false, index: true
t.string :messenger_url
t.string :messenger_icon
t.string :messenger_channel

View File

@@ -0,0 +1,7 @@
# Redmine Messenger plugin for Redmine
class AddDefaultMentions < ActiveRecord::Migration
def change
add_column :messenger_settings, :default_mentions, :string
end
end

View File

@@ -0,0 +1,8 @@
# Redmine Messenger plugin for Redmine
class AddPrivateSettings < ActiveRecord::Migration
def change
add_column :messenger_settings, :post_private_contacts, :integer, default: 0, null: false
add_column :messenger_settings, :post_private_db, :integer, default: 0, null: false
end
end

13
init.rb
View File

@@ -8,8 +8,8 @@ Redmine::Plugin.register :redmine_messenger do
author 'AlphaNodes GmbH'
url 'https://github.com/alphanodes/redmine_messenger'
author_url 'https://alphanodes.com/'
description 'Messenger integration for Slack, Rocketchat and Mattermost support'
version '0.9.9'
description 'Messenger integration for Slack, Discord, Rocketchat and Mattermost support'
version '1.0.2'
requires_redmine version_or_higher: '3.0.0'
@@ -21,13 +21,16 @@ Redmine::Plugin.register :redmine_messenger do
messenger_channel: 'redmine',
messenger_username: 'robot',
messenger_verify_ssl: '1',
auto_mentions: '1',
auto_mentions: '0',
default_mentions: '',
display_watchers: '0',
post_updates: '1',
new_include_description: '1',
updated_include_description: '1',
post_private_issues: '1',
post_private_notes: '1',
post_private_contacts: '0',
post_private_db: '0',
post_private_issues: '0',
post_private_notes: '0',
post_wiki: '0',
post_wiki_updates: '0',
post_db: '0',

View File

@@ -1,6 +1,22 @@
# Redmine Messenger plugin for Redmine
Rails.configuration.to_prepare do
module RedmineMessenger
REDMINE_CONTACTS_SUPPORT = Redmine::Plugin.installed?('redmine_contacts') ? true : false
REDMINE_DB_SUPPORT = Redmine::Plugin.installed?('redmine_db') ? true : false
# this does not work at the moment, because redmine loads passwords after messener plugin
REDMINE_PASSWORDS_SUPPORT = Redmine::Plugin.installed?('redmine_passwords') ? true : false
def self.settings
ActionController::Parameters.new(Setting[:plugin_redmine_messenger])
end
def self.setting?(value)
return true if settings[value].to_i == 1
false
end
end
# Patches
require_dependency 'redmine_messenger/patches/issue_patch'
require_dependency 'redmine_messenger/patches/wiki_page_patch'
@@ -16,14 +32,3 @@ Rails.configuration.to_prepare do
# Hooks
require_dependency 'redmine_messenger/hooks'
end
module RedmineMessenger
REDMINE_CONTACTS_SUPPORT = Redmine::Plugin.installed?('redmine_contacts') ? true : false
REDMINE_DB_SUPPORT = Redmine::Plugin.installed?('redmine_db') ? true : false
# this does not work at the moment, because redmine loads passwords after messener plugin
REDMINE_PASSWORDS_SUPPORT = Redmine::Plugin.installed?('redmine_passwords') ? true : false
def self.settings
Setting[:plugin_redmine_messenger].blank? ? {} : Setting[:plugin_redmine_messenger]
end
end

View File

@@ -3,9 +3,9 @@
module RedmineMessenger
module Helpers
def project_messenger_options(active)
options_for_select({ l(:label_messenger_settings_default) => 0,
l(:label_messenger_settings_disabled) => 1,
l(:label_messenger_settings_enabled) => 2 }, active)
options_for_select({ l(:label_messenger_settings_default) => '0',
l(:label_messenger_settings_disabled) => '1',
l(:label_messenger_settings_enabled) => '2' }, active)
end
def project_setting_messenger_default_value(value)

View File

@@ -10,8 +10,8 @@ module RedmineMessenger
channels = Messenger.channels_for_project issue.project
url = Messenger.url_for_project issue.project
return unless channels.present? && url && issue.save
return if issue.is_private? && !Messenger.setting_for_project(project, :post_private_issues)
return unless channels.present? && url && issue.changes.any? && Messenger.setting_for_project(issue.project, :post_updates)
return if issue.is_private? && !Messenger.setting_for_project(issue.project, :post_private_issues)
msg = "[#{ERB::Util.html_escape(issue.project)}] #{ERB::Util.html_escape(journal.user.to_s)} updated <#{Messenger.object_url issue}|#{ERB::Util.html_escape(issue)}>"
@@ -48,7 +48,7 @@ module RedmineMessenger
attachment[:text] = ll(Setting.default_language, :text_status_changed_by_changeset, "<#{revision_url}|#{ERB::Util.html_escape(changeset.comments)}>")
attachment[:fields] = journal.details.map { |d| Messenger.detail_to_field d }
Messenger.speak(msg, channels, url, attachment: attachment, project: project)
Messenger.speak(msg, channels, url, attachment: attachment, project: repository.project)
end
end
end

View File

@@ -14,6 +14,7 @@ module RedmineMessenger
module InstanceMethods
def send_messenger_create
return unless Messenger.setting_for_project(project, :post_contact)
return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
@@ -29,6 +30,7 @@ module RedmineMessenger
def send_messenger_update
return unless Messenger.setting_for_project(project, :post_contact_updates)
return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project

View File

@@ -14,6 +14,8 @@ module RedmineMessenger
module InstanceMethods
def send_messenger_create
return unless Messenger.setting_for_project(project, :post_db)
return if is_private? && !Messenger.setting_for_project(project, :post_private_db)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
@@ -29,6 +31,7 @@ module RedmineMessenger
def send_messenger_update
return unless Messenger.setting_for_project(project, :post_db_updates)
return if is_private? && !Messenger.setting_for_project(project, :post_private_db)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project

View File

@@ -25,21 +25,19 @@ 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.settings[:display_watchers] == '1'
if RedmineMessenger.setting?(:display_watchers) && watcher_users.count > 0
attachment[:fields] << {
title: I18n.t(:field_watcher),
value: ERB::Util.html_escape(watcher_users.join(', ')),
@@ -49,7 +47,7 @@ module RedmineMessenger
Messenger.speak(l(:label_messenger_issue_created,
project_url: "<#{Messenger.object_url project}|#{ERB::Util.html_escape(project)}>",
url: "<#{Messenger.object_url(self)}|#{ERB::Util.html_escape(self)}>#{Messenger.mentions description if RedmineMessenger.settings[:auto_mentions] == '1'}",
url: send_messenger_mention_url(project, description),
user: author),
channels, url, attachment: attachment, project: project)
end
@@ -70,15 +68,42 @@ 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,
project_url: "<#{Messenger.object_url project}|#{ERB::Util.html_escape(project)}>",
url: "<#{Messenger.object_url self}|#{ERB::Util.html_escape(self)}>#{Messenger.mentions(current_journal.notes) if Messenger.setting_for_project(project, :auto_mentions)}",
url: send_messenger_mention_url(project, current_journal.notes),
user: current_journal.user),
channels, url, attachment: attachment, project: project)
end
private
def send_messenger_mention_url(project, text)
mention_to = ''
if Messenger.setting_for_project(project, :auto_mentions) ||
Messenger.textfield_for_project(project, :default_mentions).present?
mention_to = Messenger.mentions(project, text)
end
"<#{Messenger.object_url(self)}|#{ERB::Util.html_escape(self)}>#{mention_to}"
end
end
end
end

View File

@@ -14,12 +14,14 @@ module RedmineMessenger
module InstanceMethods
def send_messenger_create
return unless Messenger.setting_for_project(project, :post_password)
return if is_private?
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak(l(:label_messenger_password_created,
project_url: "<#{Messenger.object_url project}|#{ERB::Util.html_escape(project)}>",
url: "<#{Messenger.object_url self}|#{name}>",
@@ -29,6 +31,7 @@ module RedmineMessenger
def send_messenger_update
return unless Messenger.setting_for_project(project, :post_password_updates)
return if is_private?
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project

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

View File

@@ -1,5 +1,3 @@
# Redmine Messenger plugin for Redmine
require File.expand_path('../../test_helper', __FILE__)
class CommonViewsTest < Redmine::IntegrationTest

View File

@@ -1,4 +1,17 @@
# Redmine Messenger plugin for Redmine
unless ENV['SKIP_COVERAGE']
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::RcovFormatter
]
SimpleCov.start :rails do
add_filter 'init.rb'
root File.expand_path(File.dirname(__FILE__) + '/..')
end
end
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')

View File

@@ -1,5 +1,3 @@
# Redmine Messenger plugin for Redmine
require File.expand_path('../../test_helper', __FILE__)
module Redmine
@@ -25,7 +23,7 @@ module Redmine
'config',
'locales',
'*.yml')].size
assert_equal lang_files_count, 2
assert_equal lang_files_count, 3
valid_languages.each do |lang|
assert set_language_if_valid(lang)
end
@@ -34,7 +32,8 @@ module Redmine
assert_equal 'Messenger Benutzer', l(:label_settings_messenger_username)
::I18n.locale = 'en'
assert_equal 'Messenger username', l(:label_settings_messenger_username)
::I18n.locale = 'ja'
assert_equal 'メッセンジャーのユーザー名', l(:label_settings_messenger_username)
set_language_if_valid('en')
end
end

View File

@@ -1,5 +1,3 @@
# Redmine Messenger plugin for Redmine
require File.expand_path('../../test_helper', __FILE__)
class IssueTest < ActiveSupport::TestCase

View File

@@ -1,22 +1,3 @@
# This file is a part of redmine_reporting,
# a reporting and statistics plugin for Redmine.
#
# Copyright (c) 2016-2017 AlphaNodes GmbH
# https://alphanodes.com
#
# redmine_reporting is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# redmine_reporting is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_reporting. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ProjectTest < ActiveSupport::TestCase