Skip to content

Commit

Permalink
feat: add state resent (#102)
Browse files Browse the repository at this point in the history
* feat: add state resent
* chore: prepare release 3.3.0
  • Loading branch information
tinect authored Feb 12, 2025
1 parent ad980a1 commit 40e719d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frosh/mail-platform-archive",
"version": "3.2.0",
"version": "3.3.0",
"description": "Mail Archive",
"type": "shopware-platform-plugin",
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions src/Controller/Api/MailArchiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public function resend(Request $request, Context $context): JsonResponse

$this->mailSender->send($email);

$this->froshMailArchiveRepository->update([[
'id' => $mailId,
'transportState' => MailSender::TRANSPORT_STATE_RESENT,
]], $context);

return new JsonResponse([
'success' => true,
]);
Expand Down
38 changes: 38 additions & 0 deletions src/Migration/Migration1739273849MigrateResentState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Frosh\MailArchive\Migration;

use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Migration\MigrationStep;

class Migration1739273849MigrateResentState extends MigrationStep
{
public function getCreationTimestamp(): int
{
return 1739273849;
}

public function update(Connection $connection): void
{
$sourceMailIds = $connection->fetchFirstColumn('SELECT source_mail_id FROM frosh_mail_archive WHERE source_mail_id IS NOT NULL GROUP BY source_mail_id;');

if (empty($sourceMailIds)) {
return;
}

$updateQuery = $connection->createQueryBuilder();
$updateQuery->update('frosh_mail_archive');
$updateQuery->set('transport_state', '\'resent\'');
$updateQuery->where('id IN (:ids)');

foreach (array_chunk($sourceMailIds, 1000) as $chunk) {
$updateQuery->setParameter('ids', $chunk, ArrayParameterType::BINARY);
$updateQuery->executeStatement();
}
}

public function updateDestructive(Connection $connection): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>
<template #column-success="{item}">
<div>
<sw-color-badge v-if="item.transportState === 'sent'"
<sw-color-badge v-if="item.transportState === 'sent' || item.transportState === 'resent'"
color="#37d046"
rounded
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Component.register('frosh-mail-archive-index', {
value: 'pending',
label: this.translateState('pending'),
},
{
value: 'resent',
label: this.translateState('resent'),
},
];
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"state": {
"pending": "ausstehend",
"sent": "gesendet",
"resent": "erneut gesendet",
"failed": "fehlgeschlagen",
"unknown": "unbekannt"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"state": {
"pending": "pending",
"sent": "sent",
"resent": "resent",
"failed": "failed",
"unknown": "unknown"
},
Expand Down
1 change: 1 addition & 0 deletions src/Services/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MailSender extends AbstractMailSender
public const TRANSPORT_STATE_PENDING = 'pending';
public const TRANSPORT_STATE_FAILED = 'failed';
public const TRANSPORT_STATE_SENT = 'sent';
public const TRANSPORT_STATE_RESENT = 'resent';

public const FROSH_MESSAGE_ID_HEADER = 'Frosh-Message-ID';

Expand Down

0 comments on commit 40e719d

Please sign in to comment.