Skip to content

Commit

Permalink
Rename Account.locale to normalisedLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea committed Sep 25, 2023
1 parent 9cc2162 commit 7177bdc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/schemas/tech.relaycorp.letro.storage.LetroDatabase/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -27,8 +27,8 @@
"notNull": true
},
{
"fieldPath": "locale",
"columnName": "locale",
"fieldPath": "normalisedLocale",
"columnName": "normalisedLocale",
"affinity": "TEXT",
"notNull": true
},
Expand Down Expand Up @@ -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')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down

0 comments on commit 7177bdc

Please sign in to comment.