use correct primary key to search for any other users in the DB and use current value from user attributes object

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-07-22 14:50:08 +02:00
parent 6a8cafec22
commit 00f55f1949
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
5 changed files with 9 additions and 9 deletions

View File

@ -71,8 +71,8 @@ abstract class UsersDao {
@Query("SELECT * FROM User where userId = :userId") @Query("SELECT * FROM User where userId = :userId")
abstract fun getUserWithUserId(userId: String): Maybe<UserEntity> abstract fun getUserWithUserId(userId: String): Maybe<UserEntity>
@Query("SELECT * FROM User where userId != :userId") @Query("SELECT * FROM User where id != :id")
abstract fun getUsersWithoutUserId(userId: Long): Single<List<UserEntity>> abstract fun getUsersWithoutId(id: Long): Single<List<UserEntity>>
@Query("SELECT * FROM User where scheduledForDeletion = 1") @Query("SELECT * FROM User where scheduledForDeletion = 1")
abstract fun getUsersScheduledForDeletion(): Single<List<UserEntity>> abstract fun getUsersScheduledForDeletion(): Single<List<UserEntity>>

View File

@ -33,7 +33,7 @@ interface UsersRepository {
fun getUserWithId(id: Long): Maybe<User> fun getUserWithId(id: Long): Maybe<User>
fun getUserWithIdNotScheduledForDeletion(id: Long): Maybe<User> fun getUserWithIdNotScheduledForDeletion(id: Long): Maybe<User>
fun getUserWithUserId(userId: String): Maybe<User> fun getUserWithUserId(userId: String): Maybe<User>
fun getUsersWithoutUserId(userId: Long): Single<List<User>> fun getUsersWithoutUserId(id: Long): Single<List<User>>
fun getUsersScheduledForDeletion(): Single<List<User>> fun getUsersScheduledForDeletion(): Single<List<User>>
fun getUsersNotScheduledForDeletion(): Single<List<User>> fun getUsersNotScheduledForDeletion(): Single<List<User>>
fun getUserWithUsernameAndServer(username: String, server: String): Maybe<User> fun getUserWithUsernameAndServer(username: String, server: String): Maybe<User>

View File

@ -49,8 +49,8 @@ class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
return usersDao.getUserWithUserId(userId).map { UserMapper.toModel(it) } return usersDao.getUserWithUserId(userId).map { UserMapper.toModel(it) }
} }
override fun getUsersWithoutUserId(userId: Long): Single<List<User>> { override fun getUsersWithoutUserId(id: Long): Single<List<User>> {
return usersDao.getUsersWithoutUserId(userId).map { UserMapper.toModel(it) } return usersDao.getUsersWithoutId(id).map { UserMapper.toModel(it) }
} }
override fun getUsersScheduledForDeletion(): Single<List<User>> { override fun getUsersScheduledForDeletion(): Single<List<User>> {

View File

@ -57,8 +57,8 @@ class UserManager internal constructor(private val userRepository: UsersReposito
return userRepository.getUserWithId(id) return userRepository.getUserWithId(id)
} }
fun disableAllUsersWithoutId(userId: Long): Single<Int> { fun disableAllUsersWithoutId(id: Long): Single<Int> {
val results = userRepository.getUsersWithoutUserId(userId) val results = userRepository.getUsersWithoutUserId(id)
return results.map { users -> return results.map { users ->
var count = 0 var count = 0
@ -275,7 +275,7 @@ class UserManager internal constructor(private val userRepository: UsersReposito
user.externalSignalingServer = LoganSquare user.externalSignalingServer = LoganSquare
.parse(userAttributes.externalSignalingServer, ExternalSignalingServer::class.java) .parse(userAttributes.externalSignalingServer, ExternalSignalingServer::class.java)
} }
user.current = true user.current = userAttributes.currentUser == true
return user return user
} }

View File

@ -3,7 +3,7 @@
* *
* @author Andy Scherzinger * @author Andy Scherzinger
* @author Mario Danic * @author Mario Danic
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de> * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com> * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify