feat: centralize app release configuration

This commit is contained in:
richjohnrambo
2026-09-12 17:07:49 +08:00
parent 2728f35069
commit e5fbca735d
13 changed files with 257 additions and 104 deletions
+18 -4
View File
@@ -169,6 +169,7 @@ type AdminInternalConfigProvider interface {
ListActiveTenants(limit int) ([]types.Tenant, error)
RegistrationSMSEnabled() (bool, error)
ThirdPartyConfig(group string, keys ...string) (map[string]string, error)
LatestAppRelease(platform, channel string) (*types.AppRelease, error)
}
var adminInternalConfigProvider AdminInternalConfigProvider
@@ -2728,24 +2729,37 @@ type profileMapper struct{}
var Profiles ProfilePersistenceInterface
type AppReleasePersistenceInterface interface {
Latest(tenantID types.TenantID, platform, channel string) (*types.AppRelease, error)
Latest(platform, channel string) (*types.AppRelease, error)
}
type appReleaseMapper struct{}
var AppReleases AppReleasePersistenceInterface
func (appReleaseMapper) Latest(tenantID types.TenantID, platform, channel string) (*types.AppRelease, error) {
func (appReleaseMapper) Latest(platform, channel string) (*types.AppRelease, error) {
platform = strings.ToLower(strings.TrimSpace(platform))
channel = strings.ToLower(strings.TrimSpace(channel))
if platform == "" || channel == "" {
return nil, types.ErrMalformed
}
tenantAdp, err := tenantBusinessAdapter(tenantID)
cacheKey := platform + ":" + channel
if cached, ok := appReleaseConfigCache.get(cacheKey); ok {
copy := *cached
return &copy, nil
}
if adminInternalConfigProvider == nil {
return nil, types.ErrUnsupported
}
release, err := adminInternalConfigProvider.LatestAppRelease(platform, channel)
if err != nil {
return nil, err
}
return tenantAdp.TenantAppReleaseLatest(tenantID, platform, channel)
if release == nil {
return nil, types.ErrNotFound
}
copy := *release
appReleaseConfigCache.set(cacheKey, &copy)
return release, nil
}
type DevicePushTokenPersistenceInterface interface {