Merge pull request #118 from Romanitho/dev

Added App changelog link on notification click
pull/119/head
Romain 2022-07-05 17:40:57 +02:00 committed by GitHub
commit 5652a5eaea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 8 deletions

View File

@ -0,0 +1,12 @@
#Get App Info
Function Get-AppInfo ($AppID) {
#Get AppID Info
$String = & $winget show $AppID --accept-source-agreements -s winget | Out-String
#Search for Release Note info
$ReleaseNote = [regex]::match($String,"(?<=Release Notes Url: )(.*)(?=\n)").Groups[0].Value
#Return Release Note
return $ReleaseNote
}

View File

@ -1,12 +1,17 @@
#Function to send notifications to user #Function to send notifications to user
function Start-NotifTask ($Title, $Message, $MessageType, $Balise) { function Start-NotifTask ($Title, $Message, $MessageType, $Balise, $OnClickAction) {
if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) { if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success")) {
#Prepare OnClickAction (if set)
if ($OnClickAction){
$ToastOnClickAction = "activationType='protocol' launch='$OnClickAction'"
}
#Add XML variables #Add XML variables
[xml]$ToastTemplate = @" [xml]$ToastTemplate = @"
<toast launch="ms-get-started://redirect?id=apps_action"> <toast $ToastOnClickAction>
<visual> <visual>
<binding template="ToastImageAndText03"> <binding template="ToastImageAndText03">
<text id="1">$Title</text> <text id="1">$Title</text>

View File

@ -2,13 +2,16 @@
Function Update-App ($app) { Function Update-App ($app) {
#Get App Info
$OnClickAction = Get-AppInfo $app.Id
#Send available update notification #Send available update notification
Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan"
$Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name) $Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name)
$Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion) $Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion)
$MessageType = "info" $MessageType = "info"
$Balise = $($app.Name) $Balise = $($app.Name)
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
#Winget upgrade #Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
@ -62,7 +65,7 @@ Function Update-App ($app) {
$Message = $NotifLocale.local.outputs.output[3].message -f $($app.AvailableVersion) $Message = $NotifLocale.local.outputs.output[3].message -f $($app.AvailableVersion)
$MessageType = "success" $MessageType = "success"
$Balise = $($app.Name) $Balise = $($app.Name)
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
$Script:InstallOK += 1 $Script:InstallOK += 1
@ -77,7 +80,7 @@ Function Update-App ($app) {
$Message = $NotifLocale.local.outputs.output[4].message $Message = $NotifLocale.local.outputs.output[4].message
$MessageType = "error" $MessageType = "error"
$Balise = $($app.Name) $Balise = $($app.Name)
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
} }

View File

@ -2,12 +2,14 @@
function Update-WAU { function Update-WAU {
$OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases"
#Send available update notification #Send available update notification
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate" $Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
$Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion $Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion
$MessageType = "info" $MessageType = "info"
$Balise = "Winget-AutoUpdate" $Balise = "Winget-AutoUpdate"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
#Run WAU update #Run WAU update
try { try {
@ -52,7 +54,7 @@ function Update-WAU {
$Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion
$MessageType = "success" $MessageType = "success"
$Balise = "Winget-AutoUpdate" $Balise = "Winget-AutoUpdate"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
#Rerun with newer version #Rerun with newer version
Write-Log "Re-run WAU" Write-Log "Re-run WAU"
@ -69,7 +71,7 @@ function Update-WAU {
$Message = $NotifLocale.local.outputs.output[4].message $Message = $NotifLocale.local.outputs.output[4].message
$MessageType = "error" $MessageType = "error"
$Balise = "Winget-AutoUpdate" $Balise = "Winget-AutoUpdate"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction
Write-Log "WAU Update failed" "Red" Write-Log "WAU Update failed" "Red"
} }