feat: centralize app release configuration
This commit is contained in:
@@ -445,7 +445,6 @@ type TenantBusinessAdapter interface {
|
||||
TenantUserProfileUpdate(t.TenantID, t.Uid, t.UserProfilePatch) (*t.UserProfile, error)
|
||||
TenantUserPrivacyGet(t.TenantID, t.Uid) (*t.UserPrivacySettings, error)
|
||||
TenantUserPrivacyUpdate(t.TenantID, t.Uid, t.UserPrivacyPatch) (*t.UserPrivacySettings, error)
|
||||
TenantAppReleaseLatest(t.TenantID, string, string) (*t.AppRelease, error)
|
||||
TenantDevicePushTokenUpsert(t.TenantID, *t.DevicePushToken) (*t.DevicePushToken, error)
|
||||
TenantRiskChallengeCreate(t.TenantID, *t.RiskChallenge) (*t.RiskChallenge, error)
|
||||
TenantRiskChallengeConfirm(t.TenantID, t.Uid, string, string, string, time.Time) (*t.RiskChallenge, error)
|
||||
|
||||
@@ -1858,24 +1858,6 @@ func createIMUserProductTables(tx *sql.Tx) error {
|
||||
PRIMARY KEY(id),
|
||||
UNIQUE INDEX uk_im_user_privacy_settings_user(user_id)
|
||||
)`,
|
||||
`CREATE TABLE im_app_releases(
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
platform VARCHAR(32) NOT NULL,
|
||||
channel VARCHAR(32) NOT NULL DEFAULT 'stable',
|
||||
latest_version VARCHAR(64) NOT NULL,
|
||||
min_supported_version VARCHAR(64) NOT NULL,
|
||||
update_type VARCHAR(16) NOT NULL DEFAULT 'none',
|
||||
release_notes TEXT NOT NULL,
|
||||
store_url VARCHAR(512) NOT NULL DEFAULT '',
|
||||
package_url VARCHAR(512) NOT NULL DEFAULT '',
|
||||
checksum VARCHAR(128) NOT NULL DEFAULT '',
|
||||
remind_after_seconds INT NOT NULL DEFAULT 0,
|
||||
published_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY(id),
|
||||
UNIQUE INDEX uk_im_app_releases_platform_channel(platform, channel)
|
||||
)`,
|
||||
`CREATE TABLE im_device_push_tokens(
|
||||
id BIGINT NOT NULL,
|
||||
device_id VARCHAR(128) NOT NULL,
|
||||
|
||||
@@ -6244,68 +6244,6 @@ func (a *adapter) TenantUserPrivacyUpdate(id t.TenantID, uid t.Uid, patch t.User
|
||||
return a.userPrivacyByUID(ctx, uid)
|
||||
}
|
||||
|
||||
func (a *adapter) TenantAppReleaseLatest(id t.TenantID, platform, channel string) (*t.AppRelease, error) {
|
||||
if !a.tenantScopedDB {
|
||||
tenantAdp, err := a.routedTenantAdapter(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tenantAdp != a {
|
||||
return tenantAdp.TenantAppReleaseLatest(id, platform, channel)
|
||||
}
|
||||
}
|
||||
platform = strings.ToLower(strings.TrimSpace(platform))
|
||||
channel = strings.ToLower(strings.TrimSpace(channel))
|
||||
if err := validTenant(id); err != nil || platform == "" || channel == "" {
|
||||
return nil, t.ErrMalformed
|
||||
}
|
||||
ctx, cancel := a.getContext()
|
||||
if cancel != nil {
|
||||
defer cancel()
|
||||
}
|
||||
row := struct {
|
||||
ID int64 `db:"id"`
|
||||
Platform string `db:"platform"`
|
||||
Channel string `db:"channel"`
|
||||
LatestVersion string `db:"latest_version"`
|
||||
MinSupportedVersion string `db:"min_supported_version"`
|
||||
UpdateType string `db:"update_type"`
|
||||
ReleaseNotes string `db:"release_notes"`
|
||||
StoreURL string `db:"store_url"`
|
||||
PackageURL string `db:"package_url"`
|
||||
Checksum string `db:"checksum"`
|
||||
RemindAfterSeconds int `db:"remind_after_seconds"`
|
||||
PublishedAt time.Time `db:"published_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}{}
|
||||
err := sqlx.GetContext(ctx, a.db, &row,
|
||||
`SELECT id,platform,channel,latest_version,min_supported_version,update_type,release_notes,store_url,package_url,checksum,remind_after_seconds,published_at,created_at,updated_at
|
||||
FROM im_app_releases WHERE platform=? AND channel=? LIMIT 1`, platform, channel)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, t.ErrNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &t.AppRelease{
|
||||
ID: row.ID,
|
||||
Platform: row.Platform,
|
||||
Channel: row.Channel,
|
||||
LatestVersion: row.LatestVersion,
|
||||
MinSupportedVersion: row.MinSupportedVersion,
|
||||
UpdateType: row.UpdateType,
|
||||
ReleaseNotes: row.ReleaseNotes,
|
||||
StoreURL: row.StoreURL,
|
||||
PackageURL: row.PackageURL,
|
||||
Checksum: row.Checksum,
|
||||
RemindAfterSeconds: row.RemindAfterSeconds,
|
||||
PublishedAt: row.PublishedAt,
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *adapter) TenantDevicePushTokenUpsert(id t.TenantID, token *t.DevicePushToken) (*t.DevicePushToken, error) {
|
||||
if !a.tenantScopedDB {
|
||||
tenantAdp, err := a.routedTenantAdapter(id)
|
||||
|
||||
Reference in New Issue
Block a user