mirror of
https://github.com/etesync/android
synced 2024-12-23 23:18:46 +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)
|
||||
operator fun get(owner: String): UserInfo? {
|
||||
fun fetch(owner: String): UserInfo? {
|
||||
val remote = this.remote!!.newBuilder().addPathSegment(owner).addPathSegment("").build()
|
||||
val request = Request.Builder()
|
||||
.get()
|
||||
|
@ -60,7 +60,7 @@ class AddMemberFragment : DialogFragment() {
|
||||
val httpClient = HttpClient.create(ctx!!, settings!!)
|
||||
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))
|
||||
memberPubKey = userInfo.pubkey!!
|
||||
return AddResult(null)
|
||||
|
@ -97,7 +97,7 @@ class SetupEncryptionFragment : DialogFragment() {
|
||||
val httpClient = HttpClient.create(getContext(), config.url, config.authtoken!!)
|
||||
|
||||
val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(config.url)!!)
|
||||
val userInfo = userInfoManager[config.userName]
|
||||
val userInfo = userInfoManager.fetch(config.userName)
|
||||
if (userInfo != null) {
|
||||
App.log.info("Fetched userInfo for " + config.userName)
|
||||
cryptoManager = Crypto.CryptoManager(userInfo.version!!.toInt(), config.password!!, "userInfo")
|
||||
|
@ -50,7 +50,7 @@ class SetupUserInfoFragment : DialogFragment() {
|
||||
val httpClient = HttpClient.create(context, settings)
|
||||
|
||||
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) {
|
||||
App.log.info("Creating userInfo for " + account.name)
|
||||
|
@ -206,7 +206,7 @@ class ServiceTest {
|
||||
val manager = UserInfoManager(httpClient!!, remote!!)
|
||||
|
||||
// Get when there's nothing
|
||||
userInfo = manager[Helpers.USER]
|
||||
userInfo = manager.fetch(Helpers.USER)
|
||||
assertNull(userInfo)
|
||||
|
||||
// Create
|
||||
@ -214,20 +214,20 @@ class ServiceTest {
|
||||
manager.create(userInfo)
|
||||
|
||||
// Get
|
||||
userInfo2 = manager[Helpers.USER]
|
||||
userInfo2 = manager.fetch(Helpers.USER)
|
||||
assertNotNull(userInfo2)
|
||||
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
||||
|
||||
// Update
|
||||
userInfo.setContent(cryptoManager, "test".toByteArray())
|
||||
manager.update(userInfo)
|
||||
userInfo2 = manager[Helpers.USER]
|
||||
userInfo2 = manager.fetch(Helpers.USER)
|
||||
assertNotNull(userInfo2)
|
||||
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
||||
|
||||
// Delete
|
||||
manager.delete(userInfo)
|
||||
userInfo = manager[Helpers.USER]
|
||||
userInfo = manager.fetch(Helpers.USER)
|
||||
assertNull(userInfo)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user