broke apprise notification function into its own module to be used by multiple scripts
Security / security (push) Successful in 58s
Security / security (push) Successful in 58s
This commit is contained in:
@@ -1,40 +1,8 @@
|
||||
[string] $dtHost = $ENV:DONETICKHOST
|
||||
[string] $dtPort = $ENV:DONETICKPORT
|
||||
[string] $dtAPIKey = $ENV:DONETICKAPIKEY
|
||||
[string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL
|
||||
[string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG
|
||||
|
||||
|
||||
function Send-Notification
|
||||
{
|
||||
param(
|
||||
# Title of the notification
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$title,
|
||||
|
||||
# Content of the notification
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$content
|
||||
)
|
||||
|
||||
$headers = @{
|
||||
"Content-Type"="application/json"
|
||||
}
|
||||
$body = @{
|
||||
title=$title
|
||||
body=$content
|
||||
tags="$appriseWebhookTag"
|
||||
}
|
||||
$json = $body | ConvertTo-Json
|
||||
try {
|
||||
Invoke-WebRequest -URI $appriseWebhookURL -Method post -Body $json -Headers $headers
|
||||
}
|
||||
catch {
|
||||
Write-Host "Notification Error Encountered: $($global:Error[0])"
|
||||
}
|
||||
}
|
||||
Import-Module ./AppriseNotification.psm1
|
||||
|
||||
function Get-Chores
|
||||
{
|
||||
@@ -70,7 +38,6 @@ foreach($chore in $chores)
|
||||
{
|
||||
write-host "$($chore.name) $dueDate is due today!"
|
||||
$todaysTasks += $chore
|
||||
# Send-Notification -title "TASK DUE TODAY" -content "$($chore.Name) is due today!"
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -88,7 +55,7 @@ if ($overdueTasks.Count -ne 0)
|
||||
{
|
||||
$content += "$($overdueTask.Name) was due $((Get-Date $overdueTask.nextDueDate).ToLocalTime())`n"
|
||||
}
|
||||
Send-Notification -title "OVERDUE TASKS" -content $content
|
||||
Send-AppriseNotification -title "OVERDUE TASKS" -content $content
|
||||
}
|
||||
|
||||
if ($todaysTasks.Count -ne 0)
|
||||
@@ -99,5 +66,5 @@ if ($todaysTasks.Count -ne 0)
|
||||
{
|
||||
$content += "$($task.Name) is due $((Get-Date $task.nextDueDate).ToLocalTime())`n"
|
||||
}
|
||||
Send-Notification -title "TODAY'S TASKS" -content $content
|
||||
Send-AppriseNotification -title "TODAY'S TASKS" -content $content
|
||||
}
|
||||
Reference in New Issue
Block a user