feat: migrate IM identity and snowflake primary keys

This commit is contained in:
richjohnrambo
2026-08-18 01:15:21 +08:00
parent db322d80dd
commit bf562c7d56
27 changed files with 1071 additions and 482 deletions
+7 -3
View File
@@ -2128,6 +2128,7 @@ func serveIMMeProfile(wrt http.ResponseWriter, req *http.Request) {
Signature *string `json:"signature"`
Gender *string `json:"gender"`
Region *string `json:"region"`
Email *string `json:"email"`
Version int `json:"version"`
}
if !decodeIMJSONBody(wrt, req, &body) {
@@ -2146,6 +2147,7 @@ func serveIMMeProfile(wrt http.ResponseWriter, req *http.Request) {
Signature: body.Signature,
Gender: body.Gender,
Region: body.Region,
Email: body.Email,
Version: body.Version,
})
if err != nil {
@@ -4860,14 +4862,14 @@ func resolveIMHTTPBearer(req *http.Request) (*imPrincipal, error) {
}
func currentUserPhone(tenantID types.TenantID, uid types.Uid) (string, error) {
creds, err := store.Users.GetAllCreds(tenantID, uid, "tel", true)
user, err := store.Users.Get(tenantID, uid)
if err != nil {
return "", err
}
if len(creds) == 0 || strings.TrimSpace(creds[0].Value) == "" {
if user == nil || strings.TrimSpace(user.Phone) == "" {
return "", types.ErrNotFound
}
return strings.TrimSpace(creds[0].Value), nil
return strings.TrimSpace(user.Phone), nil
}
func createSensitiveChallenge(wrt http.ResponseWriter, req *http.Request, principal *imPrincipal, action, phone string) {
@@ -6075,6 +6077,7 @@ func userProfilePayload10(profile *types.UserProfile) map[string]any {
"signature": profile.Signature,
"gender": profile.Gender,
"region": profile.Region,
"email": profile.Email,
"public_account": profile.PublicAccount,
"version": profile.Version,
"updated_at": profile.UpdatedAt.UTC().Format(time.RFC3339Nano),
@@ -6083,6 +6086,7 @@ func userProfilePayload10(profile *types.UserProfile) map[string]any {
"signature": map[string]any{"max_length": 120},
"birth_date": map[string]any{"format": "YYYY-MM-DD"},
"gender": []string{"male", "female", "other", ""},
"email": map[string]any{"max_length": 128},
},
}
return data