Compare commits

..

No commits in common. "reply_to_mail" and "master" have entirely different histories.

12 changed files with 7 additions and 75 deletions

View File

@ -2,6 +2,7 @@
namespace App\Form;
use App\Form\Actions\SettingStoreAction;
use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings;
use Lorisleiva\Actions\ActionRequest;
@ -10,7 +11,6 @@ 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 'Veranstaltungen';
return 'Formulare';
}
/**
@ -30,7 +30,6 @@ class FormSettings extends LocalSettings implements Storeable
return [
'registerUrl' => 'present|string',
'clearCacheUrl' => 'present|string',
'replyToMail' => 'nullable|string|email',
];
}
@ -48,7 +47,6 @@ class FormSettings extends LocalSettings implements Storeable
'data' => [
'registerUrl' => $this->registerUrl,
'clearCacheUrl' => $this->clearCacheUrl,
'replyToMail' => $this->replyToMail,
]
]
];

View File

@ -4,7 +4,6 @@ namespace App\Form\Mails;
use App\Form\Data\FormConfigData;
use App\Form\Editor\FormConditionResolver;
use App\Form\FormSettings;
use App\Form\Models\Participant;
use App\Lib\Editor\Condition;
use Illuminate\Bus\Queueable;
@ -25,8 +24,6 @@ class ConfirmRegistrationMail extends Mailable
/** @var array<int, mixed> */
public array $bottomText;
public FormSettings $formSettings;
/**
* Create a new message instance.
*
@ -35,7 +32,6 @@ class ConfirmRegistrationMail extends Mailable
public function __construct(public Participant $participant)
{
$conditionResolver = app(FormConditionResolver::class)->forParticipant($participant);
$this->formSettings = app(FormSettings::class);
$this->fullname = $participant->getFields()->getFullname();
$this->config = $participant->getConfig();
$this->topText = $conditionResolver->makeBlocks($participant->form->mail_top);
@ -49,15 +45,9 @@ class ConfirmRegistrationMail extends Mailable
*/
public function envelope()
{
$envelope = new Envelope(
return new Envelope(
subject: 'Deine Anmeldung zu ' . $this->participant->form->name,
);
if ($this->formSettings->replyToMail !== null) {
$envelope->replyTo($this->formSettings->replyToMail);
}
return $envelope;
}
/**

View File

@ -24,7 +24,6 @@ class SettingStoreAction
'weeks' => 'required|numeric|gte:0',
'freshRememberInterval' => 'required|numeric|gte:0',
'active' => 'boolean',
'replyToMail' => 'nullable|string|email',
];
}
@ -34,7 +33,6 @@ 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,7 +6,6 @@ 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;
@ -20,7 +19,6 @@ class YearlyMail extends Mailable
use Queueable, SerializesModels;
public InvoiceSettings $settings;
public PreventionSettings $preventionSettings;
/**
* Create a new message instance.
@ -29,7 +27,6 @@ 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());
}
@ -41,15 +38,9 @@ class YearlyMail extends Mailable
*/
public function envelope()
{
$envelope = (new Envelope(
return (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,7 +15,6 @@ 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
@ -50,7 +49,6 @@ class PreventionSettings extends LocalSettings
...$this->toArray(),
'weeks' => (string) $this->weeks,
'freshRememberInterval' => (string) $this->freshRememberInterval,
'replyToMail' => $this->replyToMail,
];
}
}

View File

@ -1,12 +0,0 @@
<?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

@ -11,7 +11,6 @@
<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,7 +22,6 @@
<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,17 +248,6 @@ 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

@ -4,7 +4,6 @@ namespace Tests\Feature\Form;
use App\Form\Enums\NamiType;
use App\Form\Enums\SpecialType;
use App\Form\FormSettings;
use App\Form\Mails\ConfirmRegistrationMail;
use App\Form\Models\Form;
use App\Group;
@ -309,22 +308,6 @@ it('testItSendsEmailToParticipant', function () {
Mail::assertQueued(ConfirmRegistrationMail::class, fn($message) => $message->hasTo('example@test.test', 'Lala GG') && $message->hasSubject('Deine Anmeldung zu Ver2'));
});
it('sets reply to in email', function () {
$this->login()->loginNami()->withoutExceptionHandling();
app(FormSettings::class)->fill(['replyToMail' => 'reply@example.com'])->save();
$form = Form::factory()->name('Ver2')->fields([
$this->textField('vorname')->specialType(SpecialType::FIRSTNAME),
$this->textField('nachname')->specialType(SpecialType::LASTNAME),
$this->textField('email')->specialType(SpecialType::EMAIL),
])
->create();
$this->register($form, ['vorname' => 'Lala', 'nachname' => 'GG', 'email' => 'example@test.test'])
->assertOk();
Mail::assertQueued(ConfirmRegistrationMail::class, fn($message) => $message->hasReplyTo('reply@example.com'));
});
it('testItDoesntSendEmailWhenNoMailFieldGiven', function () {
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()->fields([

View File

@ -2,9 +2,12 @@
namespace Tests\Feature\Nami;
use App\Invoice\InvoiceSettings;
use App\Setting\NamiSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use Zoomyboy\LaravelNami\Authentication\Auth;
use Zoomyboy\LaravelNami\Nami;
uses(DatabaseTransactions::class);

View File

@ -28,7 +28,6 @@ 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]]],
@ -42,7 +41,6 @@ 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'])
@ -60,7 +58,6 @@ it('testItStoresSettings', function () {
'freshRememberInterval' => 11,
'active' => true,
'preventAgainst' => ['EFZ'],
'replyToMail' => 'admin@example.com',
'yearlyMemberFilter' => [
'memberships' => [['group_ids' => 33]],
'search' => 'searchstring',
@ -69,7 +66,6 @@ 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);