actually got AmAutoJoinCommunities to work
This commit is contained in:
@@ -159,7 +159,7 @@ func AmAutoJoinCommunities(user *User) error {
|
||||
var lock bool
|
||||
rows.Scan(&cid, &lock)
|
||||
if !slices.Contains(current, cid) {
|
||||
_, err = amdb.Exec("INSERT INTO commmember (commid, uid, granted_lvl, locked) VALUES (?. ?, ?, ?)",
|
||||
_, err = amdb.Exec("INSERT INTO commmember (commid, uid, granted_lvl, locked) VALUES (?, ?, ?, ?)",
|
||||
cid, user.Uid, grantLevel, lock)
|
||||
if err != nil {
|
||||
break
|
||||
|
||||
+9
-1
@@ -472,8 +472,13 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim
|
||||
AmStoreAudit(ar)
|
||||
}()
|
||||
|
||||
unlock := true
|
||||
amdb.Exec("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, commmember WRITE, sideboxes WRITE, confhotlist WRITE;")
|
||||
defer amdb.Exec("UNLOCK TABLES;")
|
||||
defer func() {
|
||||
if unlock {
|
||||
amdb.Exec("UNLOCK TABLES;")
|
||||
}
|
||||
}()
|
||||
|
||||
// Test if the user name is already taken.
|
||||
rs, err := amdb.Query("SELECT uid FROM users WHERE username = ?", username)
|
||||
@@ -525,6 +530,9 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim
|
||||
return nil, err
|
||||
}
|
||||
|
||||
amdb.Exec("UNLOCK TABLES;")
|
||||
unlock = false
|
||||
|
||||
// auto-join communities
|
||||
err = AmAutoJoinCommunities(user)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user