TF-1311 Add capability of Team-Mailbox for GetMailboxMethod

This commit is contained in:
dab246
2023-02-08 15:51:49 +07:00
committed by Dat Vu
parent b2af558790
commit 9a46f7f865
9 changed files with 23 additions and 19 deletions
@@ -23,7 +23,7 @@ abstract class MailboxDataSource {
Future<List<Mailbox>> getAllMailboxCache();
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState);
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState);
Future<void> update({List<Mailbox>? updated, List<Mailbox>? created, List<MailboxId>? destroyed});
@@ -34,7 +34,7 @@ class MailboxCacheDataSourceImpl extends MailboxDataSource {
}
@override
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) {
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
throw UnimplementedError();
}
@@ -40,9 +40,9 @@ class MailboxDataSourceImpl extends MailboxDataSource {
}
@override
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) {
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
return Future.sync(() async {
return await mailboxAPI.getChanges(accountId, sinceState);
return await mailboxAPI.getChanges(session, accountId, sinceState);
}).catchError((error) {
_exceptionThrower.throwException(error);
});
@@ -49,7 +49,7 @@ class MailboxAPI with HandleSetErrorMixin {
final queryInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
final capabilities = capabilitiesSupportedMailboxes(session, accountId);
final capabilities = capabilitiesForGetMailboxMethod(session, accountId);
final result = await (jmapRequestBuilder
..usings(capabilities))
@@ -63,7 +63,7 @@ class MailboxAPI with HandleSetErrorMixin {
return MailboxResponse(mailboxes: resultCreated?.list, state: resultCreated?.state);
}
Set<CapabilityIdentifier> capabilitiesSupportedMailboxes(Session session, AccountId accountId) {
Set<CapabilityIdentifier> capabilitiesForGetMailboxMethod(Session session, AccountId accountId) {
final getMailboxCreated = GetMailboxMethod(accountId);
try {
requireCapability(
@@ -76,7 +76,7 @@ class MailboxAPI with HandleSetErrorMixin {
}
}
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) async {
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) async {
final processingInvocation = ProcessingInvocation();
final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);
@@ -101,8 +101,10 @@ class MailboxAPI with HandleSetErrorMixin {
final getMailboxUpdatedInvocation = jmapRequestBuilder.invocation(getMailboxUpdated);
final getMailboxCreatedInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
final capabilities = capabilitiesForGetMailboxMethod(session, accountId);
final result = await (jmapRequestBuilder
..usings(getMailboxCreated.requiredCapabilities))
..usings(capabilities))
.build()
.execute();
@@ -51,7 +51,7 @@ class MailboxRepositoryImpl extends MailboxRepository {
State? sinceState = localMailboxResponse.state!;
while(hasMoreChanges && sinceState != null) {
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(accountId, sinceState);
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
hasMoreChanges = changesResponse.hasMoreChanges;
sinceState = changesResponse.newStateChanges;
@@ -115,14 +115,14 @@ class MailboxRepositoryImpl extends MailboxRepository {
}
@override
Stream<MailboxResponse> refresh(AccountId accountId, State currentState) async* {
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState) async* {
final localMailboxList = await mapDataSource[DataSourceType.local]!.getAllMailboxCache();
bool hasMoreChanges = true;
State? sinceState = currentState;
while(hasMoreChanges && sinceState != null) {
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(accountId, sinceState);
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
hasMoreChanges = changesResponse.hasMoreChanges;
sinceState = changesResponse.newStateChanges;