TF-4195 Add interactor/repository/datasource to feature add a Label to an email

This commit is contained in:
dab246
2025-12-12 01:32:51 +07:00
committed by Dat H. Pham
parent b6027e996d
commit 0d247b30d7
19 changed files with 215 additions and 49 deletions
@@ -936,4 +936,30 @@ class EmailAPI with HandleSetErrorMixin, MailAPIMixin {
throw NotParsableBlobIdToEmailException();
}
}
Future<void> addLabelToEmail(
AccountId accountId,
EmailId emailId,
KeyWordIdentifier labelKeyword,
) async {
final method = SetEmailMethod(accountId)
..addUpdates({emailId.id: labelKeyword.generateLabelActionPath()});
final builder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
final invocation = builder.invocation(method);
final result =
await (builder..usings(method.requiredCapabilities)).build().execute();
final response = result.parse<SetEmailResponse>(
invocation.methodCallId,
SetEmailResponse.deserialize,
);
final emailIdsUpdated = response?.updated?.keys ?? <Id>[];
if (emailIdsUpdated.isEmpty || !emailIdsUpdated.contains(emailId.id)) {
throw parseErrorForSetResponse(response, emailId.id);
}
}
}