mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
Rename UserNgEntity to UserEntity
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
25a5346435
commit
4233e1bbc1
@ -35,13 +35,13 @@ import com.nextcloud.talk.data.source.local.converters.SignalingSettingsConverte
|
|||||||
import com.nextcloud.talk.data.storage.ArbitraryStoragesDao
|
import com.nextcloud.talk.data.storage.ArbitraryStoragesDao
|
||||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorageNgEntity
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorageNgEntity
|
||||||
import com.nextcloud.talk.data.user.UsersDao
|
import com.nextcloud.talk.data.user.UsersDao
|
||||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
import com.nextcloud.talk.data.user.model.UserEntity
|
||||||
import net.sqlcipher.database.SQLiteDatabase
|
import net.sqlcipher.database.SQLiteDatabase
|
||||||
import net.sqlcipher.database.SupportFactory
|
import net.sqlcipher.database.SupportFactory
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [UserNgEntity::class, ArbitraryStorageNgEntity::class],
|
entities = [UserEntity::class, ArbitraryStorageNgEntity::class],
|
||||||
version = 8,
|
version = 8,
|
||||||
exportSchema = true
|
exportSchema = true
|
||||||
)
|
)
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
package com.nextcloud.talk.data.user
|
package com.nextcloud.talk.data.user
|
||||||
|
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
import com.nextcloud.talk.data.user.model.UserEntity
|
||||||
|
|
||||||
object UserMapper {
|
object UserMapper {
|
||||||
fun toModel(entities: List<UserNgEntity?>?): List<User> {
|
fun toModel(entities: List<UserEntity?>?): List<User> {
|
||||||
return if (entities == null) {
|
return if (entities == null) {
|
||||||
ArrayList()
|
ArrayList()
|
||||||
} else {
|
} else {
|
||||||
@ -36,7 +36,7 @@ object UserMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toModel(entity: UserNgEntity?): User? {
|
fun toModel(entity: UserEntity?): User? {
|
||||||
return if (entity == null) {
|
return if (entity == null) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
@ -57,23 +57,23 @@ object UserMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toEntity(model: User): UserNgEntity {
|
fun toEntity(model: User): UserEntity {
|
||||||
var userNgEntity: UserNgEntity? = null
|
var UserEntity: UserEntity? = null
|
||||||
model.id?.let {
|
model.id?.let {
|
||||||
userNgEntity = UserNgEntity(it, model.userId, model.username, model.baseUrl)
|
UserEntity = UserEntity(it, model.userId, model.username, model.baseUrl)
|
||||||
} ?: run {
|
} ?: run {
|
||||||
userNgEntity = UserNgEntity(userId = model.userId, username = model.username, baseUrl = model.baseUrl)
|
UserEntity = UserEntity(userId = model.userId, username = model.username, baseUrl = model.baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
userNgEntity!!.token = model.token
|
UserEntity!!.token = model.token
|
||||||
userNgEntity!!.displayName = model.displayName
|
UserEntity!!.displayName = model.displayName
|
||||||
userNgEntity!!.pushConfigurationState = model.pushConfigurationState
|
UserEntity!!.pushConfigurationState = model.pushConfigurationState
|
||||||
userNgEntity!!.capabilities = model.capabilities
|
UserEntity!!.capabilities = model.capabilities
|
||||||
userNgEntity!!.clientCertificate = model.clientCertificate
|
UserEntity!!.clientCertificate = model.clientCertificate
|
||||||
userNgEntity!!.externalSignalingServer = model.externalSignalingServer
|
UserEntity!!.externalSignalingServer = model.externalSignalingServer
|
||||||
userNgEntity!!.current = model.current
|
UserEntity!!.current = model.current
|
||||||
userNgEntity!!.scheduledForDeletion = model.scheduledForDeletion
|
UserEntity!!.scheduledForDeletion = model.scheduledForDeletion
|
||||||
|
|
||||||
return userNgEntity!!
|
return UserEntity!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import androidx.room.OnConflictStrategy
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
import com.nextcloud.talk.data.user.model.UserEntity
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.SingleObserver
|
import io.reactivex.SingleObserver
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
@ -41,58 +41,58 @@ import java.lang.Boolean.TRUE
|
|||||||
abstract class UsersDao {
|
abstract class UsersDao {
|
||||||
// get active user
|
// get active user
|
||||||
@Query("SELECT * FROM User where current = 1")
|
@Query("SELECT * FROM User where current = 1")
|
||||||
abstract fun getActiveUser(): Single<UserNgEntity?>
|
abstract fun getActiveUser(): Single<UserEntity?>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where current = 1")
|
@Query("SELECT * FROM User where current = 1")
|
||||||
abstract fun getActiveUserSynchronously(): UserNgEntity?
|
abstract fun getActiveUserSynchronously(): UserEntity?
|
||||||
|
|
||||||
@Query("SELECT * FROM User WHERE current = 1")
|
@Query("SELECT * FROM User WHERE current = 1")
|
||||||
abstract fun getActiveUserLiveData(): Single<UserNgEntity?>
|
abstract fun getActiveUserLiveData(): Single<UserEntity?>
|
||||||
|
|
||||||
@Query("DELETE FROM User WHERE id = :id")
|
@Query("DELETE FROM User WHERE id = :id")
|
||||||
abstract fun deleteUserWithId(id: Long)
|
abstract fun deleteUserWithId(id: Long)
|
||||||
|
|
||||||
@Update
|
@Update
|
||||||
abstract fun updateUser(user: UserNgEntity): Int
|
abstract fun updateUser(user: UserEntity): Int
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
abstract fun saveUser(user: UserNgEntity): Long
|
abstract fun saveUser(user: UserEntity): Long
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
abstract fun saveUsers(vararg users: UserNgEntity): List<Long>
|
abstract fun saveUsers(vararg users: UserEntity): List<Long>
|
||||||
|
|
||||||
// get all users not scheduled for deletion
|
// get all users not scheduled for deletion
|
||||||
@Query("SELECT * FROM User where current != 0")
|
@Query("SELECT * FROM User where current != 0")
|
||||||
abstract fun getUsers(): Single<List<UserNgEntity>>
|
abstract fun getUsers(): Single<List<UserEntity>>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where id = :id")
|
@Query("SELECT * FROM User where id = :id")
|
||||||
abstract fun getUserWithId(id: Long): Single<UserNgEntity?>
|
abstract fun getUserWithId(id: Long): Single<UserEntity?>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where id = :id AND scheduledForDeletion != 1")
|
@Query("SELECT * FROM User where id = :id AND scheduledForDeletion != 1")
|
||||||
abstract fun getUserWithIdNotScheduledForDeletion(id: Long): Single<UserNgEntity?>
|
abstract fun getUserWithIdNotScheduledForDeletion(id: Long): Single<UserEntity?>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where userId = :userId")
|
@Query("SELECT * FROM User where userId = :userId")
|
||||||
abstract fun getUserWithUserId(userId: String): Single<UserNgEntity?>
|
abstract fun getUserWithUserId(userId: String): Single<UserEntity?>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where userId != :userId")
|
@Query("SELECT * FROM User where userId != :userId")
|
||||||
abstract fun getUsersWithoutUserId(userId: Long): Single<List<UserNgEntity>>
|
abstract fun getUsersWithoutUserId(userId: Long): Single<List<UserEntity>>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where current = 0")
|
@Query("SELECT * FROM User where current = 0")
|
||||||
abstract fun getUsersScheduledForDeletion(): Single<List<UserNgEntity>>
|
abstract fun getUsersScheduledForDeletion(): Single<List<UserEntity>>
|
||||||
|
|
||||||
@Query("SELECT * FROM User where scheduledForDeletion = 0")
|
@Query("SELECT * FROM User where scheduledForDeletion = 0")
|
||||||
abstract fun getUsersNotScheduledForDeletion(): Single<List<UserNgEntity>>
|
abstract fun getUsersNotScheduledForDeletion(): Single<List<UserEntity>>
|
||||||
|
|
||||||
@Query("SELECT * FROM User WHERE username = :username AND baseUrl = :server")
|
@Query("SELECT * FROM User WHERE username = :username AND baseUrl = :server")
|
||||||
abstract fun getUserWithUsernameAndServer(username: String, server: String): Single<UserNgEntity?>
|
abstract fun getUserWithUsernameAndServer(username: String, server: String): Single<UserEntity?>
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
open suspend fun setUserAsActiveWithId(id: Long): Boolean {
|
open suspend fun setUserAsActiveWithId(id: Long): Boolean {
|
||||||
val users = getUsers()
|
val users = getUsers()
|
||||||
var result = TRUE
|
var result = TRUE
|
||||||
|
|
||||||
users.subscribe(object : SingleObserver<List<UserNgEntity>> {
|
users.subscribe(object : SingleObserver<List<UserEntity>> {
|
||||||
override fun onSuccess(users: List<UserNgEntity>) {
|
override fun onSuccess(users: List<UserEntity>) {
|
||||||
for (user in users) {
|
for (user in users) {
|
||||||
// removed from clause: && UserStatus.ACTIVE == user.status
|
// removed from clause: && UserStatus.ACTIVE == user.status
|
||||||
if (user.id != id) {
|
if (user.id != id) {
|
||||||
|
@ -37,7 +37,7 @@ import java.lang.Boolean.FALSE
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
@Serializable
|
@Serializable
|
||||||
@Entity(tableName = "User")
|
@Entity(tableName = "User")
|
||||||
data class UserNgEntity(
|
data class UserEntity(
|
||||||
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") var id: Long = 0,
|
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") var id: Long = 0,
|
||||||
@ColumnInfo(name = "userId") var userId: String? = null,
|
@ColumnInfo(name = "userId") var userId: String? = null,
|
||||||
@ColumnInfo(name = "username") var username: String? = null,
|
@ColumnInfo(name = "username") var username: String? = null,
|
@ -25,7 +25,7 @@ import android.text.TextUtils
|
|||||||
import com.bluelinelabs.logansquare.LoganSquare
|
import com.bluelinelabs.logansquare.LoganSquare
|
||||||
import com.nextcloud.talk.data.user.UsersRepository
|
import com.nextcloud.talk.data.user.UsersRepository
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
import com.nextcloud.talk.data.user.model.UserEntity
|
||||||
import com.nextcloud.talk.models.ExternalSignalingServer
|
import com.nextcloud.talk.models.ExternalSignalingServer
|
||||||
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
||||||
import com.nextcloud.talk.models.json.push.PushConfigurationState
|
import com.nextcloud.talk.models.json.push.PushConfigurationState
|
||||||
@ -195,7 +195,7 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validDisplayName(displayName: String?, user: UserNgEntity): Boolean {
|
private fun validDisplayName(displayName: String?, user: UserEntity): Boolean {
|
||||||
return if (displayName == null) {
|
return if (displayName == null) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user