Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6dc3efdd
Commit
6dc3efdd
authored
Dec 22, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not override incoming webhook channel for mattermost and slack
parent
47550d09
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
7 deletions
+13
-7
app/models/project_services/chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+6
-4
app/models/project_services/mattermost_service.rb
app/models/project_services/mattermost_service.rb
+1
-1
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+1
-1
changelogs/unreleased/issue_25887.yml
changelogs/unreleased/issue_25887.yml
+4
-0
spec/support/slack_mattermost_notifications_shared_examples.rb
...support/slack_mattermost_notifications_shared_examples.rb
+1
-1
No files found.
app/models/project_services/chat_notification_service.rb
View file @
6dc3efdd
...
@@ -49,10 +49,12 @@ class ChatNotificationService < Service
...
@@ -49,10 +49,12 @@ class ChatNotificationService < Service
return
false
unless
message
return
false
unless
message
opt
=
{}
channel_name
=
get_channel_field
(
object_kind
).
presence
||
channel
opt
[
:channel
]
=
get_channel_field
(
object_kind
).
presence
||
channel
||
default_channel
opt
=
{}
opt
[
:channel
]
=
channel_name
if
channel_name
opt
[
:username
]
=
username
if
username
opt
[
:username
]
=
username
if
username
notifier
=
Slack
::
Notifier
.
new
(
webhook
,
opt
)
notifier
=
Slack
::
Notifier
.
new
(
webhook
,
opt
)
notifier
.
ping
(
message
.
pretext
,
attachments:
message
.
attachments
,
fallback:
message
.
fallback
)
notifier
.
ping
(
message
.
pretext
,
attachments:
message
.
attachments
,
fallback:
message
.
fallback
)
...
@@ -71,7 +73,7 @@ class ChatNotificationService < Service
...
@@ -71,7 +73,7 @@ class ChatNotificationService < Service
fields
.
reject
{
|
field
|
field
[
:name
].
end_with?
(
'channel'
)
}
fields
.
reject
{
|
field
|
field
[
:name
].
end_with?
(
'channel'
)
}
end
end
def
default_channel
def
default_channel
_placeholder
raise
NotImplementedError
raise
NotImplementedError
end
end
...
@@ -103,7 +105,7 @@ class ChatNotificationService < Service
...
@@ -103,7 +105,7 @@ class ChatNotificationService < Service
def
build_event_channels
def
build_event_channels
supported_events
.
reduce
([])
do
|
channels
,
event
|
supported_events
.
reduce
([])
do
|
channels
,
event
|
channels
<<
{
type:
'text'
,
name:
event_channel_name
(
event
),
placeholder:
default_channel
}
channels
<<
{
type:
'text'
,
name:
event_channel_name
(
event
),
placeholder:
default_channel
_placeholder
}
end
end
end
end
...
...
app/models/project_services/mattermost_service.rb
View file @
6dc3efdd
...
@@ -35,7 +35,7 @@ class MattermostService < ChatNotificationService
...
@@ -35,7 +35,7 @@ class MattermostService < ChatNotificationService
]
]
end
end
def
default_channel
def
default_channel
_placeholder
"#town-square"
"#town-square"
end
end
end
end
app/models/project_services/slack_service.rb
View file @
6dc3efdd
...
@@ -34,7 +34,7 @@ class SlackService < ChatNotificationService
...
@@ -34,7 +34,7 @@ class SlackService < ChatNotificationService
]
]
end
end
def
default_channel
def
default_channel
_placeholder
"#general"
"#general"
end
end
end
end
changelogs/unreleased/issue_25887.yml
0 → 100644
View file @
6dc3efdd
---
title
:
Do not override incoming webhook for mattermost and slack
merge_request
:
author
:
spec/support/slack_mattermost_notifications_shared_examples.rb
View file @
6dc3efdd
...
@@ -105,7 +105,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
...
@@ -105,7 +105,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
allow
(
chat_service
).
to
receive
(
:username
).
and_return
(
username
)
allow
(
chat_service
).
to
receive
(
:username
).
and_return
(
username
)
expect
(
Slack
::
Notifier
).
to
receive
(
:new
).
expect
(
Slack
::
Notifier
).
to
receive
(
:new
).
with
(
webhook_url
,
username:
username
,
channel:
chat_service
.
default_channel
).
with
(
webhook_url
,
username:
username
).
and_return
(
and_return
(
double
(
:slack_service
).
as_null_object
double
(
:slack_service
).
as_null_object
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment