From 7177bdcf3624803778cb3d5551296c3f012e0f4d Mon Sep 17 00:00:00 2001 From: Gus Narea Date: Mon, 25 Sep 2023 14:33:42 +0100 Subject: [PATCH] Rename `Account.locale` to `normalisedLocale` --- .../tech.relaycorp.letro.storage.LetroDatabase/1.json | 10 +++++----- .../java/tech/relaycorp/letro/account/model/Account.kt | 6 +++--- .../tech/relaycorp/letro/account/storage/AccountDao.kt | 2 +- .../letro/account/storage/AccountRepository.kt | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/schemas/tech.relaycorp.letro.storage.LetroDatabase/1.json b/app/schemas/tech.relaycorp.letro.storage.LetroDatabase/1.json index 2994d020..122aafb8 100644 --- a/app/schemas/tech.relaycorp.letro.storage.LetroDatabase/1.json +++ b/app/schemas/tech.relaycorp.letro.storage.LetroDatabase/1.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 1, - "identityHash": "dc43f5c1432dfa4a804e8ab2f5182994", + "identityHash": "5f2174158254547dddd8483c68da34b4", "entities": [ { "tableName": "account", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `veraidId` TEXT NOT NULL, `requestedUserName` TEXT NOT NULL, `locale` TEXT NOT NULL, `isCurrent` INTEGER NOT NULL, `veraidPrivateKey` BLOB NOT NULL, `veraidMemberBundle` BLOB, `isCreated` INTEGER NOT NULL)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `veraidId` TEXT NOT NULL, `requestedUserName` TEXT NOT NULL, `normalisedLocale` TEXT NOT NULL, `isCurrent` INTEGER NOT NULL, `veraidPrivateKey` BLOB NOT NULL, `veraidMemberBundle` BLOB, `isCreated` INTEGER NOT NULL)", "fields": [ { "fieldPath": "id", @@ -27,8 +27,8 @@ "notNull": true }, { - "fieldPath": "locale", - "columnName": "locale", + "fieldPath": "normalisedLocale", + "columnName": "normalisedLocale", "affinity": "TEXT", "notNull": true }, @@ -286,7 +286,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'dc43f5c1432dfa4a804e8ab2f5182994')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5f2174158254547dddd8483c68da34b4')" ] } } \ No newline at end of file diff --git a/app/src/main/java/tech/relaycorp/letro/account/model/Account.kt b/app/src/main/java/tech/relaycorp/letro/account/model/Account.kt index f546fae1..5b90f745 100644 --- a/app/src/main/java/tech/relaycorp/letro/account/model/Account.kt +++ b/app/src/main/java/tech/relaycorp/letro/account/model/Account.kt @@ -15,7 +15,7 @@ data class Account( val id: Long = 0L, val veraidId: String, val requestedUserName: String, - val locale: String, + val normalisedLocale: String, val isCurrent: Boolean, // TODO: Encrypt key when integrating VeraId (https://relaycorp.atlassian.net/browse/LTR-55) val veraidPrivateKey: ByteArray, @@ -31,7 +31,7 @@ data class Account( if (id != other.id) return false if (veraidId != other.veraidId) return false if (requestedUserName != other.requestedUserName) return false - if (locale != other.locale) return false + if (normalisedLocale != other.normalisedLocale) return false if (isCurrent != other.isCurrent) return false if (!veraidPrivateKey.contentEquals(other.veraidPrivateKey)) return false if (veraidMemberBundle != null) { @@ -47,7 +47,7 @@ data class Account( var result = id.hashCode() result = 31 * result + veraidId.hashCode() result = 31 * result + requestedUserName.hashCode() - result = 31 * result + locale.hashCode() + result = 31 * result + normalisedLocale.hashCode() result = 31 * result + isCurrent.hashCode() result = 31 * result + veraidPrivateKey.contentHashCode() result = 31 * result + (veraidMemberBundle?.contentHashCode() ?: 0) diff --git a/app/src/main/java/tech/relaycorp/letro/account/storage/AccountDao.kt b/app/src/main/java/tech/relaycorp/letro/account/storage/AccountDao.kt index f495c9f2..0ffa5e65 100644 --- a/app/src/main/java/tech/relaycorp/letro/account/storage/AccountDao.kt +++ b/app/src/main/java/tech/relaycorp/letro/account/storage/AccountDao.kt @@ -23,6 +23,6 @@ interface AccountDao { @Query("SELECT * FROM $TABLE_NAME_ACCOUNT WHERE id=:id") suspend fun getById(id: Long): Account? - @Query("SELECT * FROM $TABLE_NAME_ACCOUNT WHERE requestedUserName=:requestedUserName AND locale=:locale") + @Query("SELECT * FROM $TABLE_NAME_ACCOUNT WHERE requestedUserName=:requestedUserName AND normalisedLocale=:locale") suspend fun getByRequestParams(requestedUserName: String, locale: String): Account? } diff --git a/app/src/main/java/tech/relaycorp/letro/account/storage/AccountRepository.kt b/app/src/main/java/tech/relaycorp/letro/account/storage/AccountRepository.kt index b4c4dadb..a667ec60 100644 --- a/app/src/main/java/tech/relaycorp/letro/account/storage/AccountRepository.kt +++ b/app/src/main/java/tech/relaycorp/letro/account/storage/AccountRepository.kt @@ -67,7 +67,7 @@ class AccountRepositoryImpl @Inject constructor( Account( veraidId = "$requestedUserName@$domainName", requestedUserName = requestedUserName, - locale = locale.normaliseString(), + normalisedLocale = locale.normaliseString(), veraidPrivateKey = veraidPrivateKey.encoded, isCurrent = true, ),