mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
dev day #80
This commit is contained in:
@@ -2433,79 +2433,7 @@ func (bc *BaseController) SetupInitialize(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
// Trigger background prefetch and YouTube cache refresh when settings are updated post-setup
|
||||
go func(snap models.Settings) {
|
||||
defer func() { _ = recover() }()
|
||||
snap.LoadCustomNav()
|
||||
var pubVids []string
|
||||
if snap.VideosJSON != "" {
|
||||
_ = json.Unmarshal([]byte(snap.VideosJSON), &pubVids)
|
||||
}
|
||||
var pubVidsItems any
|
||||
if snap.VideosItemsJSON != "" {
|
||||
_ = json.Unmarshal([]byte(snap.VideosItemsJSON), &pubVidsItems)
|
||||
}
|
||||
var pubMerchItems any
|
||||
if snap.MerchItemsJSON != "" {
|
||||
_ = json.Unmarshal([]byte(snap.MerchItemsJSON), &pubMerchItems)
|
||||
}
|
||||
resp := map[string]any{
|
||||
"club_id": snap.ClubID,
|
||||
"club_type": snap.ClubType,
|
||||
"club_name": snap.ClubName,
|
||||
"club_logo_url": snap.ClubLogoURL,
|
||||
"club_url": snap.ClubURL,
|
||||
"primary_color": snap.PrimaryColor,
|
||||
"secondary_color": snap.SecondaryColor,
|
||||
"accent_color": snap.AccentColor,
|
||||
"background_color": snap.BackgroundColor,
|
||||
"text_color": snap.TextColor,
|
||||
"font_heading": snap.FontHeading,
|
||||
"font_body": snap.FontBody,
|
||||
"sponsors_layout": snap.SponsorsLayout,
|
||||
"sponsors_theme": snap.SponsorsTheme,
|
||||
"facebook_url": snap.FacebookURL,
|
||||
"instagram_url": snap.InstagramURL,
|
||||
"youtube_url": snap.YoutubeURL,
|
||||
"gallery_url": snap.GalleryURL,
|
||||
"gallery_label": snap.GalleryLabel,
|
||||
"videos_module_enabled": snap.VideosModuleEnabled,
|
||||
"videos_style": snap.VideosStyle,
|
||||
"videos_source": snap.VideosSource,
|
||||
"videos_limit": snap.VideosLimit,
|
||||
"videos": pubVids,
|
||||
"videos_items": pubVidsItems,
|
||||
"merch_module_enabled": snap.MerchModuleEnabled,
|
||||
"merch_style": snap.MerchStyle,
|
||||
"merch_source": snap.MerchSource,
|
||||
"merch_limit": snap.MerchLimit,
|
||||
"merch_items": pubMerchItems,
|
||||
"about_html": snap.AboutHTML,
|
||||
"show_about_in_nav": snap.ShowAboutInNav,
|
||||
"custom_nav": snap.CustomNav,
|
||||
"contact_address": snap.ContactAddress,
|
||||
"contact_city": snap.ContactCity,
|
||||
"contact_zip": snap.ContactZip,
|
||||
"contact_country": snap.ContactCountry,
|
||||
"contact_phone": snap.ContactPhone,
|
||||
"contact_email": snap.ContactEmail,
|
||||
"location_latitude": snap.LocationLatitude,
|
||||
"location_longitude": snap.LocationLongitude,
|
||||
"map_zoom_level": snap.MapZoomLevel,
|
||||
"map_style": snap.MapStyle,
|
||||
"show_map_on_homepage": snap.ShowMapOnHomepage,
|
||||
}
|
||||
b, _ := json.MarshalIndent(resp, "", " ")
|
||||
outPath := filepath.Join("cache", "prefetch", "settings.json")
|
||||
_ = os.MkdirAll(filepath.Dir(outPath), 0o755)
|
||||
tmp := outPath + ".tmp"
|
||||
_ = os.WriteFile(tmp, b, 0o644)
|
||||
_ = os.Rename(tmp, outPath)
|
||||
}(s)
|
||||
{
|
||||
base := strings.TrimSpace(s.APIBaseURL)
|
||||
if base == "" { base = getPrefetchBaseURL() }
|
||||
go services.PrefetchOnce(strings.TrimRight(base, "/"))
|
||||
}
|
||||
go func() { services.PrefetchOnce(getBaseURL()) }()
|
||||
if strings.TrimSpace(s.YoutubeURL) != "" {
|
||||
go func(u string) { _ = services.RefreshYouTubeChannelNow(u) }(s.YoutubeURL)
|
||||
}
|
||||
@@ -3061,6 +2989,11 @@ func (bc *BaseController) UpdateSettings(c *gin.Context) {
|
||||
// Deployment base URLs (optional, for domain/IP change)
|
||||
FrontendBaseURL *string `json:"frontend_base_url"`
|
||||
APIBaseURL *string `json:"api_base_url"`
|
||||
|
||||
// Storage quota and thresholds
|
||||
StorageQuotaMB *int `json:"storage_quota_mb"`
|
||||
StorageWarnThreshold *int `json:"storage_warn_threshold"`
|
||||
StorageCriticalThreshold *int `json:"storage_critical_threshold"`
|
||||
}
|
||||
var body reqBody
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
@@ -3289,6 +3222,17 @@ func (bc *BaseController) UpdateSettings(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// Storage quota and thresholds
|
||||
if body.StorageQuotaMB != nil {
|
||||
s.StorageQuotaMB = *body.StorageQuotaMB
|
||||
}
|
||||
if body.StorageWarnThreshold != nil {
|
||||
s.StorageWarnThreshold = *body.StorageWarnThreshold
|
||||
}
|
||||
if body.StorageCriticalThreshold != nil {
|
||||
s.StorageCriticalThreshold = *body.StorageCriticalThreshold
|
||||
}
|
||||
|
||||
// SMTP dynamic settings (if provided)
|
||||
if body.SMTPHost != nil {
|
||||
s.SMTPHost = strings.TrimSpace(*body.SMTPHost)
|
||||
|
||||
Reference in New Issue
Block a user