Skip to content

Commit 375cff8

Browse files
Merge pull request KelvinTegelaar#1900 from Zacgoose/server-side-bookmarks
Feat: Server side bookmarks
2 parents 1d92069 + fae7c3f commit 375cff8

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ListUserSettings.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ function Invoke-ListUserSettings {
4343
Write-Warning "Failed to convert UserSpecificSettings JSON: $($_.Exception.Message)"
4444
}
4545

46+
# Get user bookmarks
47+
try {
48+
$UserBookmarks = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'UserBookmarks' and RowKey eq '$Username'"
49+
$UserBookmarks = $UserBookmarks.JSON | ConvertFrom-Json -Depth 10 -ErrorAction SilentlyContinue
50+
if ($UserBookmarks -and $UserBookmarks -isnot [System.Array]) {
51+
$UserBookmarks = @($UserBookmarks)
52+
}
53+
} catch {
54+
Write-Warning "Failed to convert UserBookmarks JSON: $($_.Exception.Message)"
55+
}
56+
4657
#Get branding settings
4758
if ($UserSettings) {
4859
$brandingTable = Get-CippTable -tablename 'Config'
@@ -56,6 +67,10 @@ function Invoke-ListUserSettings {
5667
$UserSettings | Add-Member -MemberType NoteProperty -Name 'UserSpecificSettings' -Value $UserSpecificSettings -Force | Out-Null
5768
}
5869

70+
if ($UserBookmarks) {
71+
$UserSettings | Add-Member -MemberType NoteProperty -Name 'UserBookmarks' -Value $UserBookmarks -Force | Out-Null
72+
}
73+
5974
$StatusCode = [HttpStatusCode]::OK
6075
$Results = $UserSettings
6176
} catch {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function Invoke-ExecUserBookmarks {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
.ROLE
6+
CIPP.Core.ReadWrite
7+
#>
8+
param($Request, $TriggerMetadata)
9+
try {
10+
$Bookmarks = $Request.Body.currentSettings.bookmarks
11+
if ($null -eq $Bookmarks) {
12+
$Bookmarks = @()
13+
} elseif ($Bookmarks -isnot [System.Array]) {
14+
$Bookmarks = @($Bookmarks)
15+
}
16+
17+
$object = $Bookmarks | ConvertTo-Json -Compress -Depth 10
18+
$Table = Get-CippTable -tablename 'UserSettings'
19+
$User = $Request.Body.user
20+
$Table.Force = $true
21+
Add-CIPPAzDataTableEntity @Table -Entity @{
22+
JSON = "$object"
23+
RowKey = "$User"
24+
PartitionKey = 'UserBookmarks'
25+
}
26+
$StatusCode = [HttpStatusCode]::OK
27+
$Results = [pscustomobject]@{'Results' = 'Successfully added user bookmarks' }
28+
} catch {
29+
$ErrorMsg = Get-NormalizedError -message $($_.Exception.Message)
30+
$Results = "Function Error: $ErrorMsg"
31+
$StatusCode = [HttpStatusCode]::BadRequest
32+
}
33+
return [HttpResponseContext]@{
34+
StatusCode = $StatusCode
35+
Body = @($Results)
36+
}
37+
38+
}

profile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ if (!$LastStartup -or $CurrentVersion -ne $LastStartup.Version) {
126126
$SwVersion.Stop()
127127
$Timings['VersionCheck'] = $SwVersion.Elapsed.TotalMilliseconds
128128

129-
Set-CIPPEnvVarBackup
130129
if ($env:AzureWebJobsStorage -ne 'UseDevelopmentStorage=true' -and $env:NonLocalHostAzurite -ne 'true') {
130+
Set-CIPPEnvVarBackup
131131
Set-CIPPOffloadFunctionTriggers
132132
}
133133

0 commit comments

Comments
 (0)