--wip-- [skip ci]

This commit is contained in:
philipp lang 2025-11-07 00:37:45 +01:00
parent 28b47a2910
commit d95ef84980
11 changed files with 60 additions and 3 deletions

View File

@ -2,7 +2,6 @@
namespace App\Form;
use App\Form\Actions\SettingStoreAction;
use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings;
use Lorisleiva\Actions\ActionRequest;
@ -11,6 +10,7 @@ class FormSettings extends LocalSettings implements Storeable
{
public string $registerUrl;
public string $clearCacheUrl;
public ?string $replyToMail;
public static function group(): string
{
@ -19,7 +19,7 @@ class FormSettings extends LocalSettings implements Storeable
public static function title(): string
{
return 'Formulare';
return 'Veranstaltungen';
}
/**
@ -30,6 +30,7 @@ class FormSettings extends LocalSettings implements Storeable
return [
'registerUrl' => 'present|string',
'clearCacheUrl' => 'present|string',
'replyToMail' => 'nullable|string|email',
];
}
@ -47,6 +48,7 @@ class FormSettings extends LocalSettings implements Storeable
'data' => [
'registerUrl' => $this->registerUrl,
'clearCacheUrl' => $this->clearCacheUrl,
'replyToMail' => $this->replyToMail,
]
]
];

View File

@ -24,6 +24,7 @@ class SettingStoreAction
'weeks' => 'required|numeric|gte:0',
'freshRememberInterval' => 'required|numeric|gte:0',
'active' => 'boolean',
'replyToMail' => 'nullable|string|email',
];
}
@ -33,6 +34,7 @@ class SettingStoreAction
$settings->formmail = EditorData::from($request->formmail);
$settings->yearlymail = EditorData::from($request->yearlymail);
$settings->weeks = $request->weeks;
$settings->replyToMail = $request->replyToMail;
$settings->freshRememberInterval = $request->freshRememberInterval;
$settings->active = $request->active;
$settings->yearlyMemberFilter = FilterScope::from($request->yearlyMemberFilter);

View File

@ -6,6 +6,7 @@ use App\Invoice\InvoiceSettings;
use App\Lib\Editor\EditorData;
use App\Prevention\Contracts\Preventable;
use App\Prevention\Data\PreventionData;
use App\Prevention\PreventionSettings;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Attachment;
use Illuminate\Mail\Mailable;
@ -19,6 +20,7 @@ class YearlyMail extends Mailable
use Queueable, SerializesModels;
public InvoiceSettings $settings;
public PreventionSettings $preventionSettings;
/**
* Create a new message instance.
@ -27,6 +29,7 @@ class YearlyMail extends Mailable
public function __construct(public Preventable $preventable, public EditorData $bodyText, public Collection $preventions)
{
$this->settings = app(InvoiceSettings::class);
$this->preventionSettings = app(PreventionSettings::class);
$this->bodyText = $this->bodyText
->replaceWithList('wanted', $preventions->map(fn($prevention) => $prevention->text())->toArray());
}
@ -38,9 +41,15 @@ class YearlyMail extends Mailable
*/
public function envelope()
{
return (new Envelope(
$envelope = (new Envelope(
subject: $this->preventable->preventableSubject(),
))->to($this->preventable->getMailRecipient()->email, $this->preventable->getMailRecipient()->name);
if ($this->preventionSettings->replyToMail !== null) {
$envelope->replyTo($this->preventionSettings->replyToMail);
}
return $envelope;
}
/**

View File

@ -15,6 +15,7 @@ class PreventionSettings extends LocalSettings
public int $freshRememberInterval;
public bool $active;
public FilterScope $yearlyMemberFilter;
public ?string $replyToMail;
/**
* @var array<int, string>
* @todo Create collection cast to Collection of enums
@ -49,6 +50,7 @@ class PreventionSettings extends LocalSettings
...$this->toArray(),
'weeks' => (string) $this->weeks,
'freshRememberInterval' => (string) $this->freshRememberInterval,
'replyToMail' => $this->replyToMail,
];
}
}

View File

@ -0,0 +1,12 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('form.replyToMail', '');
$this->migrator->add('prevention.replyToMail', '');
}
};

View File

@ -92,6 +92,8 @@ services:
socketi:
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
ports:
- "6001:6001"
environment:
SOKETI_DEFAULT_APP_ID: adremaid
SOKETI_DEFAULT_APP_KEY: adremakey
@ -104,6 +106,8 @@ services:
meilisearch:
image: getmeili/meilisearch:v1.6
ports:
- "7700:7700"
volumes:
- ./data/meilisearch:/meili_data
env_file:

View File

@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<svg x="0px" y="0px" viewBox="0 0 511.626 511.627" xml:space="preserve">
<g>
<g>
<path d="M392.857,292.354h-18.274c-2.669,0-4.859,0.855-6.563,2.573c-1.718,1.708-2.573,3.897-2.573,6.563v91.361 c0,12.563-4.47,23.315-13.415,32.262c-8.945,8.945-19.701,13.414-32.264,13.414H82.224c-12.562,0-23.317-4.469-32.264-13.414 c-8.945-8.946-13.417-19.698-13.417-32.262V155.31c0-12.562,4.471-23.313,13.417-32.259c8.947-8.947,19.702-13.418,32.264-13.418 h200.994c2.669,0,4.859-0.859,6.57-2.57c1.711-1.713,2.566-3.9,2.566-6.567V82.221c0-2.662-0.855-4.853-2.566-6.563 c-1.711-1.713-3.901-2.568-6.57-2.568H82.224c-22.648,0-42.016,8.042-58.102,24.125C8.042,113.297,0,132.665,0,155.313v237.542 c0,22.647,8.042,42.018,24.123,58.095c16.086,16.084,35.454,24.13,58.102,24.13h237.543c22.647,0,42.017-8.046,58.101-24.13 c16.085-16.077,24.127-35.447,24.127-58.095v-91.358c0-2.669-0.856-4.859-2.574-6.57 C397.709,293.209,395.519,292.354,392.857,292.354z"/>
<path d="M506.199,41.971c-3.617-3.617-7.905-5.424-12.85-5.424H347.171c-4.948,0-9.233,1.807-12.847,5.424 c-3.617,3.615-5.428,7.898-5.428,12.847s1.811,9.233,5.428,12.85l50.247,50.248L198.424,304.067 c-1.906,1.903-2.856,4.093-2.856,6.563c0,2.479,0.953,4.668,2.856,6.571l32.548,32.544c1.903,1.903,4.093,2.852,6.567,2.852 s4.665-0.948,6.567-2.852l186.148-186.148l50.251,50.248c3.614,3.617,7.898,5.426,12.847,5.426s9.233-1.809,12.851-5.426 c3.617-3.616,5.424-7.898,5.424-12.847V54.818C511.626,49.866,509.813,45.586,506.199,41.971z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -11,6 +11,7 @@
<div class="grid grid-cols-2 gap-4">
<f-text id="register_url" v-model="inner.registerUrl" label="Formular-Link"></f-text>
<f-text id="clear_cache_url" v-model="inner.clearCacheUrl" label="Frontend-Cache-Url"></f-text>
<f-text id="reply_to_mail" v-model="inner.replyToMail" label="Reply-To-Adresse"></f-text>
</div>
</form>
</setting-layout>

View File

@ -22,6 +22,7 @@
<f-editor v-if="active === 1" id="yearlymail" v-model="data.yearlymail" label="Jährliche Präventions-Erinnerung"></f-editor>
<f-member-filter id="yearly_member_filter" v-model="data.yearlyMemberFilter" label="nur für folgende Mitglieder erlauben" />
<f-multipleselect id="prevent_against" v-model="data.preventAgainst" :options="meta.preventAgainsts" label="An diese Dokumente erinnern" size="sm"></f-multipleselect>
<f-text id="reply_to_mail" v-model="data.replyToMail" label="Reply-To-Adresse"></f-text>
</div>
</form>
</setting-layout>

View File

@ -248,6 +248,17 @@ it('notices a few weeks before', function ($date, bool $shouldSend) {
[fn() => now()->subYears(5)->addWeeks(2)->subDay(), false],
]);
it('sets reply to mail', function () {
Mail::fake();
app(PreventionSettings::class)->fill(['replyToMail' => 'admin@example.com'])->save();
createMember(['has_vk' => false]);
sleep(2);
YearlyRememberAction::run();
Mail::assertSent(YearlyMail::class, fn ($message) => $message->hasReplyTo('admin@example.com'));
});
it('remembers members yearly', function ($date, $shouldSend) {
Mail::fake();
createMember(['efz' => $date, 'ps_at' => now(), 'has_vk' => true]);

View File

@ -28,6 +28,7 @@ it('receives settings', function () {
'weeks' => 9,
'freshRememberInterval' => 11,
'active' => true,
'replyToMail' => 'admin@example.com',
'preventAgainst' => [Prevention::MOREPS->name],
'yearlyMemberFilter' => FilterScope::from([
'memberships' => [['group_ids' => [33]]],
@ -41,6 +42,7 @@ it('receives settings', function () {
->assertJsonPath('data.weeks', '9')
->assertJsonPath('data.active', true)
->assertJsonPath('data.freshRememberInterval', '11')
->assertJsonPath('data.replyToMail', 'admin@example.com')
->assertJsonPath('data.yearlyMemberFilter.search', 'searchstring')
->assertJsonPath('data.yearlyMemberFilter.memberships.0.group_ids.0', 33)
->assertJsonPath('data.preventAgainst', ['MOREPS'])
@ -58,6 +60,7 @@ it('testItStoresSettings', function () {
'freshRememberInterval' => 11,
'active' => true,
'preventAgainst' => ['EFZ'],
'replyToMail' => 'admin@example.com',
'yearlyMemberFilter' => [
'memberships' => [['group_ids' => 33]],
'search' => 'searchstring',
@ -66,6 +69,7 @@ it('testItStoresSettings', function () {
test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd']));
test()->assertEquals(9, app(PreventionSettings::class)->weeks);
test()->assertEquals('admin@example.com', app(PreventionSettings::class)->replyToMail);
test()->assertEquals(11, app(PreventionSettings::class)->freshRememberInterval);
test()->assertTrue(app(PreventionSettings::class)->active);
test()->assertEquals([['group_ids' => 33]], app(PreventionSettings::class)->yearlyMemberFilter->memberships);