Files
filebrowser/backend/internal/sharedefaults/convert.go
T
+11 45a14bf2f2 Beta/v2.1.0 (#3046)
Signed-off-by: MichaIng <micha@dietpi.com>
Co-authored-by: Kevin B. <kurami32_kbm@proton.me>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Mattijs Bliek <mattijs@mattijsbliek.com>
Co-authored-by: GammelSami <39372285+GammelSami@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: yzxcj797 <54314860+yzxcj797@users.noreply.github.com>
Co-authored-by: yzxcj797 <yzxcj797@users.noreply.github.com>
Co-authored-by: DireMunchkin <dire.munchkin@proton.me>
Co-authored-by: Chris <39135018+Chri6s@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Aditya Raj Singh <github@adityaraj.com>
Co-authored-by: tbsagdic <86909795+tbsagdic@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Ethan Lee Qi Yang <pluscompanyhqDEPT@gmail.com>
Co-authored-by: Aditya Raj Singh <aditya@bncw.in>
Co-authored-by: MichaIng <micha@dietpi.com>
Co-authored-by: FandacqkaCorp <david@davidyloreto.com>
Co-authored-by: FandacqkaCorp <275647464+FandacqkaCorp@users.noreply.github.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: connorjfarrell <connorjfarrell@users.noreply.github.com>
2026-09-30 13:04:20 -05:00

90 lines
3.7 KiB
Go

package sharedefaults
import (
"github.com/gtsteffaniak/filebrowser/backend/internal/database/share"
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
)
// DefaultsToEditable converts defaults template to a share editable payload.
func DefaultsToEditable(d settings.ShareDefaults) share.ShareEditable {
return share.ShareEditable{
FrontendShareInfo: share.FrontendShareInfo{
ShareTheme: d.ShareTheme,
DisableAnonymous: d.DisableAnonymous,
DisableThumbnails: d.DisableThumbnails,
KeepAfterExpiration: d.KeepAfterExpiration,
ThemeColor: d.ThemeColor,
Title: d.Title,
Description: d.Description,
Favicon: d.Favicon,
QuickDownload: d.QuickDownload,
HideNavButtons: d.HideNavButtons,
DisableSidebar: d.DisableSidebar,
DisableShareCard: d.DisableShareCard,
EnforceDarkLightMode: d.EnforceDarkLightMode,
ViewMode: d.ViewMode,
EnableOnlyOffice: d.EnableOnlyOffice,
ShareType: d.ShareType,
AllowDelete: d.AllowDelete,
AllowCreate: d.AllowCreate,
AllowModify: d.AllowModify,
DisableFileViewer: d.DisableFileViewer,
DisableDownload: d.DisableDownload,
AllowReplacements: d.AllowReplacements,
SidebarLinks: append([]users.SidebarLink(nil), d.SidebarLinks...),
ShowHidden: d.ShowHidden,
DisableLoginOption: d.DisableLoginOption,
},
ShareLimits: share.ShareLimits{
MaxBandwidth: d.MaxBandwidth,
AllowedUsernames: append([]string(nil), d.AllowedUsernames...),
PerUserDownloadLimit: d.PerUserDownloadLimit,
ExtractEmbeddedSubtitles: d.ExtractEmbeddedSubtitles,
DownloadsLimit: d.DownloadsLimit,
QuotaLimitBytes: d.QuotaLimitBytes,
HideFileExt: d.HideFileExt,
Banner: d.Banner,
},
}
}
// EditableToDefaults extracts defaults-relevant fields from a share editable payload.
func EditableToDefaults(e share.ShareEditable) settings.ShareDefaults {
return settings.ShareDefaults{
ShareTheme: e.ShareTheme,
DisableAnonymous: e.DisableAnonymous,
DisableThumbnails: e.DisableThumbnails,
KeepAfterExpiration: e.KeepAfterExpiration,
ThemeColor: e.ThemeColor,
Title: e.Title,
Description: e.Description,
Favicon: e.Favicon,
QuickDownload: e.QuickDownload,
HideNavButtons: e.HideNavButtons,
DisableSidebar: e.DisableSidebar,
DisableShareCard: e.DisableShareCard,
EnforceDarkLightMode: e.EnforceDarkLightMode,
ViewMode: e.ViewMode,
EnableOnlyOffice: e.EnableOnlyOffice,
ShareType: e.ShareType,
AllowDelete: e.AllowDelete,
AllowCreate: e.AllowCreate,
AllowModify: e.AllowModify,
DisableFileViewer: e.DisableFileViewer,
DisableDownload: e.DisableDownload,
AllowReplacements: e.AllowReplacements,
SidebarLinks: append([]users.SidebarLink(nil), e.SidebarLinks...),
ShowHidden: e.ShowHidden,
DisableLoginOption: e.DisableLoginOption,
MaxBandwidth: e.MaxBandwidth,
AllowedUsernames: append([]string(nil), e.AllowedUsernames...),
PerUserDownloadLimit: e.PerUserDownloadLimit,
ExtractEmbeddedSubtitles: e.ExtractEmbeddedSubtitles,
DownloadsLimit: e.DownloadsLimit,
QuotaLimitBytes: e.QuotaLimitBytes,
HideFileExt: e.HideFileExt,
Banner: e.Banner,
}
}