TF-3334 Remove Email/get of unsubscribe email action

This commit is contained in:
dab246
2024-12-19 01:08:19 +07:00
committed by Dat H. Pham
parent eb51e9b3b1
commit 6063f4b832
9 changed files with 27 additions and 30 deletions
+14 -13
View File
@@ -678,17 +678,13 @@ class EmailAPI with HandleSetErrorMixin {
}
}
Future<Email> unsubscribeMail(Session session, AccountId accountId, EmailId emailId) async {
Future<void> unsubscribeMail(Session session, AccountId accountId, EmailId emailId) async {
final setEmailMethod = SetEmailMethod(accountId)
..addUpdates(emailId.generateMapUpdateObjectUnsubscribeMail());
final getEmailMethod = GetEmailMethod(accountId)
..addIds({emailId.id})
..addProperties(ThreadConstants.propertiesDefault);
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
requestBuilder.invocation(setEmailMethod);
final getEmailInvocation = requestBuilder.invocation(getEmailMethod);
final setEmailInvocation = requestBuilder.invocation(setEmailMethod);
final capabilities = setEmailMethod.requiredCapabilities.toCapabilitiesSupportTeamMailboxes(session, accountId);
@@ -697,14 +693,19 @@ class EmailAPI with HandleSetErrorMixin {
.build()
.execute();
final getEmailResponse = response.parse<GetEmailResponse>(
getEmailInvocation.methodCallId,
GetEmailResponse.deserialize);
final setEmailResponse = response.parse<SetEmailResponse>(
setEmailInvocation.methodCallId,
SetEmailResponse.deserialize,
);
if (getEmailResponse?.list.isNotEmpty == true) {
return getEmailResponse!.list.first;
} else {
throw NotFoundEmailException();
final emailIdUpdated = setEmailResponse?.updated
?.keys
.map((id) => EmailId(id))
.toList() ?? [];
final mapErrors = handleSetResponse([setEmailResponse]);
if (emailIdUpdated.isEmpty) {
throw SetMethodException(mapErrors);
}
}