Update jmap-client library to version 0.3.0

This commit is contained in:
cketti 2020-02-17 18:44:52 +01:00
parent 465d908d1d
commit 6a0a5c8f88
3 changed files with 40 additions and 18 deletions

View file

@ -12,7 +12,7 @@ dependencies {
api project(":backend:api")
api "com.squareup.okhttp3:okhttp:${versions.okhttp}"
implementation "rs.ltt.jmap:jmap-client:0.2.4"
implementation "rs.ltt.jmap:jmap-client:0.3.0"
implementation "com.jakewharton.timber:timber:${versions.timber}"
testImplementation project(":mail:testing")

View file

@ -46,7 +46,9 @@ internal class CommandRefreshFolderList(
}
private fun fetchMailboxes() {
val call = jmapClient.call(GetMailboxMethodCall(accountId))
val call = jmapClient.call(
GetMailboxMethodCall.builder().accountId(accountId).build()
)
val response = call.getMainResponseBlocking<GetMailboxMethodResponse>()
val foldersOnServer = response.list
@ -91,19 +93,24 @@ internal class CommandRefreshFolderList(
private fun fetchMailboxChanges(state: String): UpdateState {
val multiCall = jmapClient.newMultiCall()
val mailboxChangesCall = multiCall.call(ChangesMailboxMethodCall(accountId, state))
val mailboxChangesCall = multiCall.call(
ChangesMailboxMethodCall.builder()
.accountId(accountId)
.sinceState(state)
.build()
)
val createdMailboxesCall = multiCall.call(
GetMailboxMethodCall(
accountId,
mailboxChangesCall.createResultReference(ResultReference.Path.CREATED)
)
GetMailboxMethodCall.builder()
.accountId(accountId)
.idsReference(mailboxChangesCall.createResultReference(ResultReference.Path.CREATED))
.build()
)
val changedMailboxesCall = multiCall.call(
GetMailboxMethodCall(
accountId,
mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED),
mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED_PROPERTIES)
)
GetMailboxMethodCall.builder()
.accountId(accountId)
.idsReference(mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED))
.propertiesReference(mailboxChangesCall.createResultReference(ResultReference.Path.UPDATED_PROPERTIES))
.build()
)
multiCall.execute()

View file

@ -78,8 +78,13 @@ class CommandSync(
Timber.d("Fetching all messages in %s (%s)", backendFolder.name, folderServerId)
}
val queryEmailMethod = QueryEmailMethodCall(accountId, createEmailQuery(folderServerId), limit)
val queryEmailCall = jmapClient.call(queryEmailMethod)
val queryEmailCall = jmapClient.call(
QueryEmailMethodCall.builder()
.accountId(accountId)
.query(createEmailQuery(folderServerId))
.limit(limit)
.build()
)
val queryEmailResponse = queryEmailCall.getMainResponseBlocking<QueryEmailMethodResponse>()
val queryState = if (queryEmailResponse.isCanCalculateChanges) queryEmailResponse.queryState else null
val remoteServerIds = queryEmailResponse.ids.toSet()
@ -113,8 +118,13 @@ class CommandSync(
Timber.d("Updating messages in %s (%s)", backendFolder.name, folderServerId)
val emailQuery = createEmailQuery(folderServerId)
val queryChangesEmailMethod = QueryChangesEmailMethodCall(accountId, queryState, emailQuery)
val queryChangesEmailCall = jmapClient.call(queryChangesEmailMethod)
val queryChangesEmailCall = jmapClient.call(
QueryChangesEmailMethodCall.builder()
.accountId(accountId)
.sinceQueryState(queryState)
.query(emailQuery)
.build()
)
val queryChangesEmailResponse = try {
queryChangesEmailCall.getMainResponseBlocking<QueryChangesEmailMethodResponse>()
@ -200,8 +210,13 @@ class CommandSync(
}
private fun getEmailPropertiesFromServer(emailIdsChunk: List<String>, properties: Array<String>): List<Email> {
val getEmailMethod = GetEmailMethodCall(accountId, emailIdsChunk.toTypedArray(), properties)
val getEmailCall = jmapClient.call(getEmailMethod)
val getEmailCall = jmapClient.call(
GetEmailMethodCall.builder()
.accountId(accountId)
.ids(emailIdsChunk.toTypedArray())
.properties(properties)
.build()
)
val getEmailResponse = getEmailCall.getMainResponseBlocking<GetEmailMethodResponse>()
return getEmailResponse.list.toList()