Skip to content

Commit

Permalink
CachetHQ/Cachet/cachethq#3102 add List-Unsubscribe header
Browse files Browse the repository at this point in the history
  • Loading branch information
Naugrimm committed Jan 26, 2020
1 parent cb14f44 commit f9366c7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/Bus/Handlers/Events/MessageSending.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Cachet\Bus\Handlers\Events;

/**
* This class is called immediately before sending a message into the mail channel.
*
* @author Graham Campbell <[email protected]>
* @author James Brooks <[email protected]>
*/
class MessageSending
{
/**
* Handle the any actions that need storing.
*
* @param \Illuminate\Mail\Events\MessageSending $event
*
* @return void
*/
public function handle($event)
{
if ($unsubscribeUrl = $event->data['unsubscribeUrl'] ?? null) {
$event->message->getHeaders()->addTextHeader('List-Unsubscribe', '<'.$unsubscribeUrl.'>');
}
}
}
3 changes: 3 additions & 0 deletions app/Foundation/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'Illuminate\Mail\Events\MessageSending' => [
'CachetHQ\Cachet\Bus\Handlers\Events\MessageSending',
],
'CachetHQ\Cachet\Bus\Events\ActionInterface' => [
'CachetHQ\Cachet\Bus\Handlers\Events\ActionStorageHandler',
],
Expand Down

0 comments on commit f9366c7

Please sign in to comment.