feat: manage global app release policies
This commit is contained in:
@@ -102,6 +102,51 @@ func (c *cConfig) TenantLoginIPWhitelist(ctx context.Context, req *api.TenantLog
|
||||
return &api.TenantLoginIPWhitelistRes{TenantId: data.TenantId, AppList: data.AppList, WebList: data.WebList}, nil
|
||||
}
|
||||
|
||||
func (c *cConfig) AppReleaseLatest(ctx context.Context, req *api.AppReleaseLatestReq) (res *api.AppReleaseLatestRes, err error) {
|
||||
platform := strings.ToLower(strings.TrimSpace(req.Platform))
|
||||
channel := strings.ToLower(strings.TrimSpace(req.Channel))
|
||||
if platform != "ios" && platform != "android" {
|
||||
return nil, gerror.New("客户端平台不合法")
|
||||
}
|
||||
if channel == "" {
|
||||
channel = "stable"
|
||||
}
|
||||
if strings.ContainsAny(channel, " \t\r\n/") || len(channel) > 32 {
|
||||
return nil, gerror.New("客户端渠道不合法")
|
||||
}
|
||||
var row struct {
|
||||
ID int64 `json:"id"`
|
||||
Platform string `json:"platform"`
|
||||
Channel string `json:"channel"`
|
||||
LatestVersion string `json:"latest_version"`
|
||||
MinSupportedVersion string `json:"min_supported_version"`
|
||||
UpdateType string `json:"update_type"`
|
||||
ReleaseNotes string `json:"release_notes"`
|
||||
StoreURL string `json:"store_url"`
|
||||
PackageURL string `json:"package_url"`
|
||||
Checksum string `json:"checksum"`
|
||||
RemindAfterSeconds int `json:"remind_after_seconds"`
|
||||
PublishedAt *gtime.Time `json:"published_at"`
|
||||
CreatedAt *gtime.Time `json:"created_at"`
|
||||
UpdatedAt *gtime.Time `json:"updated_at"`
|
||||
}
|
||||
err = imtenant.RegistryDB().Model("im_app_releases").Safe().Ctx(ctx).
|
||||
Where("platform", platform).Where("channel", channel).Limit(1).Scan(&row)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrap(err, "获取IM客户端版本策略失败")
|
||||
}
|
||||
if row.ID <= 0 {
|
||||
return nil, gerror.New("IM客户端版本策略不存在")
|
||||
}
|
||||
return &api.AppReleaseLatestRes{
|
||||
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: gtimeToRFC3339(row.PublishedAt), CreatedAt: gtimeToRFC3339(row.CreatedAt), UpdatedAt: gtimeToRFC3339(row.UpdatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getTenant(ctx context.Context, field string, value any) (*entity.ImTenant, error) {
|
||||
var tenant *entity.ImTenant
|
||||
if err := imtenant.RegistryDB().Model(dao.ImTenant.Table()).Safe().Ctx(ctx).Where(field, value).Scan(&tenant); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user