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
f7471e0b
Commit
f7471e0b
authored
Jun 01, 2021
by
Markus Koller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Pushover integration to Integrations namespace
Part of
https://gitlab.com/gitlab-org/gitlab/-/issues/201855
parent
e7cfd585
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
117 additions
and
116 deletions
+117
-116
.rubocop_manual_todo.yml
.rubocop_manual_todo.yml
+0
-1
app/models/integrations/pushover.rb
app/models/integrations/pushover.rb
+107
-0
app/models/project.rb
app/models/project.rb
+1
-1
app/models/project_services/pushover_service.rb
app/models/project_services/pushover_service.rb
+0
-105
lib/api/helpers/services_helpers.rb
lib/api/helpers/services_helpers.rb
+2
-2
lib/gitlab/integrations/sti_type.rb
lib/gitlab/integrations/sti_type.rb
+1
-1
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+2
-2
spec/models/integrations/pushover_spec.rb
spec/models/integrations/pushover_spec.rb
+1
-1
spec/services/admin/propagate_service_template_spec.rb
spec/services/admin/propagate_service_template_spec.rb
+1
-1
spec/workers/propagate_integration_worker_spec.rb
spec/workers/propagate_integration_worker_spec.rb
+1
-1
spec/workers/propagate_service_template_worker_spec.rb
spec/workers/propagate_service_template_worker_spec.rb
+1
-1
No files found.
.rubocop_manual_todo.yml
View file @
f7471e0b
...
...
@@ -1652,7 +1652,6 @@ Gitlab/NamespacedClass:
-
'
app/models/project_services/mock_monitoring_service.rb'
-
'
app/models/project_services/monitoring_service.rb'
-
'
app/models/project_services/prometheus_service.rb'
-
'
app/models/project_services/pushover_service.rb'
-
'
app/models/project_services/slack_slash_commands_service.rb'
-
'
app/models/project_services/slash_commands_service.rb'
-
'
app/models/project_setting.rb'
...
...
app/models/integrations/pushover.rb
0 → 100644
View file @
f7471e0b
# frozen_string_literal: true
module
Integrations
class
Pushover
<
Integration
BASE_URI
=
'https://api.pushover.net/1'
prop_accessor
:api_key
,
:user_key
,
:device
,
:priority
,
:sound
validates
:api_key
,
:user_key
,
:priority
,
presence:
true
,
if: :activated?
def
title
'Pushover'
end
def
description
s_
(
'PushoverService|Get real-time notifications on your device.'
)
end
def
self
.
to_param
'pushover'
end
def
fields
[
{
type:
'text'
,
name:
'api_key'
,
title:
_
(
'API key'
),
placeholder:
s_
(
'PushoverService|Your application key'
),
required:
true
},
{
type:
'text'
,
name:
'user_key'
,
placeholder:
s_
(
'PushoverService|Your user key'
),
required:
true
},
{
type:
'text'
,
name:
'device'
,
placeholder:
s_
(
'PushoverService|Leave blank for all active devices'
)
},
{
type:
'select'
,
name:
'priority'
,
required:
true
,
choices:
[
[
s_
(
'PushoverService|Lowest Priority'
),
-
2
],
[
s_
(
'PushoverService|Low Priority'
),
-
1
],
[
s_
(
'PushoverService|Normal Priority'
),
0
],
[
s_
(
'PushoverService|High Priority'
),
1
]
],
default_choice:
0
},
{
type:
'select'
,
name:
'sound'
,
choices:
[
[
'Device default sound'
,
nil
],
[
'Pushover (default)'
,
'pushover'
],
%w(Bike bike)
,
%w(Bugle bugle)
,
[
'Cash Register'
,
'cashregister'
],
%w(Classical classical)
,
%w(Cosmic cosmic)
,
%w(Falling falling)
,
%w(Gamelan gamelan)
,
%w(Incoming incoming)
,
%w(Intermission intermission)
,
%w(Magic magic)
,
%w(Mechanical mechanical)
,
[
'Piano Bar'
,
'pianobar'
],
%w(Siren siren)
,
[
'Space Alarm'
,
'spacealarm'
],
[
'Tug Boat'
,
'tugboat'
],
[
'Alien Alarm (long)'
,
'alien'
],
[
'Climb (long)'
,
'climb'
],
[
'Persistent (long)'
,
'persistent'
],
[
'Pushover Echo (long)'
,
'echo'
],
[
'Up Down (long)'
,
'updown'
],
[
'None (silent)'
,
'none'
]
]
}
]
end
def
self
.
supported_events
%w(push)
end
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
ref
=
Gitlab
::
Git
.
ref_name
(
data
[
:ref
])
before
=
data
[
:before
]
after
=
data
[
:after
]
message
=
if
Gitlab
::
Git
.
blank_ref?
(
before
)
s_
(
"PushoverService|%{user_name} pushed new branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
elsif
Gitlab
::
Git
.
blank_ref?
(
after
)
s_
(
"PushoverService|%{user_name} deleted branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
else
s_
(
"PushoverService|%{user_name} push to branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
end
if
data
[
:total_commits_count
]
>
0
message
=
[
message
,
s_
(
"PushoverService|Total commits count: %{total_commits_count}"
)
%
{
total_commits_count:
data
[
:total_commits_count
]
}].
join
(
"
\n
"
)
end
pushover_data
=
{
token:
api_key
,
user:
user_key
,
device:
device
,
priority:
priority
,
title:
"
#{
project
.
full_name
}
"
,
message:
message
,
url:
data
[
:project
][
:web_url
],
url_title:
s_
(
"PushoverService|See project %{project_full_name}"
)
%
{
project_full_name:
project
.
full_name
}
}
# Sound parameter MUST NOT be sent to API if not selected
if
sound
pushover_data
[
:sound
]
=
sound
end
Gitlab
::
HTTP
.
post
(
'/messages.json'
,
base_uri:
BASE_URI
,
body:
pushover_data
)
end
end
end
app/models/project.rb
View file @
f7471e0b
...
...
@@ -182,6 +182,7 @@ class Project < ApplicationRecord
has_one
:packagist_service
,
class_name:
'Integrations::Packagist'
has_one
:pipelines_email_service
,
class_name:
'Integrations::PipelinesEmail'
has_one
:pivotaltracker_service
,
class_name:
'Integrations::Pivotaltracker'
has_one
:pushover_service
,
class_name:
'Integrations::Pushover'
has_one
:redmine_service
,
class_name:
'Integrations::Redmine'
has_one
:slack_service
,
class_name:
'Integrations::Slack'
has_one
:teamcity_service
,
class_name:
'Integrations::Teamcity'
...
...
@@ -190,7 +191,6 @@ class Project < ApplicationRecord
has_one
:youtrack_service
,
class_name:
'Integrations::Youtrack'
has_one
:mattermost_slash_commands_service
has_one
:slack_slash_commands_service
has_one
:pushover_service
has_one
:prometheus_service
,
inverse_of: :project
has_one
:mock_monitoring_service
...
...
app/models/project_services/pushover_service.rb
deleted
100644 → 0
View file @
e7cfd585
# frozen_string_literal: true
class
PushoverService
<
Integration
BASE_URI
=
'https://api.pushover.net/1'
prop_accessor
:api_key
,
:user_key
,
:device
,
:priority
,
:sound
validates
:api_key
,
:user_key
,
:priority
,
presence:
true
,
if: :activated?
def
title
'Pushover'
end
def
description
s_
(
'PushoverService|Get real-time notifications on your device.'
)
end
def
self
.
to_param
'pushover'
end
def
fields
[
{
type:
'text'
,
name:
'api_key'
,
title:
_
(
'API key'
),
placeholder:
s_
(
'PushoverService|Your application key'
),
required:
true
},
{
type:
'text'
,
name:
'user_key'
,
placeholder:
s_
(
'PushoverService|Your user key'
),
required:
true
},
{
type:
'text'
,
name:
'device'
,
placeholder:
s_
(
'PushoverService|Leave blank for all active devices'
)
},
{
type:
'select'
,
name:
'priority'
,
required:
true
,
choices:
[
[
s_
(
'PushoverService|Lowest Priority'
),
-
2
],
[
s_
(
'PushoverService|Low Priority'
),
-
1
],
[
s_
(
'PushoverService|Normal Priority'
),
0
],
[
s_
(
'PushoverService|High Priority'
),
1
]
],
default_choice:
0
},
{
type:
'select'
,
name:
'sound'
,
choices:
[
[
'Device default sound'
,
nil
],
[
'Pushover (default)'
,
'pushover'
],
%w(Bike bike)
,
%w(Bugle bugle)
,
[
'Cash Register'
,
'cashregister'
],
%w(Classical classical)
,
%w(Cosmic cosmic)
,
%w(Falling falling)
,
%w(Gamelan gamelan)
,
%w(Incoming incoming)
,
%w(Intermission intermission)
,
%w(Magic magic)
,
%w(Mechanical mechanical)
,
[
'Piano Bar'
,
'pianobar'
],
%w(Siren siren)
,
[
'Space Alarm'
,
'spacealarm'
],
[
'Tug Boat'
,
'tugboat'
],
[
'Alien Alarm (long)'
,
'alien'
],
[
'Climb (long)'
,
'climb'
],
[
'Persistent (long)'
,
'persistent'
],
[
'Pushover Echo (long)'
,
'echo'
],
[
'Up Down (long)'
,
'updown'
],
[
'None (silent)'
,
'none'
]
]
}
]
end
def
self
.
supported_events
%w(push)
end
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
ref
=
Gitlab
::
Git
.
ref_name
(
data
[
:ref
])
before
=
data
[
:before
]
after
=
data
[
:after
]
message
=
if
Gitlab
::
Git
.
blank_ref?
(
before
)
s_
(
"PushoverService|%{user_name} pushed new branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
elsif
Gitlab
::
Git
.
blank_ref?
(
after
)
s_
(
"PushoverService|%{user_name} deleted branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
else
s_
(
"PushoverService|%{user_name} push to branch
\"
%{ref}
\"
."
)
%
{
user_name:
data
[
:user_name
],
ref:
ref
}
end
if
data
[
:total_commits_count
]
>
0
message
=
[
message
,
s_
(
"PushoverService|Total commits count: %{total_commits_count}"
)
%
{
total_commits_count:
data
[
:total_commits_count
]
}].
join
(
"
\n
"
)
end
pushover_data
=
{
token:
api_key
,
user:
user_key
,
device:
device
,
priority:
priority
,
title:
"
#{
project
.
full_name
}
"
,
message:
message
,
url:
data
[
:project
][
:web_url
],
url_title:
s_
(
"PushoverService|See project %{project_full_name}"
)
%
{
project_full_name:
project
.
full_name
}
}
# Sound parameter MUST NOT be sent to API if not selected
if
sound
pushover_data
[
:sound
]
=
sound
end
Gitlab
::
HTTP
.
post
(
'/messages.json'
,
base_uri:
BASE_URI
,
body:
pushover_data
)
end
end
lib/api/helpers/services_helpers.rb
View file @
f7471e0b
...
...
@@ -798,14 +798,14 @@ module API
::
Integrations
::
Packagist
,
::
Integrations
::
PipelinesEmail
,
::
Integrations
::
Pivotaltracker
,
::
Integrations
::
Pushover
,
::
Integrations
::
Redmine
,
::
Integrations
::
Slack
,
::
Integrations
::
Teamcity
,
::
Integrations
::
Youtrack
,
::
MattermostSlashCommandsService
,
::
SlackSlashCommandsService
,
::
PrometheusService
,
::
PushoverService
::
PrometheusService
]
end
...
...
lib/gitlab/integrations/sti_type.rb
View file @
f7471e0b
...
...
@@ -7,7 +7,7 @@ module Gitlab
Asana Assembla Bamboo Bugzilla Buildkite Campfire Confluence CustomIssueTracker Datadog
Discord DroneCi EmailsOnPush Ewm ExternalWiki Flowdock HangoutsChat IssueTracker Irker
Jenkins Jira Mattermost MicrosoftTeams MockCi Packagist PipelinesEmail Pivotaltracker
Redmine Slack Teamcity UnifyCircuit Youtrack WebexTeams
Pushover
Redmine Slack Teamcity UnifyCircuit Youtrack WebexTeams
)
).
freeze
def
cast
(
value
)
...
...
spec/models/integration_spec.rb
View file @
f7471e0b
...
...
@@ -446,7 +446,7 @@ RSpec.describe Integration do
describe
"for pushover service"
do
let!
(
:service_template
)
do
PushoverService
.
create!
(
Integrations
::
Pushover
.
create!
(
template:
true
,
properties:
{
device:
'MyDevice'
,
...
...
@@ -672,7 +672,7 @@ RSpec.describe Integration do
expect
(
described_class
.
service_name_to_model
(
'asana'
)).
to
eq
(
Integrations
::
Asana
)
# TODO We can remove this test when all models have been namespaced:
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60968#note_570994955
expect
(
described_class
.
service_name_to_model
(
'p
ushover'
)).
to
eq
(
Pushover
Service
)
expect
(
described_class
.
service_name_to_model
(
'p
rometheus'
)).
to
eq
(
Prometheus
Service
)
end
it
'raises an error if service name is invalid'
do
...
...
spec/models/
project_services/pushover_service
_spec.rb
→
spec/models/
integrations/pushover
_spec.rb
View file @
f7471e0b
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
PushoverService
do
RSpec
.
describe
Integrations
::
Pushover
do
include
StubRequests
describe
'Associations'
do
...
...
spec/services/admin/propagate_service_template_spec.rb
View file @
f7471e0b
...
...
@@ -6,7 +6,7 @@ RSpec.describe Admin::PropagateServiceTemplate do
describe
'.propagate'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let!
(
:service_template
)
do
PushoverService
.
create!
(
Integrations
::
Pushover
.
create!
(
template:
true
,
active:
true
,
push_events:
false
,
...
...
spec/workers/propagate_integration_worker_spec.rb
View file @
f7471e0b
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec
.
describe
PropagateIntegrationWorker
do
describe
'#perform'
do
let
(
:integration
)
do
PushoverService
.
create!
(
Integrations
::
Pushover
.
create!
(
template:
true
,
active:
true
,
device:
'MyDevice'
,
...
...
spec/workers/propagate_service_template_worker_spec.rb
View file @
f7471e0b
...
...
@@ -7,7 +7,7 @@ RSpec.describe PropagateServiceTemplateWorker do
describe
'#perform'
do
it
'calls the propagate service with the template'
do
template
=
PushoverService
.
create!
(
template
=
Integrations
::
Pushover
.
create!
(
template:
true
,
active:
true
,
properties:
{
...
...
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