Skip to content

Commit 3016fac

Browse files
authored
refactor(api,ui): rm jabb notifications (#6036)
* refactor(api,ui): rm jabb notifications kafka event have to be used to send msg on enterprise msg system Signed-off-by: Yvonnick Esnault <[email protected]>
1 parent 7a94305 commit 3016fac

File tree

13 files changed

+26
-88
lines changed

13 files changed

+26
-88
lines changed

docs/content/docs/concepts/files/workflow-syntax.md

-18
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,6 @@ Example of email notification.
104104
105105
```
106106

107-
Example of jabber notification. Note that you can add `conditions` on every notifications
108-
109-
```yml
110-
- type: jabber
111-
pipelines:
112-
- deploy
113-
settings:
114-
on_start: true
115-
send_to_groups: true
116-
recipients:
117-
118-
conditions:
119-
check:
120-
- variable: cds.triggered_by.email
121-
operator: eq
122-
123-
```
124-
125107
Example of vcs notification. Note that `pipelines` list is optional on every notifications. When it's not specified, notification will be triggered for each pipeline
126108

127109
```yml

docs/content/docs/concepts/workflow/notifications.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ On a workflow you can have 2 kinds of notifications:
1010

1111
## User notifications
1212

13-
You can configure user notifications to send email or a message on jabber with different parameters. Inside the body of the notification you can customise the message thanks to the CDS variable templating with syntax like `{{.cds.myvar}}`. You can also use `HTML` to customise the message, then in order to let CDS interpret your message as an `HTML` one you just need to wrap all your message inside html tag like this `<html>MyContentHere</html>`.
13+
You can configure user notifications to send email with different parameters. Inside the body of the notification you can customise the message thanks to the CDS variable templating with syntax like `{{.cds.myvar}}`. You can also use `HTML` to customise the message, then in order to let CDS interpret your message as an `HTML` one you just need to wrap all your message inside html tag like this `<html>MyContentHere</html>`.
1414

1515
## VCS Notifications
1616

engine/api/notification.go

-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ func (api *API) getUserNotificationTypeHandler() service.Handler {
1919
SendToGroups: &sdk.False,
2020
Template: &sdk.UserNotificationTemplateEmail,
2121
},
22-
sdk.JabberUserNotification: {
23-
OnSuccess: sdk.UserNotificationChange,
24-
OnFailure: sdk.UserNotificationAlways,
25-
OnStart: &sdk.False,
26-
SendToAuthor: &sdk.True,
27-
SendToGroups: &sdk.False,
28-
Template: &sdk.UserNotificationTemplateJabber,
29-
},
3022
sdk.VCSUserNotification: {
3123
Template: &sdk.UserNotificationTemplate{
3224
Body: sdk.DefaultWorkflowNodeRunReport,

engine/api/notification/user.go

+2-34
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,18 @@ func GetUserWorkflowEvents(ctx context.Context, db gorp.SqlExecutor, store cache
5757
for _, notif := range notifs {
5858
if ShouldSendUserWorkflowNotification(ctx, notif, nr, previousWR) {
5959
switch notif.Type {
60-
case sdk.JabberUserNotification:
61-
jn := &notif.Settings
62-
//Get recipents from groups
63-
if jn.SendToGroups != nil && *jn.SendToGroups {
64-
u, err := projectPermissionUserIDs(ctx, db, store, projectID, sdk.PermissionRead)
65-
if err != nil {
66-
log.Error(ctx, "notification[Jabber]. error while loading permission: %v", err)
67-
break
68-
}
69-
users, err := user.LoadAllByIDs(ctx, db, u)
70-
if err != nil {
71-
log.Error(ctx, "notification[Jabber]. error while loading users: %v", err)
72-
break
73-
}
74-
for _, u := range users {
75-
jn.Recipients = append(jn.Recipients, u.Username)
76-
}
77-
}
78-
if jn.SendToAuthor == nil || *jn.SendToAuthor {
79-
if author, ok := params[paramsAuthorEmail]; ok {
80-
jn.Recipients = append(jn.Recipients, author)
81-
}
82-
}
83-
84-
//Finally deduplicate everyone
85-
removeDuplicates(&jn.Recipients)
86-
notif, err := getWorkflowEvent(jn, params)
87-
if err != nil {
88-
log.Error(ctx, "notification.GetUserWorkflowEvents> unable to handle event %+v: %v", jn, err)
89-
}
90-
events = append(events, notif)
91-
9260
case sdk.EmailUserNotification:
9361
jn := &notif.Settings
9462
//Get recipents from groups
9563
if jn.SendToGroups != nil && *jn.SendToGroups {
9664
u, err := projectPermissionUserIDs(ctx, db, store, projectID, sdk.PermissionRead)
9765
if err != nil {
98-
log.Error(ctx, "notification[Email].GetUserWorkflowEvents> error while loading permission: %v", err)
66+
log.Error(ctx, "error while loading permission: %v", err)
9967
return nil
10068
}
10169
contacts, err := user.LoadContactsByUserIDs(ctx, db, u)
10270
if err != nil {
103-
log.Error(ctx, "notification[Jabber]. error while loading users contacts: %v", err)
71+
log.Error(ctx, "error while loading users contacts: %v", err)
10472
break
10573
}
10674
for _, c := range contacts {

engine/api/workflow/dao_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ func TestInsertComplexeWorkflowWithComplexeJoins(t *testing.T) {
11581158
},
11591159
Notifications: []sdk.WorkflowNotification{
11601160
{
1161-
Type: "jabber",
1161+
Type: "email",
11621162
SourceNodeRefs: []string{"pip6", "pip5"},
11631163
Settings: sdk.UserNotificationSettings{
11641164
OnFailure: sdk.UserNotificationAlways,

engine/api/workflow_ascode_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ metadata:
717717
default_tags: tag_version,git.branch,git.author
718718
notifications:
719719
- type: vcs
720-
- type: jabber
720+
- type: email
721721
pipelines:
722722
- playbook-game-stuff
723723
- playbook-game-molecule
@@ -732,7 +732,7 @@ notifications:
732732
{{.cds.status}}'
733733
body: |
734734
{{.cds.buildURL}}
735-
- type: jabber
735+
- type: email
736736
pipelines:
737737
- notify
738738
settings:
@@ -748,7 +748,7 @@ notifications:
748748
- variable: git.branch
749749
operator: eq
750750
value: master
751-
- type: jabber
751+
- type: email
752752
pipelines:
753753
- notify
754754
settings:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- +migrate Up
2+
delete from workflow_notification where type = 'jabber';
3+
4+
-- +migrate Down
5+
SELECT 1;

sdk/exportentities/v1/workflow_notif_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package v1_test
22

33
import (
4-
v1 "github.com/ovh/cds/sdk/exportentities/v1"
54
"reflect"
65
"testing"
76

7+
v1 "github.com/ovh/cds/sdk/exportentities/v1"
8+
89
"github.com/ovh/cds/engine/api/test"
910
"github.com/ovh/cds/sdk"
1011
yaml "gopkg.in/yaml.v2"
@@ -48,7 +49,7 @@ metadata:
4849
default_tags: git.branch,git.author
4950
notifications:
5051
DDOS-me,DDOS-me_2:
51-
- type: jabber
52+
- type: email
5253
settings:
5354
on_success: always
5455
on_failure: change

sdk/exportentities/v2/workflow_notif_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ workflow:
5252
metadata:
5353
default_tags: git.branch,git.author
5454
notifications:
55-
- type: jabber
55+
- type: email
5656
pipelines:
5757
- DDOS-me
5858
- DDOS-me_2
@@ -158,7 +158,7 @@ workflow:
158158
- success
159159
pipeline: test
160160
notifications:
161-
- type: jabber
161+
- type: email
162162
pipelines:
163163
- test
164164
- test_2
@@ -198,7 +198,7 @@ notifications:
198198
Details : {{.cds.buildURL}}
199199
Triggered by : {{.cds.triggered_by.username}}
200200
Branch : {{.git.branch}}
201-
- type: jabber
201+
- type: email
202202
pipelines:
203203
- test
204204
- test_2
@@ -231,7 +231,7 @@ workflow:
231231
- success
232232
pipeline: test
233233
notifications:
234-
- type: jabber
234+
- type: email
235235
- type: event
236236
integration: my-integration
237237
`,

sdk/notif.go

+5-12
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ import (
1313

1414
//const
1515
const (
16-
EmailUserNotification = "email"
17-
JabberUserNotification = "jabber"
18-
VCSUserNotification = "vcs"
19-
EventsNotification = "event"
16+
EmailUserNotification = "email"
17+
VCSUserNotification = "vcs"
18+
EventsNotification = "event"
2019
)
2120

2221
//const
@@ -35,7 +34,7 @@ type UserNotification struct {
3534
Notifications map[string]UserNotificationSettings `json:"notifications"`
3635
}
3736

38-
// UserNotificationSettings are jabber or email settings
37+
// UserNotificationSettings --> email settings
3938
type UserNotificationSettings struct {
4039
OnSuccess string `json:"on_success,omitempty" yaml:"on_success,omitempty"` // default is "onChange", empty means onChange
4140
OnFailure string `json:"on_failure,omitempty" yaml:"on_failure,omitempty"` // default is "always", empty means always
@@ -96,14 +95,8 @@ Triggered by : {{.cds.triggered_by.username}}
9695
Branch : {{.git.branch | default "n/a"}}`,
9796
}
9897

99-
UserNotificationTemplateJabber = UserNotificationTemplate{
100-
Subject: "{{.cds.project}}/{{.cds.workflow}}#{{.cds.version}} {{.cds.status}}",
101-
Body: `{{.cds.buildURL}}`,
102-
}
103-
10498
UserNotificationTemplateMap = map[string]UserNotificationTemplate{
105-
EmailUserNotification: UserNotificationTemplateEmail,
106-
JabberUserNotification: UserNotificationTemplateJabber,
99+
EmailUserNotification: UserNotificationTemplateEmail,
107100
VCSUserNotification: {
108101
Body: DefaultWorkflowNodeRunReport,
109102
},

ui/src/app/model/workflow.model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ export class WorkflowPull {
687687
environments: Array<string>;
688688
}
689689

690-
export const notificationTypes = ['jabber', 'email', 'vcs'];
690+
export const notificationTypes = ['email', 'vcs'];
691691
export const notificationOnSuccess = ['always', 'change', 'never'];
692692
export const notificationOnFailure = ['always', 'change', 'never'];
693693

ui/src/app/views/workflow/show/notification/form/workflow.notifications.form.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
[readonly]="true">
3030
</div>
3131
</div>
32-
<ng-container *ngIf="notification.type === 'jabber' || notification.type === 'email'">
32+
<ng-container *ngIf="notification.type === 'email'">
3333
<div class="three fields">
3434
<div class="six wide field">
3535
<label>{{ 'workflow_notification_on_success' | translate}}</label>
@@ -64,8 +64,6 @@
6464
</div>
6565
<div class="three fields">
6666
<div class="eight wide field">
67-
<label
68-
*ngIf="notification.type === 'jabber'">{{ 'workflow_notification_jabber_user' | translate}}</label>
6967
<label
7068
*ngIf="notification.type === 'email'">{{ 'workflow_notification_email_user' | translate}}</label>
7169
<input type="text" name="users" [(ngModel)]="selectedUsers" [readonly]="readOnly">

ui/src/assets/i18n/en.json

-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@
855855
"workflow_notification_body": "Message",
856856
"workflow_notification_to_group": "Send to group",
857857
"workflow_notification_to_initiator": "Send to initiator",
858-
"workflow_notification_jabber_user": "Jabber users",
859858
"workflow_notification_email_user": "Mails",
860859
"workflow_notification_form": "Add a notification",
861860
"workflow_notification_copy": "Copy",

0 commit comments

Comments
 (0)