44 Commits

Author SHA1 Message Date
Sebastian f39dd75ae5 fix: folder deletion while in trash
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-08-07 20:45:29 -04:00
Sebastian b60341f62d fix: message sending
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-30 21:03:59 -04:00
Sebastian 4cd249d019 fix: attachment upload on send
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-29 21:24:05 -04:00
Sebastian 152a8141d0 fix: logging
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-29 21:20:05 -04:00
Sebastian 5aa95fa329 feat: sync sending identities
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-28 21:50:37 -04:00
Sebastian f0b0f87ce2 fix: primary address saving
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-28 21:02:51 -04:00
Sebastian 75a462ad18 fix: disable auto complete
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-28 20:52:53 -04:00
Sebastian 8af08d8936 refactor: migrate to scoped execution contexts
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-27 00:52:29 -04:00
Sebastian edc1aece13 Merge pull request 'fix(deps): update dependency pinia to v4' (#57) from renovate/pinia-4.x into main
Reviewed-on: #57
2026-07-24 14:02:16 +00:00
Sebastian b81070338d fix(deps): update dependency pinia to v4
Build Test / test (pull_request) Successful in 35s
JS Unit Tests / test (pull_request) Successful in 37s
PHP Integration Tests / Integration Tests (pull_request) Successful in 56s
PHP Unit Tests / test (pull_request) Successful in 1m9s
2026-07-24 13:58:43 +00:00
Sebastian ab24fe2b54 Merge pull request 'chore(deps): update dependency vue-router to v5.2.0' (#63) from renovate/vue-router-5.x-lockfile into main
Reviewed-on: #63
2026-07-24 13:56:34 +00:00
Sebastian 3073cf9f75 Merge pull request 'chore(deps): update dependency @vitejs/plugin-vue to v6.0.8' (#60) from renovate/vitejs-plugin-vue-6.x-lockfile into main
Reviewed-on: #60
2026-07-24 13:55:54 +00:00
Sebastian 8cf4993107 Merge pull request 'chore(deps): update dependency vue-tsc to v3.3.8' (#61) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #61
2026-07-24 13:55:47 +00:00
Sebastian 5bda58fbb9 Merge pull request 'chore(deps): update dependency vuetify to v4.1.6' (#62) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #62
2026-07-24 13:55:32 +00:00
Sebastian b6bc83e432 chore(deps): update dependency vue-router to v5.2.0
Build Test / test (pull_request) Successful in 36s
JS Unit Tests / test (pull_request) Successful in 34s
PHP Integration Tests / Integration Tests (pull_request) Successful in 2m33s
PHP Unit Tests / test (pull_request) Successful in 2m18s
2026-07-24 13:51:41 +00:00
Sebastian 02f3662f40 chore(deps): update dependency vuetify to v4.1.6
Build Test / test (pull_request) Successful in 40s
JS Unit Tests / test (pull_request) Successful in 36s
PHP Unit Tests / test (pull_request) Successful in 1m40s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m50s
2026-07-24 13:51:36 +00:00
Sebastian 2dd56e0662 chore(deps): update dependency vue-tsc to v3.3.8
JS Unit Tests / test (pull_request) Successful in 1m17s
Build Test / test (pull_request) Successful in 1m20s
PHP Unit Tests / test (pull_request) Successful in 1m47s
PHP Integration Tests / Integration Tests (pull_request) Successful in 3m10s
2026-07-24 13:51:34 +00:00
Sebastian d449a71e80 chore(deps): update dependency @vitejs/plugin-vue to v6.0.8
JS Unit Tests / test (pull_request) Successful in 1m7s
Build Test / test (pull_request) Successful in 1m23s
PHP Unit Tests / test (pull_request) Successful in 2m23s
PHP Integration Tests / Integration Tests (pull_request) Successful in 4m5s
2026-07-24 13:51:31 +00:00
Sebastian 1310de8a15 Merge pull request 'chore(deps): update mongo docker tag to v8' (#59) from renovate/mongo-8.x into main
Reviewed-on: #59
2026-07-24 04:49:46 +00:00
Sebastian c7eb46c7ac chore(deps): update mongo docker tag to v8
Build Test / test (pull_request) Successful in 1m26s
JS Unit Tests / test (pull_request) Successful in 1m29s
PHP Unit Tests / test (pull_request) Successful in 2m13s
PHP Integration Tests / Integration Tests (pull_request) Successful in 2m22s
2026-07-24 04:38:37 +00:00
Sebastian c58d99988c Merge pull request 'chore: implement js test suites' (#58) from chore/js-test-suites into main
Reviewed-on: #58
2026-07-24 04:37:07 +00:00
Sebastian f5e7fa5f81 chore: implement js test suites
JS Unit Tests / test (pull_request) Successful in 40s
Build Test / test (pull_request) Successful in 42s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m20s
PHP Unit Tests / test (pull_request) Successful in 1m54s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-24 00:34:39 -04:00
Sebastian 9a243e2c61 Merge pull request 'chore(deps): update dependency vue-router to v5.2.0' (#54) from renovate/vue-router-5.x-lockfile into main
Reviewed-on: #54
2026-07-24 03:58:09 +00:00
Sebastian 4a8cea943b Merge pull request 'chore(deps): update dependency vue-tsc to v3.3.8' (#53) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #53
2026-07-24 03:22:10 +00:00
Sebastian 8965c047d1 Merge pull request 'chore(deps): update dependency @vitejs/plugin-vue to v6.0.8' (#49) from renovate/vitejs-plugin-vue-6.x-lockfile into main
Reviewed-on: #49
2026-07-24 03:22:00 +00:00
Sebastian 7fa75dafc9 Merge pull request 'chore(deps): update dependency vuetify to v4.1.6' (#46) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #46
2026-07-24 03:21:51 +00:00
Sebastian 8eb245f52f Merge pull request 'chore(deps): update dependency vue to v3.5.40' (#50) from renovate/vue-monorepo into main
Reviewed-on: #50
2026-07-24 03:21:20 +00:00
Sebastian 3c4b864339 chore(deps): update dependency vue-router to v5.2.0
JS Unit Tests / test (pull_request) Successful in 45s
Build Test / test (pull_request) Failing after 50s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m37s
PHP Unit Tests / test (pull_request) Successful in 2m46s
2026-07-24 02:56:25 +00:00
Sebastian 64b933534b chore(deps): update dependency vuetify to v4.1.6
Build Test / test (pull_request) Failing after 31s
JS Unit Tests / test (pull_request) Successful in 34s
PHP Unit Tests / test (pull_request) Successful in 1m57s
PHP Integration Tests / Integration Tests (pull_request) Successful in 2m40s
2026-07-24 02:56:16 +00:00
Sebastian d3f383e937 chore(deps): update dependency vue-tsc to v3.3.8
Build Test / test (pull_request) Failing after 36s
JS Unit Tests / test (pull_request) Successful in 29s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m33s
PHP Unit Tests / test (pull_request) Successful in 2m52s
2026-07-24 02:56:11 +00:00
Sebastian 816c1cf931 chore(deps): update dependency vue to v3.5.40
Build Test / test (pull_request) Failing after 41s
JS Unit Tests / test (pull_request) Failing after 31s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m41s
PHP Unit Tests / test (pull_request) Successful in 1m36s
2026-07-24 02:56:08 +00:00
Sebastian 072ea8c450 chore(deps): update dependency @vitejs/plugin-vue to v6.0.8
Build Test / test (pull_request) Failing after 57s
JS Unit Tests / test (pull_request) Successful in 50s
PHP Unit Tests / test (pull_request) Successful in 2m25s
PHP Integration Tests / Integration Tests (pull_request) Successful in 2m53s
2026-07-24 02:56:01 +00:00
Sebastian 44c3b629a2 Merge pull request 'Chore/php83 test suites' (#52) from chore/php83-test-suites into main
Reviewed-on: #52
2026-07-24 02:43:18 +00:00
Sebastian aa0ac2da51 fix: install module dependencies before running integration tests
JS Unit Tests / test (pull_request) Successful in 40s
PHP Unit Tests / test (pull_request) Successful in 1m16s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m27s
Build Test / test (pull_request) Failing after 25s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 22:32:09 -04:00
Sebastian 4ef881e5c1 chore: implement php test suites
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 22:20:36 -04:00
Sebastian dc6d6081ee fix: returned identifier on create and modify
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-19 06:45:48 -04:00
Sebastian 1a5339f069 Merge pull request 'chore(deps): update dependency vue-tsc to v3.3.7' (#45) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #45
2026-07-17 23:18:12 +00:00
Sebastian 9d95521247 Merge pull request 'chore(deps): update vitest monorepo to v4.1.10' (#47) from renovate/vitest-monorepo into main
Reviewed-on: #47
2026-07-17 23:17:58 +00:00
Sebastian cfb99dfc01 Merge pull request 'chore(deps): update dependency typescript to v7' (#48) from renovate/typescript-7.x into main
Reviewed-on: #48
2026-07-17 23:17:50 +00:00
Sebastian 609e7e577c Merge pull request 'chore(deps): update dependency vite to v8.1.5' (#44) from renovate/vite-8.x-lockfile into main
Reviewed-on: #44
2026-07-17 23:17:41 +00:00
Sebastian fa5e91f0a9 chore(deps): update dependency vite to v8.1.5
JS Unit Tests / test (pull_request) Failing after 13m2s
Build Test / test (pull_request) Failing after 13m4s
PHP Unit Tests / test (pull_request) Failing after 18m0s
2026-07-17 03:08:36 +00:00
Sebastian 024c9656d4 chore(deps): update dependency typescript to v7
PHP Unit Tests / test (pull_request) Failing after 14m47s
JS Unit Tests / test (pull_request) Failing after 15m6s
Build Test / test (pull_request) Failing after 15m8s
2026-07-10 03:08:12 +00:00
Sebastian b950022081 chore(deps): update vitest monorepo to v4.1.10
JS Unit Tests / test (pull_request) Failing after 11m9s
Build Test / test (pull_request) Failing after 11m33s
PHP Unit Tests / test (pull_request) Failing after 16m6s
2026-07-10 03:08:04 +00:00
Sebastian 2da8bebe61 chore(deps): update dependency vue-tsc to v3.3.7
PHP Unit Tests / test (pull_request) Failing after 12m26s
JS Unit Tests / test (pull_request) Failing after 12m36s
Build Test / test (pull_request) Failing after 12m38s
2026-07-10 03:07:55 +00:00
17 changed files with 1825 additions and 1031 deletions
@@ -0,0 +1,59 @@
name: PHP Integration Tests
on:
pull_request:
workflow_dispatch:
jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
services:
mongo:
image: mongo:8
options: >-
--health-cmd "mongosh --quiet --eval \"db.adminCommand('ping')\""
--health-interval 5s
--health-timeout 5s
--health-retries 12
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install server
uses: ./action-server-install
with:
install-php: 'true'
php-version: '8.5'
server-path: './server'
database-uri: 'mongodb://mongo:27017/?tls=false'
database-name: 'ktrix_ci'
app-environment: 'test'
- name: Checkout module under test
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
path: server/modules/provider_jmapc
github-server-url: https://git.ktrix.dev
- name: Install module dependencies
run: composer install --prefer-dist --no-progress
working-directory: server/modules/provider_jmapc
- name: Install and enable module
working-directory: server
run: |
php bin/console module:install provider_jmapc
php bin/console module:enable provider_jmapc
- name: Run integration tests
working-directory: server/modules/provider_jmapc
run: composer test:integration
+1 -5
View File
@@ -14,11 +14,7 @@ node_modules/
# Backend development
/lib/vendor/
coverage/
phpunit.xml.cache
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache
.phpstan.cache
*.cache
.phpactor/
# Editors
+6 -5
View File
@@ -10,7 +10,7 @@
"config": {
"optimize-autoloader": true,
"platform": {
"php": "8.2"
"php": "8.3"
},
"autoloader-suffix": "ProviderJmapc",
"vendor-dir": "lib/vendor",
@@ -27,11 +27,11 @@
"require": {
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/psr7": "^2.0",
"php": ">=8.2 <=8.5",
"php": ">=8.3 <=8.5",
"sebastiankrupinski/jmap-client-php": "dev-main"
},
"require-dev": {
"phpunit/phpunit": "^11.0"
"phpunit/phpunit": "^12.0"
},
"autoload": {
"psr-4": {
@@ -48,7 +48,8 @@
],
"post-update-cmd": [
],
"test:unit": "phpunit --configuration tests/php/phpunit.unit.xml --colors=always --testdox",
"test:coverage": "XDEBUG_MODE=coverage phpunit --configuration tests/php/phpunit.unit.xml --coverage-html .phpunit.coverage --coverage-text"
"test:unit": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --colors=always --testdox",
"test:integration": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Integration Tests\" --colors=always --testdox",
"test:coverage": "XDEBUG_MODE=coverage phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --coverage-html .phpunit.coverage --coverage-text"
}
}
Generated
+271 -355
View File
File diff suppressed because it is too large Load Diff
+62 -3
View File
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace KTXM\ProviderJmapc\Providers\Mail;
use KTXF\Mail\Object\Address;
use KTXF\Mail\Provider\ProviderBaseInterface;
use KTXF\Mail\Provider\ProviderServiceDiscoverInterface;
use KTXF\Mail\Provider\ProviderServiceMutateInterface;
@@ -142,7 +143,64 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
}
$created = $this->serviceStore->create($tenantId, $userId, $service);
return (string) $created['id'];
$this->serviceIdentitiesSync($tenantId, $userId, (new Service())->fromStore($created));
return (string) $created['sid'];
}
/**
* Fetches sending identities from the JMAP server and overwrites
* primaryAddress/secondaryAddresses on the service with them.
*/
private function serviceIdentitiesSync(string $tenantId, string $userId, Service $service): void
{
try {
$client = RemoteService::freshClient($service);
$identities = RemoteService::mailService($client)->identityFetch();
// A JMAP server may expose multiple identities sharing the same
// address (e.g. distinct signatures/display names for one
// mailbox) — collapse those down to one entry per address,
// keeping the first label seen.
$addresses = [];
foreach ($identities as $identity) {
if ($identity->address() === null) {
continue;
}
$key = strtolower($identity->address());
if (!isset($addresses[$key])) {
$addresses[$key] = Address::fromArray(['address' => $identity->address(), 'label' => $identity->name()]);
}
}
$addresses = array_values($addresses);
if (empty($addresses)) {
return;
}
$currentAddress = strtolower($service->getPrimaryAddress()->getAddress());
$primaryIndex = 0;
foreach ($addresses as $index => $address) {
if (strtolower($address->getAddress()) === $currentAddress) {
$primaryIndex = $index;
break;
}
}
$secondary = [];
foreach ($addresses as $index => $address) {
if ($index !== $primaryIndex) {
$secondary[] = $address;
}
}
$service->setPrimaryAddress($addresses[$primaryIndex]);
$service->setSecondaryAddresses($secondary);
$this->serviceStore->modify($tenantId, $userId, $service);
} catch (\Throwable) {
// Server may not support urn:ietf:params:jmap:submission, or have
// no identities configured — fall back to what the user entered.
}
}
public function serviceModify(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
@@ -151,8 +209,9 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
throw new \InvalidArgumentException('Service must be instance of JMAP Service');
}
$updated = $this->serviceStore->modify($tenantId, $userId, $service);
return (string) $updated['sid'];
$this->serviceStore->modify($tenantId, $userId, $service);
$this->serviceIdentitiesSync($tenantId, $userId, $service);
return (string) $service->identifier();
}
public function serviceDestroy(string $tenantId, string $userId, ResourceServiceMutateInterface $service): bool
+54 -12
View File
@@ -206,8 +206,9 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
if (isset($data[self::PROPERTY_IDENTITY])) {
$this->setIdentity($this->freshIdentity(null, $data[self::PROPERTY_IDENTITY]));
}
if (isset($data[self::PROPERTY_PRIMARY_ADDRESS]) && is_string($data[self::PROPERTY_PRIMARY_ADDRESS])) {
$this->setPrimaryAddress(new Address($data[self::PROPERTY_PRIMARY_ADDRESS]));
if (isset($data[self::PROPERTY_PRIMARY_ADDRESS])) {
$value = $data[self::PROPERTY_PRIMARY_ADDRESS];
$this->setPrimaryAddress(is_array($value) ? Address::fromArray($value) : new Address((string)$value));
}
if (isset($data[self::PROPERTY_SECONDARY_ADDRESSES]) && is_array($data[self::PROPERTY_SECONDARY_ADDRESSES])) {
$this->setSecondaryAddresses(array_map(
@@ -483,17 +484,34 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
}
}
// we need to determine if the folder being deleted is already in the trash
if (str_starts_with((string) $target->collection(), (string) $deleteTargetIdentifier?->collection())) {
// if so, we should hard delete instead of moving to avoid duplicates in the trash
$deleteMode = 'hard';
if ($deleteMode === 'soft') {
$targetMailbox = $this->mailService->collectionFetch((string) $target->collection());
if ($targetMailbox === null) {
throw new \RuntimeException('Collection not found for delete operation');
}
$targetIdentifier = (string) $target->collection();
$trashIdentifier = (string) $deleteTargetIdentifier->collection();
$parentIdentifier = isset($targetMailbox['parentId'])
? (string) $targetMailbox['parentId']
: null;
// JMAP mailbox IDs are opaque, so containment must be determined
// from parentId rather than by comparing ID prefixes.
if ($targetIdentifier === $trashIdentifier || $parentIdentifier === $trashIdentifier) {
$deleteMode = 'hard';
}
}
$result = match ($deleteMode) {
'soft' => $this->collectionMove($deleteTargetIdentifier, $target),
'hard' => $this->mailService->collectionDestroy($target->collection(), $force),
};
return $result;
if ($deleteMode === 'soft') {
return $this->collectionMove($deleteTargetIdentifier, $target);
}
if ($this->mailService->collectionDestroy((string) $target->collection(), $force) === null) {
throw new \RuntimeException("Failed to delete collection: {$target->collection()}");
}
return true;
}
public function collectionMove(CollectionIdentifier $target, CollectionIdentifier $source): CollectionBaseInterface
@@ -879,7 +897,31 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC
);
}
$nativeMessage = $this->normalizeMessageProperties($message)->toJmap();
$nativeProperties = $this->normalizeMessageProperties($message);
$attachments = $nativeProperties->getAttachments();
foreach ($attachments as $attachment) {
if ($attachment->getBlobId() !== null) {
continue;
}
$content = $attachment->getContent();
if ($content === null) {
throw new \InvalidArgumentException(sprintf(
'Attachment "%s" has neither content nor a JMAP blob identifier',
$attachment->getName() ?? 'unnamed',
));
}
$attachment->setBlobId($this->mailService->blobDeposit(
$attachment->getType() ?? 'application/octet-stream',
$content,
));
}
if ($attachments !== []) {
$nativeProperties->setAttachments(...$attachments);
}
$nativeMessage = $nativeProperties->toJmap();
$transportId = $this->mailService->entitySubmitFresh($identityId, $nativeMessage, $preSendTarget->collection(), $postSentTarget->collection());
return new EntitySubmitResult(
+1 -1
View File
@@ -97,7 +97,7 @@ class Provider implements IProviderBase, IProviderServiceMutate
}
// Note: This simplified interface doesn't pass tenantId
// Will need to get it from SessionTenant in actual implementation
// Will need to get it from TenantContextInterface in actual implementation
throw new \RuntimeException('Use Mail Provider interface for service creation');
}
+52 -31
View File
@@ -912,23 +912,44 @@ class RemoteMailService {
*
* @since Release 2.0.0
*/
public function entitySubmitFresh(string $identityId, array $message, string $preSendTarget, string $postSentTarget): string {
public function entitySubmitFresh(string $identityId, array $data, string $preSendTarget, string $postSentTarget): string {
$mail = new MailParametersRequest();
$mail->parametersRaw($message);
$message = new MailParametersRequest();
$message->parametersRaw($data);
$messageCreateId = 'm_' . uniqid();
$submissionCreateId = 's_' . uniqid();
$messageId = 'm_' . uniqid();
$submissionId = 's_' . uniqid();
$r0 = new MailSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
$createdMessage = $r0->create($messageCreateId, $mail);
$createdMessage->in($preSendTarget);
$m0 = $r0->create($messageId, $message);
$m0->in($preSendTarget);
$m0->draft(true);
$m0->seen(true);
$r1 = new MailSubmissionSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
$submission = $r1->create($submissionCreateId);
$submission->identity($identityId);
$submission->message('#' . $messageCreateId);
$r1->completionUpdate('#' . $messageId, [
'mailboxIds/' . $postSentTarget => true,
'mailboxIds/' . $preSendTarget => null,
'keywords/$draft' => null,
]);
$s0 = $r1->create($submissionId);
$s0->identity($identityId);
$s0->message('#' . $messageId);
$bundle = $this->dataStore->perform([$r0, $r1]);
$messageResponse = $bundle->response(0);
if ($messageResponse instanceof ResponseException) {
throw new Exception($messageResponse->type() . ': ' . $messageResponse->description(), 1);
}
if (method_exists($messageResponse, 'createFailure')) {
$failure = $messageResponse->createFailure($messageId);
if (is_array($failure)) {
$type = $failure['type'] ?? 'unknownError';
$description = $failure['description'] ?? 'Email creation failed';
throw new Exception($type . ': ' . $description, 1);
}
}
$response = $bundle->response(1);
if ($response instanceof ResponseException) {
if ($response->type() === 'unknownMethod') {
@@ -937,7 +958,19 @@ class RemoteMailService {
throw new Exception($response->type() . ': ' . $response->description(), 1);
}
return $this->extractSubmissionIdentifier($response, $submissionCreateId);
return $this->extractSubmissionIdentifier($response, $submissionId);
}
/**
* Upload attachment content and return its JMAP blob identifier.
*/
public function blobDeposit(string $type, string $data): string {
$response = json_decode($this->dataStore->upload($this->dataAccount, $type, $data), true);
if (!is_array($response) || !isset($response['blobId']) || !is_string($response['blobId']) || $response['blobId'] === '') {
throw new Exception('JMAP attachment upload did not return a blob identifier', 1);
}
return $response['blobId'];
}
/**
@@ -953,18 +986,18 @@ class RemoteMailService {
$requests = [];
if ($patch !== null && $patch !== []) {
$draftMutation = new MailParametersRequest();
$draftMutation->parametersRaw($patch);
$m0 = new MailParametersRequest();
$m0->parametersRaw($patch);
$r0 = new MailSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
$r0->update($draftId, $draftMutation);
$r0->update($draftId, $m0);
$requests[] = $r0;
}
$submissionCreateId = 's_' . uniqid();
$submissionId = 's_' . uniqid();
$r1 = new MailSubmissionSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
$submission = $r1->create($submissionCreateId);
$submission->identity($identityId);
$submission->message($draftId);
$s0 = $r1->create($submissionId);
$s0->identity($identityId);
$s0->message($draftId);
$requests[] = $r1;
$bundle = $this->dataStore->perform($requests);
@@ -977,19 +1010,7 @@ class RemoteMailService {
throw new Exception($response->type() . ': ' . $response->description(), 1);
}
return $this->extractSubmissionIdentifier($response, $submissionCreateId);
}
private function collectionByRole(string $role): ?string {
$filter = $this->collectionListFilter();
$filter->condition('role', $role);
$collections = $this->collectionList(null, $filter, null);
if ($collections === []) {
return null;
}
return (string)array_key_first($collections);
return $this->extractSubmissionIdentifier($response, $submissionId);
}
private function extractSubmissionIdentifier(object $response, string $createId): string {
+9 -8
View File
@@ -13,7 +13,7 @@ use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Psr7\HttpFactory;
use JmapClient\Authentication\Basic;
use JmapClient\Client as JmapClient;
use KTXC\Server;
use KTXF\Security\Crypto;
use KTXF\Resource\Provider\ResourceServiceIdentityBasic;
use KTXF\Resource\Provider\ResourceServiceLocationUri;
use KTXM\ProviderJmapc\Providers\Mail\Service as MailService;
@@ -73,10 +73,13 @@ class RemoteService {
}
// debugging
if ($service->getDebug()) {
$logDir = Server::getInstance()?->logDir();
$logDir .= '/jmap/' . $service->identifier() . '.json';
$logDirectory = dirname(__DIR__, 5) . '/var/logs/jmap';
if (!is_dir($logDirectory) && !mkdir($logDirectory, 0775, true) && !is_dir($logDirectory)) {
throw new \RuntimeException(sprintf('Unable to create JMAP log directory: %s', $logDirectory));
}
$logFile = $logDirectory . '/' . $service->identifier() . '.json';
$client->configureTransportLogState(true);
$client->configureTransportLogLocation($logDir);
$client->configureTransportLogLocation($logFile);
}
// return
return $client;
@@ -200,7 +203,7 @@ class RemoteService {
return $service;
}
public static function cookieStoreRetrieve(mixed $id): ?array {
public static function cookieStoreRetrieve(mixed $id, Crypto $crypto): ?array {
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
@@ -209,7 +212,6 @@ class RemoteService {
}
$data = file_get_contents($file);
$crypto = Server::getInstance()->container()->get(\KTXF\Security\Crypto::class);
$data = $crypto->decrypt($data);
if (!empty($data)) {
@@ -220,13 +222,12 @@ class RemoteService {
}
public static function cookieStoreDeposit(mixed $id, array $value): void {
public static function cookieStoreDeposit(mixed $id, array $value, Crypto $crypto): void {
if (empty($value)) {
return;
}
$crypto = Server::getInstance()->container()->get(\KTXF\Security\Crypto::class);
$data = $crypto->encrypt(json_encode($value));
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . (string)$id . '.jmapc';
+1243 -538
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -18,7 +18,7 @@
"test:coverage": "vitest run --coverage --config tests/js/vitest.config.ts"
},
"dependencies": {
"pinia": "^3.0.0",
"pinia": "^4.0.0",
"vue": "^3.5.18",
"vue-router": "^5.0.0",
"vuetify": "^4.0.0"
@@ -27,9 +27,12 @@
"@vitejs/plugin-vue": "^6.0.1",
"@vitest/coverage-v8": "^4.0.18",
"@vitest/ui": "^4.0.18",
"@vue/test-utils": "^2.4.10",
"@vue/tsconfig": "^0.9.0",
"jsdom": "^29.1.1",
"typescript": "~6.0.0",
"vite": "^8.0.0",
"vitest": "^4.0.18",
"vue-tsc": "^3.0.5"
}
}
+2 -2
View File
@@ -274,7 +274,7 @@ async function initiateOAuth() {
variant="outlined"
prepend-inner-icon="mdi-account"
class="mb-4"
autocomplete="username"
autocomplete="off"
autocorrect="off"
autocapitalize="none"
:rules="[rules.required]"
@@ -289,7 +289,7 @@ async function initiateOAuth() {
variant="outlined"
prepend-inner-icon="mdi-lock"
class="mb-4"
autocomplete="current-password"
autocomplete="new-password"
:rules="[rules.required]"
/>
</template>
+15 -65
View File
@@ -25,7 +25,7 @@ const settingGroups = [
title: 'Addresses',
value: 'addresses' as const,
icon: 'mdi-at',
description: 'Configure the primary mailbox identity and any sender aliases exposed by this service.'
description: 'View the primary mailbox identity and sender aliases synced from the JMAP server.'
},
{
title: 'Messages',
@@ -71,7 +71,7 @@ watch(
)
watch(
[deleteMode, deleteDestination, primaryAddress, secondaryAddresses],
[deleteMode, deleteDestination],
() => {
const nextService = props.service ?? new ServiceObject()
const nextAuxiliary = {
@@ -83,13 +83,9 @@ watch(
}
if (sameAuxiliary(nextService.auxiliary ?? {}, nextAuxiliary)) {
if (sameAddresses(nextService)) {
return
}
return
}
nextService.primaryAddress = primaryAddress.value.empty ? null : primaryAddress.value
nextService.secondaryAddresses = dedupeAddresses(secondaryAddresses.value)
nextService.auxiliary = nextAuxiliary
emit('update:service', nextService)
},
@@ -111,44 +107,10 @@ function normalizeDeleteDestination(value: string): string {
return trimmedValue.length > 0 ? trimmedValue : 'Trash'
}
function dedupeAddresses(entries: ServiceAddressObject[]): ServiceAddressObject[] {
const populated = entries.filter(entry => !entry.empty)
return populated.filter((entry, index) =>
populated.findIndex(candidate => candidate.matches(entry.address)) === index)
}
function addSecondaryAddress() {
secondaryAddresses.value.push(new ServiceAddressObject())
}
function removeSecondaryAddress(index: number) {
secondaryAddresses.value.splice(index, 1)
}
function validAddress(value: string): boolean | string {
const trimmedValue = value.trim()
return trimmedValue.length === 0 || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmedValue) || 'Invalid email address'
}
function sameAuxiliary(current: Record<string, any>, next: Record<string, any>): boolean {
return (current.deleteMode === 'hard' ? 'hard' : 'soft') === next.deleteMode
&& (current.deleteDestination ?? undefined) === (next.deleteDestination ?? undefined)
}
function sameAddresses(service: ServiceObject): boolean {
const nextPrimary = primaryAddress.value.empty ? null : primaryAddress.value
const nextSecondary = dedupeAddresses(secondaryAddresses.value)
return sameAddress(service.primaryAddress, nextPrimary)
&& service.secondaryAddresses.length === nextSecondary.length
&& service.secondaryAddresses.every((entry, index) => sameAddress(entry, nextSecondary[index]))
}
function sameAddress(current: ServiceAddressObject | null, next: ServiceAddressObject | null): boolean {
if (current === null || next === null) {
return current === next
}
return current.equals(next)
}
</script>
<template>
@@ -176,69 +138,57 @@ function sameAddress(current: ServiceAddressObject | null, next: ServiceAddressO
<div class="jmap-settings-card">
<h3 class="text-h6 mb-2">Addresses</h3>
<p class="text-body-2 text-medium-emphasis mb-6">
Configure the primary mailbox identity and any additional sender aliases exposed by this service.
The primary mailbox identity and sender aliases are managed by the JMAP server and synced automatically.
</p>
<div class="text-subtitle-2 mb-2">Primary Address</div>
<div class="d-flex ga-2 mb-6">
<v-text-field
v-model="primaryAddress.label"
:model-value="primaryAddress.label"
label="Display Name"
variant="outlined"
density="compact"
hide-details="auto"
readonly
/>
<v-text-field
v-model="primaryAddress.address"
:model-value="primaryAddress.address"
label="Email Address"
variant="outlined"
density="compact"
prepend-inner-icon="mdi-email-outline"
:rules="[validAddress]"
hide-details="auto"
readonly
/>
</div>
<div class="text-subtitle-2 mb-2">Secondary Addresses</div>
<p v-if="secondaryAddresses.length === 0" class="text-body-2 text-medium-emphasis">
No aliases reported by the server.
</p>
<div
v-for="(entry, index) in secondaryAddresses"
:key="index"
class="d-flex ga-2 mb-2"
>
<v-text-field
v-model="entry.label"
:model-value="entry.label"
label="Display Name"
variant="outlined"
density="compact"
hide-details="auto"
readonly
/>
<v-text-field
v-model="entry.address"
:model-value="entry.address"
label="Email Address"
variant="outlined"
density="compact"
prepend-inner-icon="mdi-email-multiple-outline"
:rules="[validAddress]"
hide-details="auto"
readonly
/>
<v-btn
icon
size="small"
variant="text"
@click="removeSecondaryAddress(index)"
>
<v-icon>mdi-delete-outline</v-icon>
<v-tooltip activator="parent" location="bottom">Remove Alias</v-tooltip>
</v-btn>
</div>
<v-btn
variant="tonal"
prepend-icon="mdi-plus"
@click="addSecondaryAddress"
>
Add Alias
</v-btn>
</div>
</v-window-item>
+3 -3
View File
@@ -1,17 +1,17 @@
import { fileURLToPath } from 'node:url'
import { defineConfig, configDefaults } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import vuetify from 'vite-plugin-vuetify'
import path from 'path'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
export default defineConfig({
plugins: [vue(), vuetify()],
plugins: [vue()],
resolve: {
alias: {
'@KTXC': path.resolve(__dirname, '../../../core/src'),
'@': path.resolve(__dirname, '../../src'),
'@KTXC': path.resolve(__dirname, '../../../../core/src'),
},
},
test: {
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace KTXT\ProviderJmapc\Integration;
use PHPUnit\Framework\TestCase;
class BaseTest extends TestCase
{
public function testBasicAssertion(): void
{
$this->assertTrue(true);
}
public function testArrayOperations(): void
{
$array = ['foo' => 'bar'];
$this->assertArrayHasKey('foo', $array);
$this->assertEquals('bar', $array['foo']);
}
public function testStringOperations(): void
{
$string = 'Hello, World!';
$this->assertStringContainsString('World', $string);
$this->assertEquals(13, strlen($string));
}
}
+10
View File
@@ -2,6 +2,16 @@
require dirname(__DIR__, 2).'/lib/vendor/autoload.php';
// When this module is checked out inside a full server (server/modules/<handle>,
// as it is in CI and in this monorepo checkout), also load the server's own
// core/shared autoloader so tests can reference framework (KTXC/KTXF) types.
// Standalone module checkouts without a server alongside them skip this.
define('SERVER_ROOT', dirname(__DIR__, 4));
$serverAutoload = SERVER_ROOT . '/vendor/autoload.php';
if (is_file($serverAutoload)) {
require $serverAutoload;
}
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
umask(0000);
}
@@ -21,6 +21,9 @@
<testsuite name="Unit Tests">
<directory>unit</directory>
</testsuite>
<testsuite name="Integration Tests">
<directory>Integration</directory>
</testsuite>
</testsuites>
<source ignoreSuppressionOfDeprecations="true"
@@ -29,8 +32,7 @@
restrictWarnings="true"
>
<include>
<directory>../../core/lib</directory>
<directory>../../shared/lib</directory>
<directory>../../lib</directory>
</include>
<deprecationTrigger>