Skip to content

Commit

Permalink
extension updates
Browse files Browse the repository at this point in the history
install passpushposh v1.2.0 - thanks @adamburley
update pwpush extension to support pro accounts and branding
improve extension test

Co-Authored-By: Adam Burley <52085927+adamburley@users.noreply.github.com>
  • Loading branch information
JohnDuprey and adamburley committed Feb 6, 2025
1 parent a339077 commit 5d0a4d6
Show file tree
Hide file tree
Showing 11 changed files with 1,084 additions and 1,024 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Function Invoke-ExecExtensionMapping {
$TicketTypes = Get-HaloTicketType
$Body = @{'TicketTypes' = $TicketTypes }
}
'PWPushFields' {
$Accounts = Get-PwPushAccount
$Body = @{
'Accounts' = $Accounts
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Function Invoke-ExecExtensionTest {
$Payload = 'This is a test from CIPP'
$PasswordLink = New-PwPushLink -Payload $Payload
if ($PasswordLink) {
$Results = [pscustomobject]@{'Results' = 'Successfully generated PWPush'; 'Link' = $PasswordLink }
$Results = [pscustomobject]@{Results = @(@{'resultText' = 'Successfully generated PWPush, hit the Copy to Clipboard button to retrieve the test.'; 'copyField' = $PasswordLink; 'state' = 'success' }) }
} else {
$Results = [pscustomobject]@{'Results' = 'PWPush is not enabled' }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ function Invoke-ExecApiClient {
'Enabled' = $Request.Body.Enabled ?? $false
}
$Results = @{
text = "API Client created '$($Client.AppName)'"
copyField = $APIConfig.ApplicationSecret
severity = 'success'
resultText = "API Client created '$($Client.AppName)'"
copyField = $APIConfig.ApplicationSecret
state = 'success'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ Function Invoke-ListExtensionsConfig {
$Table = Get-CIPPTable -TableName Extensionsconfig
try {
$Body = (Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -Depth 10 -ErrorAction Stop
if ($Body.HaloPSA.TicketType -and !$Body.HaloPSA.TicketType.value) {
# translate ticket type to autocomplete format
Write-Information "Ticket Type: $($Body.HaloPSA.TicketType)"
$Types = Get-HaloTicketType
$Type = $Types | Where-Object { $_.id -eq $Body.HaloPSA.TicketType }
#Write-Information ($Type | ConvertTo-Json)
if ($Type) {
$Body.HaloPSA.TicketType = @{
label = $Type.name
value = $Type.id
}
}
}
} catch {
Write-Information (Get-CippException -Exception $_ | ConvertTo-Json)
$Body = @{}
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Expand Down
13 changes: 13 additions & 0 deletions Modules/CippExtensions/Public/PwPush/Get-PwPushAccount.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Get-PwPushAccount {
$Table = Get-CIPPTable -TableName Extensionsconfig
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).PWPush
if ($Configuration.Enabled -eq $true -and $Configuration.PWPushPro -eq $true) {
Set-PwPushConfig -Configuration $Configuration
Get-PushAccount
} else {
return @(@{
name = 'PWPush Pro is not enabled or configured. Make sure to save the configuration first.';
id = ''
})
}
}
1 change: 1 addition & 0 deletions Modules/CippExtensions/Public/PwPush/New-PwPushLink.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function New-PwPushLink {
if ($Configuration.ExpireAfterDays) { $PushParams.ExpireAfterDays = $Configuration.ExpireAfterDays }
if ($Configuration.ExpireAfterViews) { $PushParams.ExpireAfterViews = $Configuration.ExpireAfterViews }
if ($Configuration.DeletableByViewer) { $PushParams.DeletableByViewer = $Configuration.DeletableByViewer }
if ($Configuration.AccountId) { $PushParams.AccountId = $Configuration.AccountId.value }
try {
if ($PSCmdlet.ShouldProcess('Create a new PwPush link')) {
$Link = New-Push @PushParams
Expand Down
13 changes: 12 additions & 1 deletion Modules/CippExtensions/Public/PwPush/Set-PwPushConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,26 @@ function Set-PwPushConfig {
if ($Configuration.BaseUrl) {
$InitParams.BaseUrl = $Configuration.BaseUrl
}
if (![string]::IsNullOrEmpty($Configuration.EmailAddress)) {
if (![string]::IsNullOrEmpty($Configuration.EmailAddress) -or $Configuration.PWPushPro -eq $true) {
$ApiKey = Get-ExtensionAPIKey -Extension 'PWPush'

if (![string]::IsNullOrEmpty($ApiKey)) {
$InitParams.APIKey = $ApiKey
}
if (![string]::IsNullOrEmpty($Configuration.EmailAddress)) {
$InitParams.EmailAddress = $Configuration.EmailAddress
}
if ($Configuration.PWPushPro -eq $true) {
$InitParams.AccountType = 'Pro'
$InitParams.Remove('BaseUrl')
}
}
Write-Information ($InitParams | ConvertTo-Json)

$Module = Get-Module PassPushPosh -ListAvailable
Write-Host $Module.Version
if ($PSCmdlet.ShouldProcess('Initialize-PassPushPosh')) {
Initialize-PassPushPosh @InitParams
}
}

Loading

0 comments on commit 5d0a4d6

Please sign in to comment.