@ -46,8 +46,7 @@ class Bark extends NotificationProvider {
}
}
/ * *
/ * *
* Add additional parameter for better on device styles ( iOS 15
* Add additional parameter for Bark v1 endpoints
* optimized )
* @ param { BeanModel } notification Notification to send
* @ param { BeanModel } notification Notification to send
* @ param { string } postUrl URL to append parameters to
* @ param { string } postUrl URL to append parameters to
* @ returns { string } Additional URL parameters
* @ returns { string } Additional URL parameters
@ -96,12 +95,23 @@ class Bark extends NotificationProvider {
* @ returns { string } Success message
* @ returns { string } Success message
* /
* /
async postNotification ( notification , title , subtitle , endpoint ) {
async postNotification ( notification , title , subtitle , endpoint ) {
// url encode title and subtitle
let result ;
title = encodeURIComponent ( title ) ;
if ( notification . apiVersion === "v1" || notification . apiVersion == null ) {
subtitle = encodeURIComponent ( subtitle ) ;
// url encode title and subtitle
let postUrl = endpoint + "/" + title + "/" + subtitle ;
title = encodeURIComponent ( title ) ;
postUrl = this . appendAdditionalParameters ( notification , postUrl ) ;
subtitle = encodeURIComponent ( subtitle ) ;
let result = await axios . get ( postUrl ) ;
let postUrl = endpoint + "/" + title + "/" + subtitle ;
postUrl = this . appendAdditionalParameters ( notification , postUrl ) ;
result = await axios . get ( postUrl ) ;
} else {
result = await axios . post ( ` ${ endpoint } /push ` , {
title ,
body : subtitle ,
icon : barkNotificationAvatar ,
sound : notification . barkSound || "telegraph" , // default sound is telegraph
group : notification . barkGroup || "UptimeKuma" , // default group is UptimeKuma
} ) ;
}
this . checkResult ( result ) ;
this . checkResult ( result ) ;
if ( result . statusText != null ) {
if ( result . statusText != null ) {
return "Bark notification succeed: " + result . statusText ;
return "Bark notification succeed: " + result . statusText ;