diff --git a/Winget-AutoUpdate/functions/Get-AppInfo.ps1 b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 new file mode 100644 index 0000000..247b917 --- /dev/null +++ b/Winget-AutoUpdate/functions/Get-AppInfo.ps1 @@ -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 +} \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 index 0ee572a..1d1b862 100644 --- a/Winget-AutoUpdate/functions/Start-NotifTask.ps1 +++ b/Winget-AutoUpdate/functions/Start-NotifTask.ps1 @@ -1,12 +1,17 @@ #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")) { + #Prepare OnClickAction (if set) + if ($OnClickAction){ + $ToastOnClickAction = "activationType='protocol' launch='$OnClickAction'" + } + #Add XML variables [xml]$ToastTemplate = @" - + $Title diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 31ee6fd..9c1f2bd 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -2,13 +2,16 @@ Function Update-App ($app) { + #Get App Info + $OnClickAction = Get-AppInfo $app.Id + #Send available update notification Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" $Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name) $Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion) $MessageType = "info" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction #Winget upgrade 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) $MessageType = "success" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction $Script:InstallOK += 1 @@ -77,7 +80,7 @@ Function Update-App ($app) { $Message = $NotifLocale.local.outputs.output[4].message $MessageType = "error" $Balise = $($app.Name) - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction } diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 0f2008e..25e43bd 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -2,12 +2,14 @@ function Update-WAU { + $OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases" + #Send available update notification $Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion $MessageType = "info" $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction #Run WAU update try { @@ -52,7 +54,7 @@ function Update-WAU { $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $MessageType = "success" $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction #Rerun with newer version Write-Log "Re-run WAU" @@ -69,7 +71,7 @@ function Update-WAU { $Message = $NotifLocale.local.outputs.output[4].message $MessageType = "error" $Balise = "Winget-AutoUpdate" - Start-NotifTask $Title $Message $MessageType $Balise + Start-NotifTask $Title $Message $MessageType $Balise $OnClickAction Write-Log "WAU Update failed" "Red" }