Skip to content

Commit 5915919

Browse files
authored
Add slack message support to service (#12) (#13)
* Add slack message support to service (#12) * Update mail test with new name for recipient * Add slack api key to helm chart * Bump helm chart version
1 parent 7aa8d5b commit 5915919

File tree

12 files changed

+199
-140
lines changed

12 files changed

+199
-140
lines changed

.openapi-generator/FILES

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ internal/server/api_notification.go
88
internal/server/api_notification_service.go
99
internal/server/helpers.go
1010
internal/server/impl.go
11+
internal/server/model_email_recipient.go
12+
internal/server/model_email_sender.go
1113
internal/server/model_error.go
1214
internal/server/model_mail_message.go
13-
internal/server/model_notification_message.go
14-
internal/server/model_recipient.go
1515
internal/server/model_send_bulk_mail_request.go
1616
internal/server/model_send_bulk_mail_response.go
1717
internal/server/model_send_bulk_mail_response_failed.go
1818
internal/server/model_send_bulk_mail_response_successful.go
1919
internal/server/model_send_mail_request.go
2020
internal/server/model_send_mail_response.go
21-
internal/server/model_send_notification_response.go
22-
internal/server/model_sender.go
23-
internal/server/model_subscribe_request.go
24-
internal/server/model_unsubscribe_request.go
21+
internal/server/model_send_slack_message_request.go
22+
internal/server/model_send_slack_message_response.go
23+
internal/server/model_slack_message.go
24+
internal/server/model_slack_recipient.go
2525
internal/server/routers.go

api/notification-service.yaml

Lines changed: 131 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ paths:
7474
schema:
7575
$ref: '#/components/schemas/Error'
7676

77-
78-
/notification/send:
77+
/notification/slack/send:
7978
post:
80-
summary: Send a notification
81-
operationId: sendNotification
79+
summary: Send a Slack message
80+
operationId: sendSlackNotification
8281
tags:
8382
- notification
8483
requestBody:
@@ -87,79 +86,106 @@ paths:
8786
content:
8887
application/json:
8988
schema:
90-
$ref: '#/components/schemas/NotificationMessage'
89+
$ref: '#/components/schemas/SendSlackMessageRequest'
9190
responses:
9291
200:
9392
description: OK
9493
content:
9594
application/json:
9695
schema:
97-
$ref: '#/components/schemas/SendNotificationResponse'
96+
$ref: '#/components/schemas/SendSlackMessageResponse'
9897
default:
9998
description: unexpected error
10099
content:
101100
application/json:
102101
schema:
103102
$ref: '#/components/schemas/Error'
104103

105-
/notification/subscribe:
106-
post:
107-
summary: Subscribe to notifications
108-
operationId: notificationSubscribe
109-
tags:
110-
- notification
111-
requestBody:
112-
description: Parameters of the subscription
113-
required: true
114-
content:
115-
application/json:
116-
schema:
117-
$ref: '#/components/schemas/SubscribeRequest'
118-
responses:
119-
200:
120-
description: OK
121-
content:
122-
application/json:
123-
schema:
124-
type: string
125-
default:
126-
description: unexpected error
127-
content:
128-
application/json:
129-
schema:
130-
$ref: '#/components/schemas/Error'
104+
# /notification/send:
105+
# post:
106+
# summary: Send a notification
107+
# operationId: sendNotification
108+
# tags:
109+
# - notification
110+
# requestBody:
111+
# description: Parameters of the message to send
112+
# required: true
113+
# content:
114+
# application/json:
115+
# schema:
116+
# $ref: '#/components/schemas/SendNotificationRequest'
117+
# responses:
118+
# 200:
119+
# description: OK
120+
# content:
121+
# application/json:
122+
# schema:
123+
# $ref: '#/components/schemas/SendNotificationResponse'
124+
# default:
125+
# description: unexpected error
126+
# content:
127+
# application/json:
128+
# schema:
129+
# $ref: '#/components/schemas/Error'
131130

132-
/notification/unsubscribe:
133-
post:
134-
summary: Unsubscribe to notifications
135-
operationId: notificationUnsubscribe
136-
tags:
137-
- notification
138-
requestBody:
139-
description: Parameters of the unsubscription
140-
required: true
141-
content:
142-
application/json:
143-
schema:
144-
$ref: '#/components/schemas/SubscribeRequest'
145-
responses:
146-
200:
147-
description: OK
148-
content:
149-
application/json:
150-
schema:
151-
type: string
152-
default:
153-
description: unexpected error
154-
content:
155-
application/json:
156-
schema:
157-
$ref: '#/components/schemas/Error'
131+
# /notification/subscribe:
132+
# post:
133+
# summary: Subscribe to notifications
134+
# operationId: notificationSubscribe
135+
# tags:
136+
# - notification
137+
# requestBody:
138+
# description: Parameters of the subscription
139+
# required: true
140+
# content:
141+
# application/json:
142+
# schema:
143+
# $ref: '#/components/schemas/SubscribeRequest'
144+
# responses:
145+
# 200:
146+
# description: OK
147+
# content:
148+
# application/json:
149+
# schema:
150+
# type: string
151+
# default:
152+
# description: unexpected error
153+
# content:
154+
# application/json:
155+
# schema:
156+
# $ref: '#/components/schemas/Error'
157+
158+
# /notification/unsubscribe:
159+
# post:
160+
# summary: Unsubscribe to notifications
161+
# operationId: notificationUnsubscribe
162+
# tags:
163+
# - notification
164+
# requestBody:
165+
# description: Parameters of the unsubscription
166+
# required: true
167+
# content:
168+
# application/json:
169+
# schema:
170+
# $ref: '#/components/schemas/SubscribeRequest'
171+
# responses:
172+
# 200:
173+
# description: OK
174+
# content:
175+
# application/json:
176+
# schema:
177+
# type: string
178+
# default:
179+
# description: unexpected error
180+
# content:
181+
# application/json:
182+
# schema:
183+
# $ref: '#/components/schemas/Error'
158184

159185
components:
160186
schemas:
161187

162-
Recipient:
188+
EmailRecipient:
163189
type: object
164190
required:
165191
- name
@@ -170,7 +196,7 @@ components:
170196
address:
171197
type: string
172198

173-
Sender:
199+
EmailSender:
174200
type: object
175201
required:
176202
- name
@@ -188,9 +214,9 @@ components:
188214
- from
189215
properties:
190216
to:
191-
$ref: '#/components/schemas/Recipient'
217+
$ref: '#/components/schemas/EmailRecipient'
192218
from:
193-
$ref: '#/components/schemas/Sender'
219+
$ref: '#/components/schemas/EmailSender'
194220
message:
195221
$ref: '#/components/schemas/MailMessage'
196222

@@ -203,9 +229,9 @@ components:
203229
toAddresses:
204230
type: array
205231
items:
206-
$ref: '#/components/schemas/Recipient'
232+
$ref: '#/components/schemas/EmailRecipient'
207233
from:
208-
$ref: '#/components/schemas/Sender'
234+
$ref: '#/components/schemas/EmailSender'
209235
message:
210236
$ref: '#/components/schemas/MailMessage'
211237

@@ -228,36 +254,40 @@ components:
228254
description: Schedule these mesages to go out at the time specified by this UNIX timestamp
229255
format: int64
230256

231-
NotificationMessage:
257+
SlackRecipient:
232258
type: object
233259
required:
234-
- to
235-
- subject
260+
- conversationId
236261
properties:
237-
to:
238-
$ref: '#/components/schemas/Recipient'
239-
subject:
262+
conversationId:
240263
type: string
264+
description: The id of the channel or user to send the message to
265+
266+
SlackMessage:
267+
type: object
268+
properties:
241269
body:
242270
type: string
243-
templateId:
244-
type: string
271+
description: The body of the message to send
245272

246-
SubscribeRequest:
273+
SendSlackMessageRequest:
247274
type: object
275+
required:
276+
- to
277+
- message
248278
properties:
249-
topicId:
279+
to:
280+
$ref: '#/components/schemas/SlackRecipient'
281+
message:
282+
$ref: '#/components/schemas/SlackMessage'
283+
replyToTimestamp:
250284
type: string
251-
required:
252-
- topicId
253285

254-
UnsubscribeRequest:
286+
SendSlackMessageResponse:
255287
type: object
256288
properties:
257-
topicId:
289+
timestamp:
258290
type: string
259-
required:
260-
- topicId
261291

262292
SendMailResponse:
263293
type: object
@@ -292,11 +322,27 @@ components:
292322
type: string
293323
description: Error or response message returned by the mail provider
294324

295-
SendNotificationResponse:
296-
type: object
297-
properties:
298-
trackingId:
299-
type: string
325+
# SendNotificationResponse:
326+
# type: object
327+
# properties:
328+
# trackingId:
329+
# type: string
330+
331+
# SubscribeRequest:
332+
# type: object
333+
# properties:
334+
# topicId:
335+
# type: string
336+
# required:
337+
# - topicId
338+
339+
# UnsubscribeRequest:
340+
# type: object
341+
# properties:
342+
# topicId:
343+
# type: string
344+
# required:
345+
# - topicId
300346

301347
Error:
302348
type: object

charts/zero-notifcation-service/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.0.4
18+
version: 0.0.5
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
23-
appVersion: 0.0.4
23+
appVersion: 0.0.5

charts/zero-notifcation-service/templates/secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ data:
66
type: Opaque
77
data:
88
SENDGRID_API_KEY: {{ .Values.application.sendgridApiKey | b64enc | quote }}
9+
SLACK_API_KEY: {{ .Values.application.slackApiKey | b64enc | quote }}

charts/zero-notifcation-service/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ affinity: {}
7979

8080
application:
8181
sendgridApiKey:
82+
slackApiKey:
8283
gracefulShutdownTimeout: 10
8384
structuredLogging: true

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ require (
77
github.com/pkg/errors v0.9.1 // indirect
88
github.com/sendgrid/rest v2.6.2+incompatible
99
github.com/sendgrid/sendgrid-go v3.7.2+incompatible
10+
github.com/slack-go/slack v0.8.0
1011
github.com/spf13/viper v1.7.1
1112
github.com/stretchr/testify v1.4.0
1213
go.uber.org/multierr v1.6.0 // indirect
1314
go.uber.org/zap v1.16.0
14-
golang.org/x/tools v0.0.0-20201208002638-66f931576d67 // indirect
15+
golang.org/x/tools v0.1.0 // indirect
1516
)

0 commit comments

Comments
 (0)