mirror of
https://github.com/etesync/android
synced 2025-01-11 16:21:10 +00:00
UserInfoManager: fix the wrong conversion to kotlin.
This commit is contained in:
parent
1865160e4e
commit
6e2ab7d972
@ -19,7 +19,7 @@ class UserInfoManager(httpClient: OkHttpClient, remote: HttpUrl) : BaseManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exceptions.HttpException::class)
|
@Throws(Exceptions.HttpException::class)
|
||||||
operator fun get(owner: String): UserInfo? {
|
fun fetch(owner: String): UserInfo? {
|
||||||
val remote = this.remote!!.newBuilder().addPathSegment(owner).addPathSegment("").build()
|
val remote = this.remote!!.newBuilder().addPathSegment(owner).addPathSegment("").build()
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
.get()
|
.get()
|
||||||
|
@ -60,7 +60,7 @@ class AddMemberFragment : DialogFragment() {
|
|||||||
val httpClient = HttpClient.create(ctx!!, settings!!)
|
val httpClient = HttpClient.create(ctx!!, settings!!)
|
||||||
val userInfoManager = UserInfoManager(httpClient, remote!!)
|
val userInfoManager = UserInfoManager(httpClient, remote!!)
|
||||||
|
|
||||||
val userInfo = userInfoManager[memberEmail]
|
val userInfo = userInfoManager.fetch(memberEmail)
|
||||||
?: throw Exception(getString(R.string.collection_members_error_user_not_found, memberEmail))
|
?: throw Exception(getString(R.string.collection_members_error_user_not_found, memberEmail))
|
||||||
memberPubKey = userInfo.pubkey!!
|
memberPubKey = userInfo.pubkey!!
|
||||||
return AddResult(null)
|
return AddResult(null)
|
||||||
|
@ -97,7 +97,7 @@ class SetupEncryptionFragment : DialogFragment() {
|
|||||||
val httpClient = HttpClient.create(getContext(), config.url, config.authtoken!!)
|
val httpClient = HttpClient.create(getContext(), config.url, config.authtoken!!)
|
||||||
|
|
||||||
val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(config.url)!!)
|
val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(config.url)!!)
|
||||||
val userInfo = userInfoManager[config.userName]
|
val userInfo = userInfoManager.fetch(config.userName)
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
App.log.info("Fetched userInfo for " + config.userName)
|
App.log.info("Fetched userInfo for " + config.userName)
|
||||||
cryptoManager = Crypto.CryptoManager(userInfo.version!!.toInt(), config.password!!, "userInfo")
|
cryptoManager = Crypto.CryptoManager(userInfo.version!!.toInt(), config.password!!, "userInfo")
|
||||||
|
@ -50,7 +50,7 @@ class SetupUserInfoFragment : DialogFragment() {
|
|||||||
val httpClient = HttpClient.create(context, settings)
|
val httpClient = HttpClient.create(context, settings)
|
||||||
|
|
||||||
val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(settings.uri!!)!!)
|
val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(settings.uri!!)!!)
|
||||||
var userInfo: UserInfoManager.UserInfo? = userInfoManager[account.name]
|
var userInfo: UserInfoManager.UserInfo? = userInfoManager.fetch(account.name)
|
||||||
|
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
App.log.info("Creating userInfo for " + account.name)
|
App.log.info("Creating userInfo for " + account.name)
|
||||||
|
@ -206,7 +206,7 @@ class ServiceTest {
|
|||||||
val manager = UserInfoManager(httpClient!!, remote!!)
|
val manager = UserInfoManager(httpClient!!, remote!!)
|
||||||
|
|
||||||
// Get when there's nothing
|
// Get when there's nothing
|
||||||
userInfo = manager[Helpers.USER]
|
userInfo = manager.fetch(Helpers.USER)
|
||||||
assertNull(userInfo)
|
assertNull(userInfo)
|
||||||
|
|
||||||
// Create
|
// Create
|
||||||
@ -214,20 +214,20 @@ class ServiceTest {
|
|||||||
manager.create(userInfo)
|
manager.create(userInfo)
|
||||||
|
|
||||||
// Get
|
// Get
|
||||||
userInfo2 = manager[Helpers.USER]
|
userInfo2 = manager.fetch(Helpers.USER)
|
||||||
assertNotNull(userInfo2)
|
assertNotNull(userInfo2)
|
||||||
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
userInfo.setContent(cryptoManager, "test".toByteArray())
|
userInfo.setContent(cryptoManager, "test".toByteArray())
|
||||||
manager.update(userInfo)
|
manager.update(userInfo)
|
||||||
userInfo2 = manager[Helpers.USER]
|
userInfo2 = manager.fetch(Helpers.USER)
|
||||||
assertNotNull(userInfo2)
|
assertNotNull(userInfo2)
|
||||||
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
manager.delete(userInfo)
|
manager.delete(userInfo)
|
||||||
userInfo = manager[Helpers.USER]
|
userInfo = manager.fetch(Helpers.USER)
|
||||||
assertNull(userInfo)
|
assertNull(userInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user