Add a name to notification channels

This name is supposed to be used by users to distinguish multiple channels.
This commit is contained in:
eikek
2022-01-17 14:15:07 +01:00
parent 44e599dc86
commit d41490dd88
13 changed files with 140 additions and 40 deletions

View File

@ -5491,6 +5491,8 @@ components:
id:
type: string
format: ident
name:
type: string
channelType:
type: string
format: channeltype
@ -5514,6 +5516,8 @@ components:
id:
type: string
format: ident
name:
type: string
channelType:
type: string
format: channeltype
@ -5539,6 +5543,8 @@ components:
id:
type: string
format: ident
name:
type: string
channelType:
type: string
format: channeltype
@ -5557,6 +5563,8 @@ components:
id:
type: string
format: ident
name:
type: string
channelType:
type: string
format: channeltype

View File

@ -73,15 +73,24 @@ object NotificationChannel {
.map(NonEmptyList.fromList)
.flatMap(_.toRight("No recipients given!"))
.leftMap(new IllegalArgumentException(_))
.map(rec => Channel.Mail(mail.id, mail.connection, rec)),
.map(rec => Channel.Mail(mail.id, mail.name, mail.connection, rec)),
gotify =>
Right(Channel.Gotify(gotify.id, gotify.url, gotify.appKey, gotify.priority)),
Right(
Channel
.Gotify(gotify.id, gotify.name, gotify.url, gotify.appKey, gotify.priority)
),
matrix =>
Right(
Channel
.Matrix(matrix.id, matrix.homeServer, matrix.roomId, matrix.accessToken)
.Matrix(
matrix.id,
matrix.name,
matrix.homeServer,
matrix.roomId,
matrix.accessToken
)
),
http => Right(Channel.Http(http.id, http.url))
http => Right(Channel.Http(http.id, http.name, http.url))
)
def convert(c: Channel): NotificationChannel =
@ -90,24 +99,35 @@ object NotificationChannel {
mail {
NotificationMail(
m.id,
m.name,
ChannelType.Mail,
m.connection,
m.recipients.toList.map(_.displayString)
)
},
g =>
gotify(NotificationGotify(g.id, ChannelType.Gotify, g.url, g.appKey, g.priority)),
gotify(
NotificationGotify(
g.id,
g.name,
ChannelType.Gotify,
g.url,
g.appKey,
g.priority
)
),
m =>
matrix(
NotificationMatrix(
m.id,
m.name,
ChannelType.Matrix,
m.homeServer,
m.roomId,
m.accessToken
)
),
h => http(NotificationHttp(h.id, ChannelType.Http, h.url))
h => http(NotificationHttp(h.id, h.name, ChannelType.Http, h.url))
)
implicit val jsonDecoder: Decoder[NotificationChannel] =