feat: assign IM user account numbers

This commit is contained in:
richjohnrambo
2026-09-10 21:51:23 +08:00
parent 51fee50343
commit 928a45ecfb
6 changed files with 112 additions and 27 deletions
+5 -5
View File
@@ -289,8 +289,8 @@ func TestTenantAuthIsolation(t *testing.T) {
userBID := userAID + 1
for index, userID := range []int64{userAID, userBID} {
tenantDB := quoteIdent(dbNames[index])
if _, err := db.Exec("INSERT INTO "+tenantDB+".im_users(id,username,createdat,updatedat,state,access,phone,public,trusted) "+
"VALUES(?,?,?,?,?,?,?,?,?)", userID, "alice", now, now, types.StateOK, `{}`, "13800000000", nil, nil); err != nil {
if _, err := db.Exec("INSERT INTO "+tenantDB+".im_users(id,account_no,username,createdat,updatedat,state,access,phone,public,trusted) "+
"VALUES(?,?,?,?,?,?,?,?,?,?)", userID, 1000+index, "alice", now, now, types.StateOK, `{}`, "13800000000", nil, nil); err != nil {
t.Fatal(err)
}
if _, err := db.Exec("INSERT INTO "+tenantDB+".im_auth(userid,authlvl,secret) VALUES(?,?,?)",
@@ -360,9 +360,9 @@ func TestTenantUserSearchMatchesUsernamePhoneAndPublicAccount(t *testing.T) {
{targetID, "potter", "+8615500000002", `{"fn":"Potter"}`},
} {
if _, err := db.Exec(
`INSERT INTO im_users(id,username,createdat,updatedat,state,access,phone,public,trusted)
VALUES(?,?,?,?,?,?,?,?,?)`,
user.id, user.username, now, now, types.StateOK, `{"Auth":"JRWPAS","Anon":"N"}`, user.phone, user.public, `{}`); err != nil {
`INSERT INTO im_users(id,account_no,username,createdat,updatedat,state,access,phone,public,trusted)
VALUES(?,?,?,?,?,?,?,?,?,?)`,
user.id, user.id%1000000, user.username, now, now, types.StateOK, `{"Auth":"JRWPAS","Anon":"N"}`, user.phone, user.public, `{}`); err != nil {
t.Fatal(err)
}
if _, err := db.Exec(