@@ -214,9 +214,13 @@ data ChatProvider
214
214
215
215
-- A type to unify slack and discord message types
216
216
data MessageContent (provider :: ChatProvider ) = MessageContent
217
- { -- | The content of the primary message.
218
- content :: Text ,
217
+ { -- Text of the bot message
218
+ preText :: Text ,
219
+ -- Title of the attachment
219
220
title :: Text ,
221
+ -- Text of the attachment
222
+ content :: Text ,
223
+ -- Title link
220
224
mainLink :: URI ,
221
225
authorName :: Text ,
222
226
authorLink :: URI ,
@@ -227,9 +231,9 @@ data MessageContent (provider :: ChatProvider) = MessageContent
227
231
deriving stock (Show , Eq )
228
232
229
233
instance ToJSON (MessageContent 'Slack) where
230
- toJSON MessageContent {content, title, mainLink, authorName, authorLink, authorAvatarUrl, thumbnailUrl, timestamp} =
234
+ toJSON MessageContent {preText, content, title, mainLink, authorName, authorLink, authorAvatarUrl, thumbnailUrl, timestamp} =
231
235
Aeson. object
232
- [ " text" .= content ,
236
+ [ " text" .= preText ,
233
237
" attachments"
234
238
.= [ Aeson. object
235
239
[ " title" .= title,
@@ -246,11 +250,11 @@ instance ToJSON (MessageContent 'Slack) where
246
250
]
247
251
248
252
instance ToJSON (MessageContent 'Discord) where
249
- toJSON MessageContent {content, title, mainLink, authorName, authorLink, authorAvatarUrl, thumbnailUrl, timestamp} =
253
+ toJSON MessageContent {preText, content, title, mainLink, authorName, authorLink, authorAvatarUrl, thumbnailUrl, timestamp} =
250
254
Aeson. object
251
255
[ " username" .= (" Share Notification" :: Text ),
252
256
" avatar_url" .= Links. unisonLogoImage,
253
- " content" .= content ,
257
+ " content" .= preText ,
254
258
" embeds"
255
259
.= [ Aeson. object
256
260
[ " title" .= title,
@@ -266,9 +270,9 @@ instance ToJSON (MessageContent 'Discord) where
266
270
buildWebhookRequest :: NotificationWebhookId -> URI -> NotificationEvent NotificationEventId UnifiedDisplayInfo UTCTime HydratedEventPayload -> WebhookEventPayload JWTParam -> Background (Either WebhookSendFailure HTTPClient. Request )
267
271
buildWebhookRequest webhookId uri event defaultPayload = do
268
272
if
269
- | isSlackWebhook uri -> buildChatAppPayload (Proxy @ Slack ) uri
270
- | isDiscordWebhook uri -> buildChatAppPayload (Proxy @ Discord ) uri
271
- | otherwise -> pure $ buildDefaultPayload
273
+ | isSlackWebhook uri -> buildChatAppPayload (Proxy @ Slack ) uri
274
+ | isDiscordWebhook uri -> buildChatAppPayload (Proxy @ Discord ) uri
275
+ | otherwise -> pure $ buildDefaultPayload
272
276
where
273
277
isSlackWebhook :: URI -> Bool
274
278
isSlackWebhook uri =
@@ -311,7 +315,8 @@ buildWebhookRequest webhookId uri event defaultPayload = do
311
315
link <- Links. notificationLink event. eventData
312
316
pure $
313
317
MessageContent
314
- { content = preText,
318
+ { preText = preText,
319
+ content = " Branch updated" ,
315
320
title = title,
316
321
mainLink = link,
317
322
authorName = actorAuthor,
@@ -323,11 +328,13 @@ buildWebhookRequest webhookId uri event defaultPayload = do
323
328
HydratedProjectContributionCreatedPayload payload -> do
324
329
let pbShorthand = (projectBranchShortHandFromParts payload. projectInfo. projectShortHand payload. contributionInfo. contributionSourceBranch. branchShortHand)
325
330
title = payload. contributionInfo. contributionTitle
331
+ description = fromMaybe " " $ payload. contributionInfo. contributionDescription
326
332
preText = " New Contribution in " <> IDs. toText pbShorthand
327
333
link <- Links. notificationLink event. eventData
328
334
pure $
329
335
MessageContent
330
- { content = preText,
336
+ { preText = preText,
337
+ content = description,
331
338
title = title,
332
339
mainLink = link,
333
340
authorName = actorAuthor,
0 commit comments