Fix user lookup on unscoped tenant database
This commit is contained in:
@@ -333,11 +333,11 @@ func (a *adapter) TenantUserGet(id t.TenantID, uid t.Uid) (*t.User, error) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
var row profileUserRow
|
var row profileUserRow
|
||||||
err = a.db.GetContext(ctx, &row, `SELECT u.tenant_id,u.id,u.username,u.createdat,u.updatedat,u.state,u.stateat,u.access,u.lastseen,u.useragent,
|
err = a.db.GetContext(ctx, &row, `SELECT ? AS tenant_id,u.id,u.username,u.createdat,u.updatedat,u.state,u.stateat,u.access,u.lastseen,u.useragent,
|
||||||
COALESCE(u.phone,'') AS phone,u.public,u.trusted,
|
COALESCE(u.phone,'') AS phone,u.public,u.trusted,
|
||||||
p.nickname AS profile_nickname,p.avatar_file_id AS profile_avatar_file_id,p.updated_at AS profile_updated_at
|
p.nickname AS profile_nickname,p.avatar_file_id AS profile_avatar_file_id,p.updated_at AS profile_updated_at
|
||||||
FROM im_users AS u LEFT JOIN im_user_profiles AS p ON p.tenant_id=u.tenant_id AND p.user_id=u.id
|
FROM im_users AS u LEFT JOIN im_user_profiles AS p ON p.user_id=u.id
|
||||||
WHERE u.tenant_id=? AND u.id=? AND u.state!=?`,
|
WHERE u.id=? AND u.state!=?`,
|
||||||
id, decodeUID(uid), t.StateDeleted)
|
id, decodeUID(uid), t.StateDeleted)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -9312,12 +9312,13 @@ func (a *adapter) TenantUserSearch(id t.TenantID, viewer t.Uid, queryText, searc
|
|||||||
WHERE privacy_friend.user_id=? AND privacy_friend.peer_id=u.id AND privacy_friend.status=?
|
WHERE privacy_friend.user_id=? AND privacy_friend.peer_id=u.id AND privacy_friend.status=?
|
||||||
) OR COALESCE(JSON_UNQUOTE(JSON_EXTRACT(privacy.add_me_methods, ?)), 'true')='true')`)
|
) OR COALESCE(JSON_UNQUOTE(JSON_EXTRACT(privacy.add_me_methods, ?)), 'true')='true')`)
|
||||||
args = append(args, decodeUID(viewer), t.RelationshipFriend, "$."+addMethod)
|
args = append(args, decodeUID(viewer), t.RelationshipFriend, "$."+addMethod)
|
||||||
|
args = append([]any{id}, args...)
|
||||||
args = append(args, limit+1)
|
args = append(args, limit+1)
|
||||||
ctx, cancel := a.getContext()
|
ctx, cancel := a.getContext()
|
||||||
if cancel != nil {
|
if cancel != nil {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
rows, err := a.db.QueryxContext(ctx, `SELECT DISTINCT u.tenant_id,u.id,u.username,u.createdat,u.updatedat,u.state,u.stateat,u.access,u.lastseen,u.useragent,
|
rows, err := a.db.QueryxContext(ctx, `SELECT DISTINCT ? AS tenant_id,u.id,u.username,u.createdat,u.updatedat,u.state,u.stateat,u.access,u.lastseen,u.useragent,
|
||||||
COALESCE(u.phone,'') AS phone,u.public,u.trusted,
|
COALESCE(u.phone,'') AS phone,u.public,u.trusted,
|
||||||
profile.nickname AS profile_nickname,profile.avatar_file_id AS profile_avatar_file_id,profile.updated_at AS profile_updated_at
|
profile.nickname AS profile_nickname,profile.avatar_file_id AS profile_avatar_file_id,profile.updated_at AS profile_updated_at
|
||||||
FROM im_users AS u `+strings.Join(joins, " ")+`
|
FROM im_users AS u `+strings.Join(joins, " ")+`
|
||||||
|
|||||||
Reference in New Issue
Block a user