Add priority to gotify channel

Closes: #1277
This commit is contained in:
eikek
2022-01-12 20:59:07 +01:00
parent 5f10798e86
commit 7aebc1ccdf
15 changed files with 118 additions and 38 deletions

View File

@ -5523,6 +5523,11 @@ components:
appKey:
type: string
format: password
priority:
type: integer
format: int32
description: |
A priority number [0-10]
NotificationHttp:
description: |
A notification channel for receiving a generic http request.

View File

@ -74,7 +74,8 @@ object NotificationChannel {
.flatMap(_.toRight("No recipients given!"))
.leftMap(new IllegalArgumentException(_))
.map(rec => Channel.Mail(mail.id, mail.connection, rec)),
gotify => Right(Channel.Gotify(gotify.id, gotify.url, gotify.appKey)),
gotify =>
Right(Channel.Gotify(gotify.id, gotify.url, gotify.appKey, gotify.priority)),
matrix =>
Right(
Channel
@ -94,7 +95,8 @@ object NotificationChannel {
m.recipients.toList.map(_.displayString)
)
},
g => gotify(NotificationGotify(g.id, ChannelType.Gotify, g.url, g.appKey)),
g =>
gotify(NotificationGotify(g.id, ChannelType.Gotify, g.url, g.appKey, g.priority)),
m =>
matrix(
NotificationMatrix(

View File

@ -53,7 +53,34 @@ class NotificationCodecTest extends FunSuite {
id(""),
ChannelType.Gotify,
LenientUri.unsafe("http://test.gotify.com"),
Password("abcde")
Password("abcde"),
None
)
)
)
)
}
test("decode with gotify data with prio") {
val json = """{"id":"",
"enabled": true,
"channel": {"id":"", "channelType":"gotify", "url":"http://test.gotify.com", "appKey": "abcde", "priority":9},
"allEvents": false,
"eventFilter": null,
"events": ["TagsChanged", "SetFieldValue"]
}"""
val hook = parse[NotificationHook](json)
assertEquals(hook.enabled, true)
assertEquals(
hook.channel,
Right(
NotificationChannel.Gotify(
NotificationGotify(
id(""),
ChannelType.Gotify,
LenientUri.unsafe("http://test.gotify.com"),
Password("abcde"),
Some(9)
)
)
)