mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-04 03:27:29 +01:00
fix: case sensitive account lookup (#1033)
This commit is contained in:
parent
3b01922c3b
commit
e541e02b9c
@ -27,7 +27,7 @@ class DefaultAccountRepositoryTest {
|
||||
mockk<AccountsQueries>(relaxUnitFun = true) {
|
||||
every { getAll() } returns query
|
||||
every { getActive() } returns query
|
||||
every { getBy(username = any(), instance = any()) } returns query
|
||||
every { getBy(any(), any()) } returns query
|
||||
every { getActive() } returns query
|
||||
}
|
||||
private val provider =
|
||||
|
@ -14,14 +14,20 @@ internal class DefaultAccountRepository(
|
||||
|
||||
override suspend fun getAll(): List<AccountModel> =
|
||||
withContext(Dispatchers.IO) {
|
||||
db.accountsQueries.getAll().executeAsList().map { it.toModel() }
|
||||
db.accountsQueries
|
||||
.getAll()
|
||||
.executeAsList()
|
||||
.map { it.toModel() }
|
||||
}
|
||||
|
||||
override suspend fun getBy(
|
||||
username: String,
|
||||
instance: String,
|
||||
) = withContext(Dispatchers.IO) {
|
||||
db.accountsQueries.getBy(username, instance).executeAsOneOrNull()?.toModel()
|
||||
db.accountsQueries
|
||||
.getBy(username.lowercase(), instance.lowercase())
|
||||
.executeAsOneOrNull()
|
||||
?.toModel()
|
||||
}
|
||||
|
||||
override suspend fun createAccount(account: AccountModel) =
|
||||
@ -33,7 +39,10 @@ internal class DefaultAccountRepository(
|
||||
avatar = account.avatar,
|
||||
)
|
||||
val entity =
|
||||
db.accountsQueries.getAll().executeAsList().firstOrNull { it.jwt == account.jwt }
|
||||
db.accountsQueries
|
||||
.getAll()
|
||||
.executeAsList()
|
||||
.firstOrNull { it.jwt == account.jwt }
|
||||
entity?.id ?: 0
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ FROM AccountEntity;
|
||||
getBy:
|
||||
SELECT *
|
||||
FROM AccountEntity
|
||||
WHERE username = ? AND instance = ?;
|
||||
WHERE username = LOWER(?) AND instance = LOWER(?);
|
||||
|
||||
update:
|
||||
UPDATE AccountEntity
|
||||
|
Loading…
x
Reference in New Issue
Block a user