3 Commits
0.1 ... 0.2

Author SHA1 Message Date
Thanos Kyritsis
a5cecdb814 plugin successfully tested for redmine 3.2.x 2016-02-13 14:27:25 +02:00
Thanos Kyritsis
7eef353849 bump version to 0.2 and update redmine dependency (refs #3) 2016-02-13 14:26:48 +02:00
Thanos Kyritsis
0dd8f50592 borrow code from redmine's mailer.rb in order to proper detect sub-uri conditions (refs #4) 2016-02-13 14:26:02 +02:00
3 changed files with 33 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
This plugin posts updates to issues in your Redmine installation to a Mattermost
channel.
Redmine Supported versions: 2.0.x - 3.1.x (3.2.x is not yet tested but should work).
Redmine Supported versions: 2.0.x - 3.2.x.
## Screenshot

View File

@@ -8,9 +8,9 @@ Redmine::Plugin.register :redmine_mattermost do
url 'https://github.com/altsol/redmine_mattermost'
author_url 'http://altsol.gr'
description 'Mattermost chat integration'
version '0.1'
version '0.2'
requires_redmine :version_or_higher => '0.8.0'
requires_redmine :version_or_higher => '2.0.0'
settings \
:default => {

View File

@@ -71,15 +71,30 @@ class MattermostListener < Redmine::Hook::Listener
repository = changeset.repository
revision_url = Rails.application.routes.url_for(
:controller => 'repositories',
:action => 'revision',
:id => repository.project,
:repository_id => repository.identifier_param,
:rev => changeset.revision,
:host => Setting.host_name,
:protocol => Setting.protocol
)
if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
host, port, prefix = $2, $4, $5
revision_url = Rails.application.routes.url_for(
:controller => 'repositories',
:action => 'revision',
:id => repository.project,
:repository_id => repository.identifier_param,
:rev => changeset.revision,
:host => host,
:protocol => Setting.protocol,
:port => port,
:script_name => prefix
)
else
revision_url = Rails.application.routes.url_for(
:controller => 'repositories',
:action => 'revision',
:id => repository.project,
:repository_id => repository.identifier_param,
:rev => changeset.revision,
:host => Setting.host_name,
:protocol => Setting.protocol
)
end
attachment = {}
attachment[:text] = ll(Setting.default_language, :text_status_changed_by_changeset, "<#{revision_url}|#{escape changeset.comments}>")
@@ -127,7 +142,12 @@ private
end
def object_url(obj)
Rails.application.routes.url_for(obj.event_url({:host => Setting.host_name, :protocol => Setting.protocol}))
if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
host, port, prefix = $2, $4, $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}))
end
end
def url_for_project(proj)