Skip to content

Commit 8b4fe49

Browse files
committed
add preset url filters
1 parent c3e68f9 commit 8b4fe49

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Modules/CIPPCore/Public/Entrypoints/Invoke-ListGraphExplorerPresets.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ Function Invoke-ListGraphExplorerPresets {
1212

1313
$APIName = $TriggerMetadata.FunctionName
1414
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15-
1615
$Username = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($request.headers.'x-ms-client-principal')) | ConvertFrom-Json).userDetails
17-
# Write to the Azure Functions log stream.
18-
Write-Host 'PowerShell HTTP trigger function processed a request.'
16+
1917
try {
2018
$Table = Get-CIPPTable -TableName 'GraphPresets'
2119
$Presets = Get-CIPPAzDataTableEntity @Table -Filter "Owner eq '$Username' or IsShared eq true" | Sort-Object -Property name
@@ -28,16 +26,21 @@ Function Invoke-ListGraphExplorerPresets {
2826
params = ConvertFrom-Json -InputObject $Preset.Params
2927
}
3028
}
29+
30+
if ($Request.Query.Endpoint) {
31+
$Endpoint = $Request.Query.Endpoint -replace '^/', ''
32+
$Results = $Results | Where-Object { $_.params.endpoint -eq $Endpoint }
33+
}
3134
} catch {
32-
$Presets = @()
35+
$Results = @()
3336
}
3437
# Associate values to output bindings by calling 'Push-OutputBinding'.
3538
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
3639
StatusCode = [HttpStatusCode]::OK
3740
Body = @{
3841
Results = @($Results)
3942
Metadata = @{
40-
Count = ($Presets | Measure-Object).Count
43+
Count = ($Results | Measure-Object).Count
4144
}
4245
}
4346
})

0 commit comments

Comments
 (0)