Added Laravel Pint for formatting

This commit is contained in:
Will Browning 2022-11-29 12:27:39 +00:00
parent 8618da1f3c
commit fd92e09e5e
156 changed files with 1352 additions and 1702 deletions

View file

@ -1,21 +0,0 @@
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('vendor')
->notPath('bootstrap')
->notPath('storage')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);

View file

@ -464,7 +464,7 @@ For full details please see the [self-hosting instructions file](SELF-HOSTING.md
## My sponsors
Thanks to [Vlad Timofeev](https://github.com/vlad-timofeev), [Patrick Dobler](https://github.com/patrickdobler), [Luca Steeb](https://github.com/steebchen), [Laiteux](https://github.com/Laiteux) and [narolinus](https://github.com/narolinus) for supporting me by sponsoring the project on GitHub!
Thanks to [Vlad Timofeev](https://github.com/vlad-timofeev), [Patrick Dobler](https://github.com/patrickdobler), [Luca Steeb](https://github.com/steebchen), [Laiteux](https://github.com/Laiteux), [narolinus](https://github.com/narolinus) and [Limon Monte](https://github.com/limonte) for supporting me by sponsoring the project on GitHub!
Also an extra special thanks to [CrazyMax](https://github.com/crazy-max) for sponsoring me and also creating and maintaining the awesome [AnonAddy Docker image](https://github.com/anonaddy/docker)!

View file

@ -44,7 +44,7 @@ class CheckDomainsMxValidation extends Command
try {
if (! $domain->checkMxRecords()) {
// Notify user via email only if domain's MX previously were valid
if (!is_null($domain->domain_mx_validated_at)) {
if (! is_null($domain->domain_mx_validated_at)) {
$domain->user->notify(new DomainMxRecordsInvalid($domain->domain));
}

View file

@ -49,40 +49,41 @@ class CreateUser extends Command
{
$validator = Validator::make([
'username' => $this->argument('username'),
'email' => $this->argument('email')], [
'username' => [
'required',
'regex:/^[a-zA-Z0-9]*$/',
'max:20',
'unique:usernames,username',
new NotDeletedUsername()
],
'email' => [
'required',
'email:rfc,dns',
'max:254',
new RegisterUniqueRecipient(),
new NotLocalRecipient()
],
]);
'email' => $this->argument('email'), ], [
'username' => [
'required',
'regex:/^[a-zA-Z0-9]*$/',
'max:20',
'unique:usernames,username',
new NotDeletedUsername(),
],
'email' => [
'required',
'email:rfc,dns',
'max:254',
new RegisterUniqueRecipient(),
new NotLocalRecipient(),
],
]);
if ($validator->fails()) {
$errors = $validator->errors();
foreach ($errors->all() as $message) {
$this->error($message);
}
return 1;
}
$userId = Uuid::uuid4();
$recipient = Recipient::create([
'email' => $this->argument('email'),
'user_id' => $userId
'user_id' => $userId,
]);
$username = Username::create([
'username' => $this->argument('username'),
'user_id' => $userId
'user_id' => $userId,
]);
$twoFactor = app('pragmarx.google2fa');
@ -92,7 +93,7 @@ class CreateUser extends Command
'default_username_id' => $username->id,
'default_recipient_id' => $recipient->id,
'password' => Hash::make($userId),
'two_factor_secret' => $twoFactor->generateSecretKey()
'two_factor_secret' => $twoFactor->generateSecretKey(),
]);
event(new Registered($user));

View file

@ -81,7 +81,7 @@ class ListUsers extends Command
'username' => $user->defaultUsername->username,
'bandwidth' => $user->bandwidth,
'created_at' => $user->created_at,
'updated_at' => $user->updated_at
'updated_at' => $user->updated_at,
];
});

View file

@ -44,8 +44,11 @@ class ReceiveEmail extends Command
* @var string
*/
protected $description = 'Receive email from postfix pipe';
protected $parser;
protected $senderFrom;
protected $size;
/**
@ -87,7 +90,7 @@ class ReceiveEmail extends Command
}
// First determine if the alias already exists in the database
if ($alias = Alias::firstWhere('email', $recipient['local_part'] . '@' . $recipient['domain'])) {
if ($alias = Alias::firstWhere('email', $recipient['local_part'].'@'.$recipient['domain'])) {
$user = $alias->user;
if ($alias->aliasable_id) {
@ -101,17 +104,18 @@ class ReceiveEmail extends Command
})
->first();
if (!empty($parentDomain)) {
if (! empty($parentDomain)) {
// It is standard or username alias
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.' . $parentDomain)); // e.g. johndoe
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.'.$parentDomain)); // e.g. johndoe
if ($subdomain === 'unsubscribe') {
$this->handleUnsubscribe($recipient);
continue;
}
// Check if this is an username or standard alias
if (!empty($subdomain)) {
if (! empty($subdomain)) {
$username = Username::where('username', $subdomain)->first();
$user = $username->user;
$aliasable = $username;
@ -124,13 +128,13 @@ class ReceiveEmail extends Command
}
}
if (!isset($user) && !empty(config('anonaddy.admin_username'))) {
if (! isset($user) && ! empty(config('anonaddy.admin_username'))) {
$user = Username::where('username', config('anonaddy.admin_username'))->first()?->user;
}
}
// If there is still no user or the user has no verified default recipient then continue.
if (!isset($user) || !$user->hasVerifiedDefaultRecipient()) {
if (! isset($user) || ! $user->hasVerifiedDefaultRecipient()) {
continue;
}
@ -203,11 +207,11 @@ class ReceiveEmail extends Command
{
if (is_null($alias)) {
$alias = $user->aliases()->create([
'email' => $recipient['local_part'] . '@' . $recipient['domain'],
'email' => $recipient['local_part'].'@'.$recipient['domain'],
'local_part' => $recipient['local_part'],
'domain' => $recipient['domain'],
'aliasable_id' => $aliasable?->id,
'aliasable_type' => $aliasable ? 'App\\Models\\' . class_basename($aliasable) : null
'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null,
]);
// Hydrate all alias fields
@ -228,11 +232,11 @@ class ReceiveEmail extends Command
if (is_null($alias)) {
// This is a new alias
$alias = new Alias([
'email' => $recipient['local_part'] . '@' . $recipient['domain'],
'email' => $recipient['local_part'].'@'.$recipient['domain'],
'local_part' => $recipient['local_part'],
'domain' => $recipient['domain'],
'aliasable_id' => $aliasable?->id,
'aliasable_type' => $aliasable ? 'App\\Models\\' . class_basename($aliasable) : null
'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null,
]);
if ($user->hasExceededNewAliasLimit()) {
@ -248,11 +252,11 @@ class ReceiveEmail extends Command
$recipientIds = $user
->recipients()
->select(['id','email_verified_at'])
->select(['id', 'email_verified_at'])
->oldest()
->get()
->filter(function ($item, $key) use ($keys) {
return in_array($key + 1, $keys) && !is_null($item['email_verified_at']);
return in_array($key + 1, $keys) && ! is_null($item['email_verified_at']);
})
->pluck('id')
->take(10)
@ -296,7 +300,7 @@ class ReceiveEmail extends Command
// First check in DB
$postfixQueueId = PostfixQueueId::firstWhere('queue_id', strtoupper($dsn['X-postfix-queue-id']));
if (!$postfixQueueId) {
if (! $postfixQueueId) {
exit(0);
}
@ -332,7 +336,7 @@ class ReceiveEmail extends Command
// Try to find a user from the bounced email address
if ($recipient = Recipient::select(['id', 'user_id', 'email', 'email_verified_at'])->get()->firstWhere('email', $bouncedEmailAddress)) {
if (!isset($user)) {
if (! isset($user)) {
$user = $recipient->user;
}
}
@ -350,11 +354,11 @@ class ReceiveEmail extends Command
if (isset($undeliveredMessageHeaders['Feedback-id'])) {
$parts = explode(':', $undeliveredMessageHeaders['Feedback-id']);
if (in_array($parts[0], ['F', 'R', 'S']) && !isset($alias)) {
if (in_array($parts[0], ['F', 'R', 'S']) && ! isset($alias)) {
$alias = Alias::find($parts[1]);
// Find the user from the alias if we don't have it from the recipient
if (!isset($user) && isset($alias)) {
if (! isset($user) && isset($alias)) {
$user = $alias->user;
}
}
@ -385,7 +389,7 @@ class ReceiveEmail extends Command
'email_type' => $parts[0] ?? null,
'status' => $dsn['Status'] ?? null,
'code' => $diagnosticCode,
'attempted_at' => $postfixQueueId->created_at
'attempted_at' => $postfixQueueId->created_at,
]);
if (isset($alias)) {
@ -452,7 +456,7 @@ class ReceiveEmail extends Command
'email' => $item,
'local_part' => strtolower($this->option('local_part')[$key]),
'extension' => $this->option('extension')[$key],
'domain' => strtolower($this->option('domain')[$key])
'domain' => strtolower($this->option('domain')[$key]),
];
});
}
@ -472,7 +476,7 @@ class ReceiveEmail extends Command
try {
mailparse_rfc822_parse_addresses($value);
} catch (\Exception $e) {
$part['headers']['from'] = str_replace("\\", "", $part['headers']['from']);
$part['headers']['from'] = str_replace('\\', '', $part['headers']['from']);
$mimePart->setPart($part);
}
}
@ -483,7 +487,7 @@ class ReceiveEmail extends Command
if ($file == 'stream') {
$fd = fopen('php://stdin', 'r');
$this->rawEmail = '';
while (!feof($fd)) {
while (! feof($fd)) {
$this->rawEmail .= fread($fd, 1024);
}
fclose($fd);
@ -491,6 +495,7 @@ class ReceiveEmail extends Command
} else {
$parser->setPath($file);
}
return $parser;
}
@ -508,7 +513,7 @@ class ReceiveEmail extends Command
$result[$key] = trim($matches[2]);
}
} elseif (preg_match('/^\s+(.+)\s*/', $line) && isset($key)) {
$result[$key] .= ' ' . $line;
$result[$key] .= ' '.$line;
}
}
@ -521,7 +526,7 @@ class ReceiveEmail extends Command
return 'hard';
}
if (preg_match("/(:?spam|unsolicited|blacklisting|blacklisted|blacklist|554|mail content denied|reject for policy reason|mail rejected by destination domain|security issue)/i", $code)) {
if (preg_match('/(:?spam|unsolicited|blacklisting|blacklisted|blacklist|554|mail content denied|reject for policy reason|mail rejected by destination domain|security issue)/i', $code)) {
return 'spam';
}

View file

@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
'App\Console\Commands\ResetBandwidth'
'App\Console\Commands\ResetBandwidth',
];
/**

View file

@ -10,7 +10,7 @@ class CustomMailManager extends MailManager
/**
* Resolve the given mailer.
*
* @param string $name
* @param string $name
* @return Mailer
*/
protected function resolve($name): CustomMailer

View file

@ -23,7 +23,7 @@ class CustomMailer extends Mailer
/**
* Send a new message using a view.
*
* @param MailableContract|string|array $view
* @param MailableContract|string|array $view
* @param array $data
* @param \Closure|string|null $callback
* @return SentMessage|null
@ -67,7 +67,7 @@ class CustomMailer extends Mailer
$recipient = Recipient::find($data['recipientId']);
try {
$encrypter = new OpenPGPEncrypter(config('anonaddy.signing_key_fingerprint'), $data['fingerprint'], "~/.gnupg", $recipient->protected_headers);
$encrypter = new OpenPGPEncrypter(config('anonaddy.signing_key_fingerprint'), $data['fingerprint'], '~/.gnupg', $recipient->protected_headers);
} catch (RuntimeException $e) {
info($e->getMessage());
$encrypter = null;
@ -114,7 +114,7 @@ class CustomMailer extends Mailer
'Subject',
'Date',
'Original-Sender',
'Sender'
'Sender',
])->toArray();
$signedEmail = $dkimSigner->sign($symfonyMessage, $options);
$symfonyMessage->setHeaders($signedEmail->getHeaders());
@ -130,10 +130,10 @@ class CustomMailer extends Mailer
try {
// Get Postfix Queue ID and save in DB
$id = str_replace("\r\n", "", Str::after($sentMessage->getDebug(), 'Ok: queued as '));
$id = str_replace("\r\n", '', Str::after($sentMessage->getDebug(), 'Ok: queued as '));
PostfixQueueId::create([
'queue_id' => $id
'queue_id' => $id,
]);
} catch (QueryException $e) {
// duplicate entry

View file

@ -10,6 +10,7 @@ use Symfony\Component\Mime\Email;
class OpenPGPEncrypter
{
protected $gnupg = null;
protected $usesProtectedHeaders;
/**
@ -53,18 +54,17 @@ class OpenPGPEncrypter
*/
protected $gnupgHome = null;
public function __construct($signingKey = null, $recipientKey = null, $gnupgHome = null, $usesProtectedHeaders = false)
{
$this->initGNUPG();
$this->signingKey = $signingKey;
$this->signingKey = $signingKey;
$this->recipientKey = $recipientKey;
$this->gnupgHome = $gnupgHome;
$this->gnupgHome = $gnupgHome;
$this->usesProtectedHeaders = $usesProtectedHeaders;
}
/**
* @param string $micalg
* @param string $micalg
*/
public function setMicalg($micalg)
{
@ -73,14 +73,14 @@ class OpenPGPEncrypter
/**
* @param $identifier
* @param null $passPhrase
* @param null $passPhrase
*
* @throws RuntimeException
*/
public function addSignature($identifier, $keyFingerprint = null, $passPhrase = null)
{
if (!$keyFingerprint) {
$keyFingerprint = $this->getKey($identifier, 'sign');
if (! $keyFingerprint) {
$keyFingerprint = $this->getKey($identifier, 'sign');
}
$this->signingKey = $keyFingerprint;
@ -97,13 +97,12 @@ class OpenPGPEncrypter
*/
public function addKeyPassphrase($identifier, $passPhrase)
{
$keyFingerprint = $this->getKey($identifier, 'sign');
$keyFingerprint = $this->getKey($identifier, 'sign');
$this->keyPassphrases[$keyFingerprint] = $passPhrase;
}
/**
* @param Email $email
*
* @param Email $email
* @return $this
*
* @throws RuntimeException
@ -117,19 +116,19 @@ class OpenPGPEncrypter
$boundary = strtr(base64_encode(random_bytes(6)), '+/', '-_');
$headers->setHeaderBody('Parameterized', 'Content-Type', 'multipart/signed');
$headers->setHeaderParameter('Content-Type', 'micalg', sprintf("pgp-%s", strtolower($this->micalg)));
$headers->setHeaderParameter('Content-Type', 'micalg', sprintf('pgp-%s', strtolower($this->micalg)));
$headers->setHeaderParameter('Content-Type', 'protocol', 'application/pgp-signature');
$headers->setHeaderParameter('Content-Type', 'boundary', $boundary);
$message->setHeaders($headers);
if (!$this->signingKey) {
if (! $this->signingKey) {
foreach ($message->getFrom() as $key => $value) {
$this->addSignature($this->getKey($key, 'sign'));
}
}
if (!$this->signingKey) {
if (! $this->signingKey) {
throw new RuntimeException('Signing has been enabled, but no signature has been added. Use autoAddSignature() or addSignature()');
}
@ -143,7 +142,7 @@ class OpenPGPEncrypter
// Check if using protected headers or not
if ($this->usesProtectedHeaders) {
$protectedHeadersSet = false;
for ($i=0; $i<count($lines); $i++) {
for ($i = 0; $i < count($lines); $i++) {
if (Str::startsWith(strtolower($lines[$i]), 'content-type: text/plain') || Str::startsWith(strtolower($lines[$i]), 'content-type: multipart/')) {
$lines[$i] = rtrim($lines[$i])."; protected-headers=\"v1\"\r\n";
if (! $protectedHeadersSet) {
@ -155,7 +154,7 @@ class OpenPGPEncrypter
}
}
} else {
for ($i=0; $i<count($lines); $i++) {
for ($i = 0; $i < count($lines); $i++) {
$lines[$i] = rtrim($lines[$i])."\r\n";
}
}
@ -178,7 +177,7 @@ class OpenPGPEncrypter
$signed = sprintf("%s\r\n%s", $message->getHeaders()->get('content-type')->toString(), $body);
if (!$this->recipientKey) {
if (! $this->recipientKey) {
throw new RuntimeException('Encryption has been enabled, but no recipients have been added. Use autoAddRecipients() or addRecipient()');
}
@ -207,25 +206,24 @@ class OpenPGPEncrypter
}
/**
* @param Email $email
*
* @param Email $email
* @return $this
*
* @throws RuntimeException
*/
public function encryptInline(Email $message): Email
{
if (!$this->signingKey) {
if (! $this->signingKey) {
foreach ($message->getFrom() as $key => $value) {
$this->addSignature($this->getKey($key, 'sign'));
}
}
if (!$this->signingKey) {
if (! $this->signingKey) {
throw new RuntimeException('Signing has been enabled, but no signature has been added. Use autoAddSignature() or addSignature()');
}
if (!$this->recipientKey) {
if (! $this->recipientKey) {
throw new RuntimeException('Encryption has been enabled, but no recipients have been added. Use autoAddRecipients() or addRecipient()');
}
@ -246,19 +244,19 @@ class OpenPGPEncrypter
*/
protected function initGNUPG()
{
if (!class_exists('gnupg')) {
if (! class_exists('gnupg')) {
throw new RuntimeException('PHPMailerPGP requires the GnuPG class');
}
if (!$this->gnupgHome && isset($_SERVER['HOME'])) {
$this->gnupgHome = $_SERVER['HOME'] . '/.gnupg';
if (! $this->gnupgHome && isset($_SERVER['HOME'])) {
$this->gnupgHome = $_SERVER['HOME'].'/.gnupg';
}
if (!$this->gnupgHome && getenv('HOME')) {
$this->gnupgHome = getenv('HOME') . '/.gnupg';
if (! $this->gnupgHome && getenv('HOME')) {
$this->gnupgHome = getenv('HOME').'/.gnupg';
}
if (!$this->gnupg) {
if (! $this->gnupg) {
$this->gnupg = new \gnupg();
}
@ -268,14 +266,13 @@ class OpenPGPEncrypter
/**
* @param $plaintext
* @param $keyFingerprint
*
* @return string
*
* @throws RuntimeException
*/
protected function pgpSignString($plaintext, $keyFingerprint)
{
if (isset($this->keyPassphrases[$keyFingerprint]) && !$this->keyPassphrases[$keyFingerprint]) {
if (isset($this->keyPassphrases[$keyFingerprint]) && ! $this->keyPassphrases[$keyFingerprint]) {
$passPhrase = $this->keyPassphrases[$keyFingerprint];
} else {
$passPhrase = null;
@ -298,7 +295,6 @@ class OpenPGPEncrypter
/**
* @param $plaintext
* @param $keyFingerprints
*
* @return string
*
* @throws RuntimeException
@ -323,14 +319,13 @@ class OpenPGPEncrypter
/**
* @param $plaintext
* @param $keyFingerprints
*
* @return string
*
* @throws RuntimeException
*/
protected function pgpEncryptAndSignString($plaintext, $keyFingerprint, $signingKeyFingerprint)
{
if (isset($this->keyPassphrases[$signingKeyFingerprint]) && !$this->keyPassphrases[$signingKeyFingerprint]) {
if (isset($this->keyPassphrases[$signingKeyFingerprint]) && ! $this->keyPassphrases[$signingKeyFingerprint]) {
$passPhrase = $this->keyPassphrases[$signingKeyFingerprint];
} else {
$passPhrase = null;
@ -354,14 +349,13 @@ class OpenPGPEncrypter
/**
* @param $identifier
* @param $purpose
*
* @return string
*
* @throws RuntimeException
*/
protected function getKey($identifier, $purpose)
{
$keys = $this->gnupg->keyinfo($identifier);
$keys = $this->gnupg->keyinfo($identifier);
$fingerprints = [];
foreach ($keys as $key) {
@ -388,6 +382,6 @@ class OpenPGPEncrypter
protected function isValidKey($key, $purpose)
{
return !($key['disabled'] || $key['expired'] || $key['revoked'] || ($purpose == 'sign' && !$key['can_sign']) || ($purpose == 'encrypt' && !$key['can_encrypt']));
return ! ($key['disabled'] || $key['expired'] || $key['revoked'] || ($purpose == 'sign' && ! $key['can_sign']) || ($purpose == 'encrypt' && ! $key['can_encrypt']));
}
}

View file

@ -8,7 +8,7 @@ final class RawContentEncoder implements ContentEncoderInterface
{
public function encodeByteStream($stream, int $maxLineLength = 0): iterable
{
while (!feof($stream)) {
while (! feof($stream)) {
yield fread($stream, 8192);
}
}

View file

@ -13,16 +13,20 @@ class EncryptedPart extends AbstractPart
protected $_headers;
private $body;
private $charset;
private $subtype;
/**
* @var ?string
*/
private $disposition;
private $seekable;
/**
* @param resource|string $body
* @param resource|string $body
*/
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain')
{
@ -30,7 +34,7 @@ class EncryptedPart extends AbstractPart
parent::__construct();
if (!\is_string($body) && !\is_resource($body)) {
if (! \is_string($body) && ! \is_resource($body)) {
throw new \TypeError(sprintf('The body of "%s" must be a string or a resource (got "%s").', self::class, get_debug_type($body)));
}

View file

@ -33,6 +33,7 @@ class MessageIDValidation implements EmailValidation
// }
} catch (\Exception $invalid) {
$this->error = new InvalidEmail(new ExceptionFound($invalid), '');
return false;
}

View file

@ -8,8 +8,8 @@ use Maatwebsite\Excel\Concerns\WithHeadings;
class AliasesExport implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return user()->aliases()->withTrashed()->get();

View file

@ -10,7 +10,7 @@ class AccountDetailController extends Controller
public function index()
{
return response()->json([
'data' => new UserResource(user())
'data' => new UserResource(user()),
]);
}
}

View file

@ -83,23 +83,23 @@ class AliasController extends Controller
}
$data = [
'email' => $localPart . '@' . $request->domain,
'email' => $localPart.'@'.$request->domain,
'local_part' => $localPart,
'extension' => $extension ?? null
'extension' => $extension ?? null,
];
} else {
if ($request->input('format', 'random_characters') === 'random_words') {
$localPart = user()->generateRandomWordLocalPart();
$data = [
'email' => $localPart . '@' . $request->domain,
'email' => $localPart.'@'.$request->domain,
'local_part' => $localPart,
];
} elseif ($request->input('format', 'random_characters') === 'random_characters') {
$localPart = user()->generateRandomCharacterLocalPart(8);
$data = [
'email' => $localPart . '@' . $request->domain,
'email' => $localPart.'@'.$request->domain,
'local_part' => $localPart,
];
} else {
@ -107,13 +107,12 @@ class AliasController extends Controller
$data = [
'id' => $uuid,
'email' => $uuid . '@' . $request->domain,
'email' => $uuid.'@'.$request->domain,
'local_part' => $uuid,
];
}
}
// Check if domain is for username or custom domain
$parentDomain = collect(config('anonaddy.all_domains'))
->filter(function ($name) use ($request) {
@ -195,7 +194,7 @@ class AliasController extends Controller
'emails_forwarded' => 0,
'emails_blocked' => 0,
'emails_replied' => 0,
'emails_sent' => 0
'emails_sent' => 0,
]);
// Soft delete to prevent from being regenerated

View file

@ -18,7 +18,7 @@ class ApiTokenDetailController extends Controller
return response()->json([
'name' => $token->name,
'created_at' => $token->created_at?->toDateTimeString(),
'expires_at' => $token->expires_at?->toDateTimeString()
'expires_at' => $token->expires_at?->toDateTimeString(),
]);
}
}

View file

@ -33,7 +33,7 @@ class DomainController extends Controller
$domain->domain = $request->domain;
if (! $domain->checkVerification()) {
return response('Verification record not found, please add the following TXT record to your domain: aa-verify=' . sha1(config('anonaddy.secret') . user()->id . user()->domains->count()), 404);
return response('Verification record not found, please add the following TXT record to your domain: aa-verify='.sha1(config('anonaddy.secret').user()->id.user()->domains->count()), 404);
}
user()->domains()->save($domain);

View file

@ -11,7 +11,7 @@ class DomainOptionController extends Controller
return response()->json([
'data' => user()->domainOptions(),
'defaultAliasDomain' => user()->default_alias_domain,
'defaultAliasFormat' => user()->default_alias_format
'defaultAliasFormat' => user()->default_alias_format,
]);
}
}

View file

@ -9,7 +9,7 @@ class FailedDeliveryController extends Controller
{
public function index()
{
$failedDeliveries = user()->failedDeliveries()->with(['recipient:id,email','alias:id,email'])->latest();
$failedDeliveries = user()->failedDeliveries()->with(['recipient:id,email', 'alias:id,email'])->latest();
return FailedDeliveryResource::collection($failedDeliveries->get());
}
@ -18,7 +18,7 @@ class FailedDeliveryController extends Controller
{
$failedDelivery = user()->failedDeliveries()->findOrFail($id);
return new FailedDeliveryResource($failedDelivery->load(['recipient:id,email','alias:id,email']));
return new FailedDeliveryResource($failedDelivery->load(['recipient:id,email', 'alias:id,email']));
}
public function destroy($id)

View file

@ -21,13 +21,13 @@ class RecipientKeyController extends Controller
$info = $this->gnupg->import($request->key_data);
if (!$info || !$info['fingerprint']) {
if (! $info || ! $info['fingerprint']) {
return response('Key could not be imported', 404);
}
$recipient->update([
'should_encrypt' => true,
'fingerprint' => $info['fingerprint']
'fingerprint' => $info['fingerprint'],
]);
return new RecipientResource($recipient->fresh()->load('aliases'));
@ -45,7 +45,7 @@ class RecipientKeyController extends Controller
'protected_headers' => false,
'inline_encryption' => false,
'protected_headers' => false,
'fingerprint' => null
'fingerprint' => null,
]);
return response('', 204);

View file

@ -14,7 +14,7 @@ class ReorderRuleController extends Controller
$rule = Rule::findOrFail($id);
$rule->update([
'order' => $key
'order' => $key,
]);
});

View file

@ -37,7 +37,7 @@ class RuleController extends Controller
'operator' => $request->operator,
'forwards' => $request->forwards ?? false,
'replies' => $request->replies ?? false,
'sends' => $request->sends ?? false
'sends' => $request->sends ?? false,
]);
return new RuleResource($rule->refresh());
@ -62,7 +62,7 @@ class RuleController extends Controller
'operator' => $request->operator,
'forwards' => $request->forwards ?? false,
'replies' => $request->replies ?? false,
'sends' => $request->sends ?? false
'sends' => $request->sends ?? false,
]);
return new RuleResource($rule->refresh());

View file

@ -28,7 +28,7 @@ class ApiAuthenticationController extends Controller
if (! $user || ! Hash::check($request->password, $user->password)) {
return response()->json([
'error' => 'The provided credentials are incorrect'
'error' => 'The provided credentials are incorrect',
], 401);
}
@ -37,18 +37,18 @@ class ApiAuthenticationController extends Controller
return response()->json([
'message' => "OTP required, please make a request to /api/auth/mfa with the 'mfa_key', 'otp' and 'device_name' including a 'X-CSRF-TOKEN' header",
'mfa_key' => Crypt::encryptString($user->id.'|'.config('anonaddy.secret').'|'.Carbon::now()->addMinutes(5)->getTimestamp()),
'csrf_token' => csrf_token()
'csrf_token' => csrf_token(),
], 422);
} elseif (Webauthn::enabled($user)) {
// If WebAuthn is enabled then return currently unsupported message
return response()->json([
'error' => 'WebAuthn authentication is not currently supported from the extension or mobile apps, please use an API key to login instead'
'error' => 'WebAuthn authentication is not currently supported from the extension or mobile apps, please use an API key to login instead',
], 403);
}
// If the user doesn't use 2FA then return the new API key
return response()->json([
'api_key' => explode('|', $user->createToken($request->device_name)->plainTextToken, 2)[1]
'api_key' => explode('|', $user->createToken($request->device_name)->plainTextToken, 2)[1],
]);
}
@ -58,7 +58,7 @@ class ApiAuthenticationController extends Controller
$mfaKey = Crypt::decryptString($request->mfa_key);
} catch (DecryptException $e) {
return response()->json([
'error' => 'Invalid mfa_key'
'error' => 'Invalid mfa_key',
], 401);
}
$parts = explode('|', $mfaKey, 3);
@ -67,14 +67,14 @@ class ApiAuthenticationController extends Controller
if (! $user || $parts[1] !== config('anonaddy.secret')) {
return response()->json([
'error' => 'Invalid mfa_key'
'error' => 'Invalid mfa_key',
], 401);
}
// Check if the mfa_key has expired
if (Carbon::now()->getTimestamp() > $parts[2]) {
return response()->json([
'error' => 'mfa_key expired, please request a new one at /api/auth/login'
'error' => 'mfa_key expired, please request a new one at /api/auth/login',
], 401);
}
@ -85,7 +85,7 @@ class ApiAuthenticationController extends Controller
if (! $timestamp) {
return response()->json([
'error' => 'The \'One Time Password\' typed was wrong'
'error' => 'The \'One Time Password\' typed was wrong',
], 401);
}
@ -94,7 +94,7 @@ class ApiAuthenticationController extends Controller
}
return response()->json([
'api_key' => explode('|', $user->createToken($request->device_name)->plainTextToken, 2)[1]
'api_key' => explode('|', $user->createToken($request->device_name)->plainTextToken, 2)[1],
]);
}
}

View file

@ -36,7 +36,7 @@ class BackupCodeController extends Controller
if (! Hash::check($request->backup_code, user()->two_factor_backup_code)) {
return back()->withErrors([
'backup_code' => __('The backup code was invalid.')
'backup_code' => __('The backup code was invalid.'),
]);
}
@ -45,7 +45,7 @@ class BackupCodeController extends Controller
user()->update([
'two_factor_enabled' => false,
'two_factor_secret' => $twoFactor->generateSecretKey(),
'two_factor_backup_code' => null
'two_factor_backup_code' => null,
]);
user()->webauthnKeys()->delete();
@ -60,7 +60,7 @@ class BackupCodeController extends Controller
public function update()
{
user()->update([
'two_factor_backup_code' => bcrypt($code = Str::random(40))
'two_factor_backup_code' => bcrypt($code = Str::random(40)),
]);
return back()->with(['backupCode' => $code]);

View file

@ -18,7 +18,7 @@ class PersonalAccessTokenController extends Controller
{
// day, week, month, year or null
if ($request->expiration) {
$method = "add".ucfirst($request->expiration);
$method = 'add'.ucfirst($request->expiration);
$expiration = now()->{$method}();
} else {
$expiration = null;
@ -30,7 +30,7 @@ class PersonalAccessTokenController extends Controller
return [
'token' => new PersonalAccessTokenResource($token->accessToken),
'accessToken' => $accessToken,
'qrCode' => (new QRCode())->render(config('app.url') . "|" . $accessToken)
'qrCode' => (new QRCode())->render(config('app.url').'|'.$accessToken),
];
}

View file

@ -63,7 +63,7 @@ class RegisterController extends Controller
'max:20',
'unique:usernames,username',
new NotBlacklisted(),
new NotDeletedUsername()
new NotDeletedUsername(),
],
'email' => [
'required',
@ -71,7 +71,7 @@ class RegisterController extends Controller
'max:254',
'confirmed',
new RegisterUniqueRecipient(),
new NotLocalRecipient()
new NotLocalRecipient(),
],
'password' => ['required', 'min:8'],
], [
@ -94,12 +94,12 @@ class RegisterController extends Controller
$recipient = Recipient::create([
'email' => $data['email'],
'user_id' => $userId
'user_id' => $userId,
]);
$username = Username::create([
'username' => $data['username'],
'user_id' => $userId
'user_id' => $userId,
]);
$twoFactor = app('pragmarx.google2fa');
@ -109,7 +109,7 @@ class RegisterController extends Controller
'default_username_id' => $username->id,
'default_recipient_id' => $recipient->id,
'password' => Hash::make($data['password']),
'two_factor_secret' => $twoFactor->generateSecretKey()
'two_factor_secret' => $twoFactor->generateSecretKey(),
]);
}
}

View file

@ -12,6 +12,7 @@ use PragmaRX\Google2FALaravel\Support\Authenticator;
class TwoFactorAuthController extends Controller
{
protected $twoFactor;
protected $authenticator;
public function __construct(Request $request)
@ -27,7 +28,7 @@ class TwoFactorAuthController extends Controller
public function store(EnableTwoFactorAuthRequest $request)
{
if (!$this->twoFactor->verifyKey(user()->two_factor_secret, $request->two_factor_token)) {
if (! $this->twoFactor->verifyKey(user()->two_factor_secret, $request->two_factor_token)) {
return redirect(url()->previous().'#two-factor')->withErrors(['two_factor_token' => 'The token you entered was incorrect']);
}
@ -35,7 +36,7 @@ class TwoFactorAuthController extends Controller
user()->update([
'two_factor_enabled' => true,
'two_factor_backup_code' => bcrypt($code = Str::random(40))
'two_factor_backup_code' => bcrypt($code = Str::random(40)),
]);
$this->authenticator->login();
@ -56,13 +57,13 @@ class TwoFactorAuthController extends Controller
public function destroy(Request $request)
{
if (!Hash::check($request->current_password_2fa, user()->password)) {
if (! Hash::check($request->current_password_2fa, user()->password)) {
return back()->withErrors(['current_password_2fa' => 'Current password incorrect']);
}
user()->update([
'two_factor_enabled' => false,
'two_factor_secret' => $this->twoFactor->generateSecretKey()
'two_factor_secret' => $this->twoFactor->generateSecretKey(),
]);
$this->authenticator->logout();

View file

@ -51,6 +51,7 @@ class VerificationController extends Controller
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function verify(Request $request)

View file

@ -19,7 +19,7 @@ class WebauthnController extends ControllersWebauthnController
{
public function index()
{
return user()->webauthnKeys()->latest()->select(['id','name','enabled','created_at'])->get()->values();
return user()->webauthnKeys()->latest()->select(['id', 'name', 'enabled', 'created_at'])->get()->values();
}
/**
@ -45,7 +45,7 @@ class WebauthnController extends ControllersWebauthnController
public function store(WebauthnRegisterRequest $request)
{
$request->validate([
'name' => 'required|string|max:50'
'name' => 'required|string|max:50',
]);
try {
@ -56,7 +56,7 @@ class WebauthnController extends ControllersWebauthnController
);
user()->update([
'two_factor_enabled' => false
'two_factor_enabled' => false,
]);
return $this->redirectAfterSuccessRegister();
@ -72,7 +72,7 @@ class WebauthnController extends ControllersWebauthnController
/**
* Return the redirect destination after a successfull register.
*
* @param WebauthnKey $webauthnKey
* @param WebauthnKey $webauthnKey
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/
protected function redirectAfterSuccessRegister()
@ -83,7 +83,7 @@ class WebauthnController extends ControllersWebauthnController
}
user()->update([
'two_factor_backup_code' => bcrypt($code = Str::random(40))
'two_factor_backup_code' => bcrypt($code = Str::random(40)),
]);
return Redirect::intended('/settings')->with(['backupCode' => $code]);
@ -92,7 +92,7 @@ class WebauthnController extends ControllersWebauthnController
/**
* Remove an existing Webauthn key.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function destroy(Request $request, $webauthnKeyId)

View file

@ -22,6 +22,6 @@ class DeactivateAliasController extends Controller
$alias->deactivate();
return redirect()->route('aliases.index')
->with(['status' => 'Alias ' . $alias->email . ' deactivated successfully!']);
->with(['status' => 'Alias '.$alias->email.' deactivated successfully!']);
}
}

View file

@ -17,7 +17,7 @@ class DomainVerificationController extends Controller
if (! $domain->checkMxRecords()) {
return response()->json([
'success' => false,
'message' => 'MX record not found or does not have correct priority. This could be due to DNS caching, please try again later.'
'message' => 'MX record not found or does not have correct priority. This could be due to DNS caching, please try again later.',
]);
}

View file

@ -10,7 +10,7 @@ class PasswordController extends Controller
{
public function update(UpdatePasswordRequest $request)
{
if (!Hash::check($request->current, user()->password)) {
if (! Hash::check($request->current, user()->password)) {
return redirect(url()->previous().'#update-password')->withErrors(['current' => 'Current password incorrect']);
}

View file

@ -22,13 +22,13 @@ class SettingController extends Controller
'user' => user(),
'recipientOptions' => user()->verifiedRecipients,
'authSecret' => user()->two_factor_secret,
'qrCode' => $qrCode
'qrCode' => $qrCode,
]);
}
public function destroy(DestroyAccountRequest $request)
{
if (!Hash::check($request->current_password_delete, user()->password)) {
if (! Hash::check($request->current_password_delete, user()->password)) {
return back()->withErrors(['current_password_delete' => 'Incorrect password entered']);
}

View file

@ -10,9 +10,9 @@ class ShowAliasController extends Controller
->aliases()
->withTrashed()
->toBase()
->selectRaw("ifnull(sum(emails_forwarded),0) as forwarded")
->selectRaw("ifnull(sum(emails_blocked),0) as blocked")
->selectRaw("ifnull(sum(emails_replied),0) as replies")
->selectRaw('ifnull(sum(emails_forwarded),0) as forwarded')
->selectRaw('ifnull(sum(emails_blocked),0) as blocked')
->selectRaw('ifnull(sum(emails_replied),0) as replies')
->first();
return view('aliases.index', [
@ -22,7 +22,7 @@ class ShowAliasController extends Controller
->aliases()
->with([
'recipients:id,email',
'aliasable.defaultRecipient:id,email'
'aliasable.defaultRecipient:id,email',
])
->latest()
->get(),

View file

@ -12,7 +12,7 @@ class ShowDomainController extends Controller
->with('defaultRecipient:id,email')
->withCount('aliases')
->latest()
->get()
->get(),
]);
}
}

View file

@ -9,10 +9,10 @@ class ShowFailedDeliveryController extends Controller
return view('failed_deliveries.index', [
'failedDeliveries' => user()
->failedDeliveries()
->with(['recipient:id,email','alias:id,email'])
->select(['alias_id','bounce_type','code','attempted_at','created_at','id','recipient_id','remote_mta','sender'])
->with(['recipient:id,email', 'alias:id,email'])
->select(['alias_id', 'bounce_type', 'code', 'attempted_at', 'created_at', 'id', 'recipient_id', 'remote_mta', 'sender'])
->latest()
->get()
->get(),
]);
}
}

View file

@ -9,7 +9,7 @@ class ShowRecipientController extends Controller
$recipients = user()->recipients()->with([
'aliases:id,aliasable_id,email',
'domainsUsingAsDefault.aliases:id,aliasable_id,email',
'usernamesUsingAsDefault.aliases:id,aliasable_id,email'
'usernamesUsingAsDefault.aliases:id,aliasable_id,email',
])->latest()->get();
$recipients->each(function ($recipient) {
@ -38,7 +38,7 @@ class ShowRecipientController extends Controller
'recipients' => $recipients,
'aliasesUsingDefault' => user()->aliasesUsingDefault()->take(5)->get(),
'aliasesUsingDefaultCount' => user()->aliasesUsingDefault()->count(),
'user' => user()->load('defaultUsername')
'user' => user()->load('defaultUsername'),
]);
}
}

View file

@ -10,7 +10,7 @@ class ShowRuleController extends Controller
'rules' => user()
->rules()
->orderBy('order')
->get()
->get(),
]);
}
}

View file

@ -12,7 +12,7 @@ class ShowUsernameController extends Controller
->with('defaultRecipient:id,email')
->withCount('aliases')
->latest()
->get()
->get(),
]);
}
}

View file

@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
'api/auth/login'
'api/auth/login',
];
}

View file

@ -26,7 +26,7 @@ class VerifyTwoFactorAuth extends Middleware
if (! Str::endsWith($request->url(), '/login/2fa')) {
$request->session()->put([
'intended_path' => $request->fullUrl()
'intended_path' => $request->fullUrl(),
]);
}

View file

@ -19,8 +19,8 @@ class VerifyWebauthn
/**
* Create a Webauthn.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Auth\Factory $auth
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Auth\Factory $auth
*/
public function __construct(AuthFactory $auth)
{

View file

@ -26,7 +26,7 @@ class ApiAuthenticationLoginRequest extends FormRequest
return [
'username' => 'required|string',
'password' => 'required|string',
'device_name' => 'required|string|max:50'
'device_name' => 'required|string|max:50',
];
}
}

View file

@ -26,7 +26,7 @@ class ApiAuthenticationMfaRequest extends FormRequest
return [
'mfa_key' => 'required|string|max:500',
'otp' => 'required|string|min:6|max:6',
'device_name' => 'required|string|max:50'
'device_name' => 'required|string|max:50',
];
}
}

View file

@ -24,7 +24,7 @@ class DestroyAccountRequest extends FormRequest
public function rules()
{
return [
'current_password_delete' => 'required|string'
'current_password_delete' => 'required|string',
];
}
}

View file

@ -24,7 +24,7 @@ class DisableTwoFactorAuthRequest extends FormRequest
public function rules()
{
return [
'current_password_2fa' => 'required|string'
'current_password_2fa' => 'required|string',
];
}
}

View file

@ -31,8 +31,8 @@ class EditDefaultRecipientRequest extends FormRequest
'max:254',
'confirmed',
new RegisterUniqueRecipient(),
'not_in:'.$this->user()->email
]
'not_in:'.$this->user()->email,
],
];
}
@ -44,7 +44,7 @@ class EditDefaultRecipientRequest extends FormRequest
public function messages()
{
return [
'email.not_in' => 'That email is the same as the current one.'
'email.not_in' => 'That email is the same as the current one.',
];
}
}

View file

@ -24,7 +24,7 @@ class EnableTwoFactorAuthRequest extends FormRequest
public function rules()
{
return [
'two_factor_token' => 'required|min:6'
'two_factor_token' => 'required|min:6',
];
}
}

View file

@ -27,27 +27,27 @@ class IndexAliasRequest extends FormRequest
return [
'page' => [
'nullable',
'array'
'array',
],
'page.number' => [
'nullable',
'integer'
'integer',
],
'page.size' => [
'nullable',
'integer',
'max:100',
'min:1'
'min:1',
],
'filter' => [
'nullable',
'array'
'array',
],
'filter.search' => [
'nullable',
'string',
'max:50',
'min:3'
'min:3',
],
'filter.deleted' => [
'nullable',
@ -86,8 +86,8 @@ class IndexAliasRequest extends FormRequest
'-created_at',
'-updated_at',
'-deleted_at',
])
]
]),
],
];
}
}

View file

@ -26,7 +26,7 @@ class IndexRecipientRequest extends FormRequest
return [
'filter' => [
'nullable',
'array'
'array',
],
'filter.verified' => [
'nullable',

View file

@ -28,8 +28,8 @@ class StoreAliasRecipientRequest extends FormRequest
'recipient_ids' => [
'array',
'max:10',
new VerifiedRecipientId()
]
new VerifiedRecipientId(),
],
];
}
}

View file

@ -30,7 +30,7 @@ class StoreAliasRequest extends FormRequest
'domain' => [
'required',
'string',
Rule::in($this->user()->domainOptions())
Rule::in($this->user()->domainOptions()),
],
'description' => 'nullable|max:200',
'format' => 'nullable|in:random_characters,uuid,random_words,custom',
@ -38,8 +38,8 @@ class StoreAliasRequest extends FormRequest
'nullable',
'array',
'max:10',
new VerifiedRecipientId()
]
new VerifiedRecipientId(),
],
];
}
@ -52,9 +52,10 @@ class StoreAliasRequest extends FormRequest
return $query->where('local_part', $this->validationData()['local_part'])
->where('domain', $this->validationData()['domain']);
}),
new ValidAliasLocalPart()
new ValidAliasLocalPart(),
], function () {
$format = $this->validationData()['format'] ?? 'random_characters';
return $format === 'custom';
});
}

View file

@ -34,8 +34,8 @@ class StoreDomainRequest extends FormRequest
'unique:domains',
new ValidDomain(),
new NotLocalDomain(),
new NotUsedAsRecipientDomain()
]
new NotUsedAsRecipientDomain(),
],
];
}
}

View file

@ -27,14 +27,14 @@ class StorePersonalAccessTokenRequest extends FormRequest
'name' => [
'required',
'string',
'max:50'
'max:50',
],
'expiration' => [
'nullable',
'string',
'max:5',
'in:day,week,month,year'
]
'in:day,week,month,year',
],
];
}
}

View file

@ -32,8 +32,8 @@ class StoreRecipientRequest extends FormRequest
'max:254',
'email:rfc',
new UniqueRecipient(),
new NotLocalRecipient()
]
new NotLocalRecipient(),
],
];
}
}

View file

@ -28,8 +28,8 @@ class StoreReorderRuleRequest extends FormRequest
'ids' => [
'required',
'array',
new ValidRuleId()
]
new ValidRuleId(),
],
];
}
}

View file

@ -28,20 +28,20 @@ class StoreRuleRequest extends FormRequest
'name' => [
'required',
'string',
'max:50'
'max:50',
],
'conditions' => [
'required',
'array',
'max:5'
'max:5',
],
'conditions.*.type' => [
'required',
Rule::in([
'subject',
'sender',
'alias'
])
'alias',
]),
],
'conditions.*.match' => [
'sometimes',
@ -54,14 +54,14 @@ class StoreRuleRequest extends FormRequest
'starts with',
'does not start with',
'ends with',
'does not end with'
])
'does not end with',
]),
],
'conditions.*.values' => [
'required',
'array',
'min:1',
'max:10'
'max:10',
],
'conditions.*.values.*' => [
'distinct',
@ -69,7 +69,7 @@ class StoreRuleRequest extends FormRequest
'actions' => [
'required',
'array',
'max:5'
'max:5',
],
'actions.*.type' => [
'required',
@ -79,20 +79,20 @@ class StoreRuleRequest extends FormRequest
'encryption',
'banner',
'block',
'webhook'
'webhook',
]),
],
'actions.*.value' => [
'required',
'max:50'
'max:50',
],
'operator' => [
'required',
'in:AND,OR'
'in:AND,OR',
],
'forwards' => 'boolean',
'replies' => 'boolean',
'sends' => 'boolean'
'sends' => 'boolean',
];
}
}

View file

@ -32,7 +32,7 @@ class StoreUsernameRequest extends FormRequest
'max:20',
'unique:usernames,username',
new NotBlacklisted(),
new NotDeletedUsername()
new NotDeletedUsername(),
],
];
}

View file

@ -24,7 +24,7 @@ class UpdateAliasRequest extends FormRequest
public function rules()
{
return [
'description' => 'nullable|max:200'
'description' => 'nullable|max:200',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateBannerLocationRequest extends FormRequest
public function rules()
{
return [
'banner_location' => 'required|string|in:top,bottom,off'
'banner_location' => 'required|string|in:top,bottom,off',
];
}
}

View file

@ -28,8 +28,8 @@ class UpdateDefaultAliasDomainRequest extends FormRequest
'domain' => [
'required',
'string',
Rule::in($this->user()->domainOptions())
]
Rule::in($this->user()->domainOptions()),
],
];
}
}

View file

@ -27,8 +27,8 @@ class UpdateDefaultAliasFormatRequest extends FormRequest
'format' => [
'required',
'string',
'in:random_characters,uuid,random_words,custom'
]
'in:random_characters,uuid,random_words,custom',
],
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateDefaultRecipientRequest extends FormRequest
public function rules()
{
return [
'default_recipient' => 'required|string'
'default_recipient' => 'required|string',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateDomainDefaultRecipientRequest extends FormRequest
public function rules()
{
return [
'default_recipient' => 'nullable|string'
'default_recipient' => 'nullable|string',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateDomainRequest extends FormRequest
public function rules()
{
return [
'description' => 'nullable|max:200'
'description' => 'nullable|max:200',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateEmailSubjectRequest extends FormRequest
public function rules()
{
return [
'email_subject' => 'nullable|string|max:50'
'email_subject' => 'nullable|string|max:50',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateFromNameRequest extends FormRequest
public function rules()
{
return [
'from_name' => 'nullable|string|max:50'
'from_name' => 'nullable|string|max:50',
];
}
}

View file

@ -25,7 +25,7 @@ class UpdatePasswordRequest extends FormRequest
{
return [
'current' => 'required|string',
'password' => 'required|confirmed|min:8'
'password' => 'required|confirmed|min:8',
];
}
}

View file

@ -26,8 +26,8 @@ class UpdateRecipientKeyRequest extends FormRequest
return [
'key_data' => [
'string',
'regex:/-----BEGIN PGP PUBLIC KEY BLOCK-----([A-Za-z0-9+=\/\n]+)-----END PGP PUBLIC KEY BLOCK-----/i'
]
'regex:/-----BEGIN PGP PUBLIC KEY BLOCK-----([A-Za-z0-9+=\/\n]+)-----END PGP PUBLIC KEY BLOCK-----/i',
],
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateUseReplyToRequest extends FormRequest
public function rules()
{
return [
'use_reply_to' => 'required|boolean'
'use_reply_to' => 'required|boolean',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateUsernameDefaultRecipientRequest extends FormRequest
public function rules()
{
return [
'default_recipient' => 'nullable|string'
'default_recipient' => 'nullable|string',
];
}
}

View file

@ -24,7 +24,7 @@ class UpdateUsernameRequest extends FormRequest
public function rules()
{
return [
'description' => 'nullable|max:200'
'description' => 'nullable|max:200',
];
}
}

View file

@ -12,10 +12,10 @@ class UserResource extends JsonResource
->aliases()
->withTrashed()
->toBase()
->selectRaw("ifnull(sum(emails_forwarded),0) as forwarded")
->selectRaw("ifnull(sum(emails_blocked),0) as blocked")
->selectRaw("ifnull(sum(emails_replied),0) as replied")
->selectRaw("ifnull(sum(emails_sent),0) as sent")
->selectRaw('ifnull(sum(emails_forwarded),0) as forwarded')
->selectRaw('ifnull(sum(emails_blocked),0) as blocked')
->selectRaw('ifnull(sum(emails_replied),0) as replied')
->selectRaw('ifnull(sum(emails_sent),0) as sent')
->first();
return [

View file

@ -25,7 +25,7 @@ class SendIncorrectOtpNotification
Cache::put("user:{$user->id}:failed-otp-notification", now()->toDateTimeString(), now()->addMinutes(5));
// Log in auth.log
Log::channel('auth')->info('Failed OTP Notification sent: ' . $user->username);
Log::channel('auth')->info('Failed OTP Notification sent: '.$user->username);
$user->notify(new IncorrectOtpNotification());
}

View file

@ -24,34 +24,63 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
use CheckUserRules;
protected $email;
protected $user;
protected $alias;
protected $sender;
protected $originalCc;
protected $originalTo;
protected $displayFrom;
protected $replyToAddress;
protected $emailSubject;
protected $emailText;
protected $emailHtml;
protected $emailAttachments;
protected $emailInlineAttachments;
protected $deactivateUrl;
protected $bannerLocationText;
protected $bannerLocationHtml;
protected $fingerprint;
protected $encryptedParts;
protected $fromEmail;
protected $size;
protected $messageId;
protected $listUnsubscribe;
protected $inReplyTo;
protected $references;
protected $originalEnvelopeFrom;
protected $originalFromHeader;
protected $originalReplyToHeader;
protected $originalSenderHeader;
protected $authenticationResults;
protected $recipientId;
/**
@ -87,7 +116,7 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
$this->encryptedParts = $emailData->encryptedParts ?? null;
$this->recipientId = $recipient->id;
$this->fingerprint = $recipient->should_encrypt && !$this->isAlreadyEncrypted() ? $recipient->fingerprint : null;
$this->fingerprint = $recipient->should_encrypt && ! $this->isAlreadyEncrypted() ? $recipient->fingerprint : null;
$this->bannerLocationText = $this->bannerLocationHtml = $this->isAlreadyEncrypted() ? 'off' : $this->alias->user->banner_location;
}
@ -103,9 +132,9 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
if ($this->user->use_reply_to) {
$this->fromEmail = $this->alias->email;
$replyToEmail = $this->alias->local_part . '+' . Str::replaceLast('@', '=', $this->replyToAddress) . '@' . $this->alias->domain;
$replyToEmail = $this->alias->local_part.'+'.Str::replaceLast('@', '=', $this->replyToAddress).'@'.$this->alias->domain;
} else {
$this->fromEmail = $this->alias->local_part . '+' . Str::replaceLast('@', '=', $this->replyToAddress) . '@' . $this->alias->domain;
$this->fromEmail = $this->alias->local_part.'+'.Str::replaceLast('@', '=', $this->replyToAddress).'@'.$this->alias->domain;
}
$returnPath = $this->alias->email;
@ -121,14 +150,14 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
}
}
$this->email = $this
$this->email = $this
->from($this->fromEmail, base64_decode($this->displayFrom)." '".$this->sender."'")
->subject($this->user->email_subject ?? base64_decode($this->emailSubject))
->withSymfonyMessage(function (Email $message) use ($returnPath) {
$message->returnPath($returnPath);
$message->getHeaders()
->addTextHeader('Feedback-ID', 'F:' . $this->alias->id . ':anonaddy');
->addTextHeader('Feedback-ID', 'F:'.$this->alias->id.':anonaddy');
// This header is used to set the To: header as the alias just before sending.
$message->getHeaders()
@ -211,7 +240,7 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
if ($this->emailText) {
$this->email->text('emails.forward.text')->with([
'text' => base64_decode($this->emailText)
'text' => base64_decode($this->emailText),
]);
}
@ -220,14 +249,14 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
$this->bannerLocationText = 'off';
$this->email->view('emails.forward.html')->with([
'html' => base64_decode($this->emailHtml)
'html' => base64_decode($this->emailHtml),
]);
}
// To prevent invalid view error where no text or html is present...
if (! $this->emailHtml && ! $this->emailText) {
$this->email->text('emails.forward.text')->with([
'text' => base64_decode($this->emailText)
'text' => base64_decode($this->emailText),
]);
}
@ -239,7 +268,7 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
);
}
$this->replacedSubject = $this->user->email_subject ? ' with subject "' . base64_decode($this->emailSubject) . '"' : null;
$this->replacedSubject = $this->user->email_subject ? ' with subject "'.base64_decode($this->emailSubject).'"' : null;
$this->checkRules('Forwards');
@ -256,7 +285,7 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'fromEmail' => $this->sender,
'replacedSubject' => $this->replacedSubject,
'shouldBlock' => $this->size === 0,
'needsDkimSignature' => $this->needsDkimSignature()
'needsDkimSignature' => $this->needsDkimSignature(),
]);
if (isset($replyToEmail)) {
@ -306,7 +335,7 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'email_type' => 'F',
'status' => null,
'code' => 'An error has occurred, please check the logs.',
'attempted_at' => now()
'attempted_at' => now(),
]);
}

View file

@ -23,19 +23,33 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
use CheckUserRules;
protected $email;
protected $user;
protected $alias;
protected $sender;
protected $emailSubject;
protected $emailText;
protected $emailHtml;
protected $emailAttachments;
protected $emailInlineAttachments;
protected $encryptedParts;
protected $displayFrom;
protected $fromEmail;
protected $size;
protected $inReplyTo;
protected $references;
/**
@ -77,14 +91,14 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
}
}
$this->email = $this
$this->email = $this
->from($this->fromEmail, $this->displayFrom)
->subject(base64_decode($this->emailSubject))
->withSymfonyMessage(function (Email $message) use ($returnPath) {
$message->returnPath($returnPath);
$message->getHeaders()
->addTextHeader('Feedback-ID', 'R:' . $this->alias->id . ':anonaddy');
->addTextHeader('Feedback-ID', 'R:'.$this->alias->id.':anonaddy');
// Message-ID is replaced on replies as it can leak parts of the real email
$message->getHeaders()->remove('Message-ID');
@ -117,20 +131,20 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
if ($this->emailText) {
$this->email->text('emails.reply.text')->with([
'text' => $this->removeRealEmailAndTextBanner(base64_decode($this->emailText))
'text' => $this->removeRealEmailAndTextBanner(base64_decode($this->emailText)),
]);
}
if ($this->emailHtml) {
$this->email->view('emails.reply.html')->with([
'html' => $this->removeRealEmailAndHtmlBanner(base64_decode($this->emailHtml))
'html' => $this->removeRealEmailAndHtmlBanner(base64_decode($this->emailHtml)),
]);
}
// To prevent invalid view error where no text or html is present...
if (! $this->emailHtml && ! $this->emailText) {
$this->email->text('emails.reply.text')->with([
'text' => base64_decode($this->emailText)
'text' => base64_decode($this->emailText),
]);
}
@ -148,7 +162,7 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'shouldBlock' => $this->size === 0,
'encryptedParts' => $this->encryptedParts,
'needsDkimSignature' => $this->needsDkimSignature(),
'aliasDomain' => $this->alias->domain
'aliasDomain' => $this->alias->domain,
]);
if ($this->alias->isCustomDomain() && ! $this->needsDkimSignature()) {
@ -196,7 +210,7 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'email_type' => 'R',
'status' => null,
'code' => 'An error has occurred, please check the logs.',
'attempted_at' => now()
'attempted_at' => now(),
]);
}
@ -216,7 +230,7 @@ class ReplyToEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
// Reply may be HTML but have a plain text banner
return Str::of(str_ireplace($this->sender, '', $html))
->replaceMatches('/(?s)((<|&lt;)!--banner-info--(&gt;|>)).*?((<|&lt;)!--banner-info--(&gt;|>))/mi', '')
->replaceMatches("/(?s)(<tr((?!<tr).)*?" . preg_quote(Str::of(config('app.url'))->after('://')->rtrim('/'), '/') . "(\/|%2F)deactivate(\/|%2F).*?\/tr>)/mi", '');
->replaceMatches('/(?s)(<tr((?!<tr).)*?'.preg_quote(Str::of(config('app.url'))->after('://')->rtrim('/'), '/')."(\/|%2F)deactivate(\/|%2F).*?\/tr>)/mi", '');
}
/**

View file

@ -23,17 +23,29 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
use CheckUserRules;
protected $email;
protected $user;
protected $alias;
protected $sender;
protected $emailSubject;
protected $emailText;
protected $emailHtml;
protected $emailAttachments;
protected $emailInlineAttachments;
protected $encryptedParts;
protected $displayFrom;
protected $fromEmail;
protected $size;
/**
@ -73,14 +85,14 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
}
}
$this->email = $this
$this->email = $this
->from($this->fromEmail, $this->displayFrom)
->subject(base64_decode($this->emailSubject))
->withSymfonyMessage(function (Email $message) use ($returnPath) {
$message->returnPath($returnPath);
$message->getHeaders()
->addTextHeader('Feedback-ID', 'S:' . $this->alias->id . ':anonaddy');
->addTextHeader('Feedback-ID', 'S:'.$this->alias->id.':anonaddy');
// Message-ID is replaced on send from as it can leak parts of the real email
$message->getHeaders()->remove('Message-ID');
@ -103,20 +115,20 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
if ($this->emailText) {
$this->email->text('emails.reply.text')->with([
'text' => $this->removeRealEmailAndTextBanner(base64_decode($this->emailText))
'text' => $this->removeRealEmailAndTextBanner(base64_decode($this->emailText)),
]);
}
if ($this->emailHtml) {
$this->email->view('emails.reply.html')->with([
'html' => $this->removeRealEmailAndHtmlBanner(base64_decode($this->emailHtml))
'html' => $this->removeRealEmailAndHtmlBanner(base64_decode($this->emailHtml)),
]);
}
// To prevent invalid view error where no text or html is present...
if (! $this->emailHtml && ! $this->emailText) {
$this->email->text('emails.reply.text')->with([
'text' => base64_decode($this->emailText)
'text' => base64_decode($this->emailText),
]);
}
@ -134,7 +146,7 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'shouldBlock' => $this->size === 0,
'encryptedParts' => $this->encryptedParts,
'needsDkimSignature' => $this->needsDkimSignature(),
'aliasDomain' => $this->alias->domain
'aliasDomain' => $this->alias->domain,
]);
if ($this->alias->isCustomDomain() && ! $this->needsDkimSignature()) {
@ -182,7 +194,7 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
'email_type' => 'S',
'status' => null,
'code' => 'An error has occurred, please check the logs.',
'attempted_at' => now()
'attempted_at' => now(),
]);
}
@ -202,7 +214,7 @@ class SendFromEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
// Reply may be HTML but have a plain text banner
return Str::of(str_ireplace($this->sender, '', $html))
->replaceMatches('/(?s)((<|&lt;)!--banner-info--(&gt;|>)).*?((<|&lt;)!--banner-info--(&gt;|>))/mi', '')
->replaceMatches("/(?s)(<tr((?!<tr).)*?" . preg_quote(Str::of(config('app.url'))->after('://')->rtrim('/'), '/') . "(\/|%2F)deactivate(\/|%2F).*?\/tr>)/mi", '');
->replaceMatches('/(?s)(<tr((?!<tr).)*?'.preg_quote(Str::of(config('app.url'))->after('://')->rtrim('/'), '/')."(\/|%2F)deactivate(\/|%2F).*?\/tr>)/mi", '');
}
/**

View file

@ -16,6 +16,7 @@ class TokenExpiringSoon extends Mailable implements ShouldQueue, ShouldBeEncrypt
use SerializesModels;
protected $user;
protected $recipient;
/**
@ -37,11 +38,11 @@ class TokenExpiringSoon extends Mailable implements ShouldQueue, ShouldBeEncrypt
public function build()
{
return $this
->subject("Your AnonAddy API token expires soon")
->subject('Your AnonAddy API token expires soon')
->markdown('mail.token_expiring_soon', [
'user' => $this->user,
'recipientId' => $this->recipient->id,
'fingerprint' => $this->recipient->should_encrypt ? $this->recipient->fingerprint : null
'fingerprint' => $this->recipient->should_encrypt ? $this->recipient->fingerprint : null,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -21,7 +21,7 @@ class Alias extends Model
protected $keyType = 'string';
protected $encrypted = [
'description'
'description',
];
protected $fillable = [
@ -38,13 +38,13 @@ class Alias extends Model
'emails_forwarded',
'emails_blocked',
'emails_replied',
'emails_sent'
'emails_sent',
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at'
'deleted_at',
];
protected $casts = [
@ -52,7 +52,7 @@ class Alias extends Model
'user_id' => 'string',
'aliasable_id' => 'string',
'aliasable_type' => 'string',
'active' => 'boolean'
'active' => 'boolean',
];
public static function boot()

View file

@ -20,7 +20,7 @@ class AliasRecipient extends Pivot
protected $casts = [
'id' => 'string',
'alias_id' => 'string',
'recipient_id' => 'string'
'recipient_id' => 'string',
];
public function setAliasAttribute($alias)

View file

@ -18,10 +18,10 @@ class DeletedUsername extends Model
public $timestamps = false;
protected $encrypted = [
'username'
'username',
];
protected $fillable = [
'username'
'username',
];
}

View file

@ -20,14 +20,14 @@ class Domain extends Model
protected $keyType = 'string';
protected $encrypted = [
'description'
'description',
];
protected $fillable = [
'domain',
'description',
'active',
'catch_all'
'catch_all',
];
protected $dates = [
@ -35,7 +35,7 @@ class Domain extends Model
'updated_at',
'domain_verified_at',
'domain_mx_validated_at',
'domain_sending_verified_at'
'domain_sending_verified_at',
];
protected $casts = [
@ -193,9 +193,9 @@ class Domain extends Model
return true;
}
return collect(dns_get_record($this->domain . '.', DNS_TXT))
return collect(dns_get_record($this->domain.'.', DNS_TXT))
->contains(function ($r) {
return trim($r['txt']) === 'aa-verify=' . sha1(config('anonaddy.secret') . user()->id . user()->domains->count());
return trim($r['txt']) === 'aa-verify='.sha1(config('anonaddy.secret').user()->id.user()->domains->count());
});
}
@ -208,7 +208,7 @@ class Domain extends Model
return true;
}
$mx = collect(dns_get_record($this->domain . '.', DNS_MX))
$mx = collect(dns_get_record($this->domain.'.', DNS_MX))
->sortBy('pri')
->first();
@ -237,39 +237,39 @@ class Domain extends Model
]);
}
$spf = collect(dns_get_record($this->domain . '.', DNS_TXT))
$spf = collect(dns_get_record($this->domain.'.', DNS_TXT))
->contains(function ($r) {
return preg_match("/^(v=spf1).*(include:spf\." . config('anonaddy.domain') . "|mx).*(-|~)all$/", $r['txt']);
return preg_match("/^(v=spf1).*(include:spf\.".config('anonaddy.domain').'|mx).*(-|~)all$/', $r['txt']);
});
if (!$spf) {
if (! $spf) {
return response()->json([
'success' => false,
'message' => 'SPF record not found. This could be due to DNS caching, please try again later.'
'message' => 'SPF record not found. This could be due to DNS caching, please try again later.',
]);
}
$dmarc = collect(dns_get_record('_dmarc.' . $this->domain . '.', DNS_TXT))
$dmarc = collect(dns_get_record('_dmarc.'.$this->domain.'.', DNS_TXT))
->contains(function ($r) {
return preg_match("/^(v=DMARC1).*(p=quarantine|reject).*/", $r['txt']);
return preg_match('/^(v=DMARC1).*(p=quarantine|reject).*/', $r['txt']);
});
if (!$dmarc) {
if (! $dmarc) {
return response()->json([
'success' => false,
'message' => 'DMARC record not found. This could be due to DNS caching, please try again later.'
'message' => 'DMARC record not found. This could be due to DNS caching, please try again later.',
]);
}
$def = collect(dns_get_record('default._domainkey.' . $this->domain . '.', DNS_CNAME))
$def = collect(dns_get_record('default._domainkey.'.$this->domain.'.', DNS_CNAME))
->contains(function ($r) {
return $r['target'] === 'default._domainkey.' . config('anonaddy.domain');
return $r['target'] === 'default._domainkey.'.config('anonaddy.domain');
});
if (!$def) {
if (! $def) {
return response()->json([
'success' => false,
'message' => 'CNAME default._domainkey record not found. This could be due to DNS caching, please try again later.'
'message' => 'CNAME default._domainkey record not found. This could be due to DNS caching, please try again later.',
]);
}
@ -278,7 +278,7 @@ class Domain extends Model
return response()->json([
'success' => true,
'message' => 'Records successfully verified.',
'data' => new DomainResource($this->fresh())
'data' => new DomainResource($this->fresh()),
]);
}
}

View file

@ -79,10 +79,10 @@ class EmailData
];
} else {
$this->attachments[] = [
'stream' => base64_encode(stream_get_contents($attachment->getStream())),
'file_name' => base64_encode($attachment->getFileName()),
'mime' => base64_encode($contentType)
];
'stream' => base64_encode(stream_get_contents($attachment->getStream())),
'file_name' => base64_encode($attachment->getFileName()),
'mime' => base64_encode($contentType),
];
}
}
}

View file

@ -19,7 +19,7 @@ class FailedDelivery extends Model
protected $keyType = 'string';
protected $encrypted = [
'sender'
'sender',
];
protected $fillable = [
@ -32,20 +32,20 @@ class FailedDelivery extends Model
'email_type',
'status',
'code',
'attempted_at'
'attempted_at',
];
protected $dates = [
'attempted_at',
'created_at',
'updated_at'
'updated_at',
];
protected $casts = [
'id' => 'string',
'user_id' => 'string',
'recipient_id' => 'string',
'alias_id' => 'string'
'alias_id' => 'string',
];
/**

View file

@ -19,7 +19,7 @@ class PostfixQueueId extends Model
protected $dates = [
'created_at',
'updated_at'
'updated_at',
];
protected $casts = [

View file

@ -8,7 +8,6 @@ use App\Traits\HasEncryptedAttributes;
use App\Traits\HasUuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class Recipient extends Model
@ -24,7 +23,7 @@ class Recipient extends Model
protected $encrypted = [
'email',
'fingerprint'
'fingerprint',
];
protected $fillable = [
@ -35,13 +34,13 @@ class Recipient extends Model
'inline_encryption',
'protected_headers',
'fingerprint',
'email_verified_at'
'email_verified_at',
];
protected $dates = [
'created_at',
'updated_at',
'email_verified_at'
'email_verified_at',
];
protected $casts = [
@ -50,7 +49,7 @@ class Recipient extends Model
'can_reply_send' => 'boolean',
'should_encrypt' => 'boolean',
'inline_encryption' => 'boolean',
'protected_headers' => 'boolean'
'protected_headers' => 'boolean',
];
public static function boot()

View file

@ -24,12 +24,12 @@ class Rule extends Model
'replies',
'sends',
'active',
'order'
'order',
];
protected $dates = [
'created_at',
'updated_at'
'updated_at',
];
protected $casts = [
@ -40,7 +40,7 @@ class Rule extends Model
'replies' => 'boolean',
'sends' => 'boolean',
'conditions' => 'array',
'actions' => 'array'
'actions' => 'array',
];
/**

View file

@ -46,13 +46,13 @@ class User extends Authenticatable implements MustVerifyEmail
'password',
'two_factor_enabled',
'two_factor_secret',
'two_factor_backup_code'
'two_factor_backup_code',
];
protected $encrypted = [
'from_name',
'email_subject',
'two_factor_secret'
'two_factor_secret',
];
/**
@ -64,7 +64,7 @@ class User extends Authenticatable implements MustVerifyEmail
'password',
'remember_token',
'two_factor_secret',
'two_factor_backup_code'
'two_factor_backup_code',
];
/**
@ -78,13 +78,13 @@ class User extends Authenticatable implements MustVerifyEmail
'default_recipient_id' => 'string',
'catch_all' => 'boolean',
'two_factor_enabled' => 'boolean',
'use_reply_to' => 'boolean'
'use_reply_to' => 'boolean',
];
protected $dates = [
'created_at',
'updated_at',
'email_verified_at'
'email_verified_at',
];
/**
@ -404,6 +404,7 @@ class User extends Authenticatable implements MustVerifyEmail
}
$withoutExtension = preg_replace('/\+[\s\S]+(?=@)/', '', $recipient->email);
return strtolower($withoutExtension);
})
->contains(strtolower($email));
@ -455,7 +456,7 @@ class User extends Authenticatable implements MustVerifyEmail
$recipientsUsingFingerprint->first()->update([
'should_encrypt' => false,
'fingerprint' => null
'fingerprint' => null,
]);
}
});

View file

@ -18,7 +18,7 @@ class Username extends Model
protected $keyType = 'string';
protected $encrypted = [
'description'
'description',
];
protected $fillable = [
@ -31,7 +31,7 @@ class Username extends Model
protected $dates = [
'created_at',
'updated_at'
'updated_at',
];
protected $casts = [
@ -39,7 +39,7 @@ class Username extends Model
'user_id' => 'string',
'active' => 'boolean',
'catch_all' => 'boolean',
'default_recipient_id' => 'string'
'default_recipient_id' => 'string',
];
public static function boot()
@ -83,6 +83,7 @@ class Username extends Model
{
return $this->hasOne(Recipient::class, 'id', 'default_recipient_id');
}
/**
* Set the usernames's default recipient.
*/

View file

@ -40,7 +40,7 @@ class CustomVerifyEmail extends VerifyEmail implements ShouldQueue, ShouldBeEncr
->subject(Lang::get('Verify Email Address'))
->markdown('mail.verify_email', [
'verificationUrl' => $verificationUrl,
'recipientId' => $recipientId
'recipientId' => $recipientId,
])
->withSymfonyMessage(function (Email $message) use ($feedbackId) {
$message->getHeaders()

View file

@ -45,12 +45,12 @@ class DefaultRecipientUpdated extends Notification implements ShouldQueue, Shoul
public function toMail($notifiable)
{
return (new MailMessage())
->subject("Your default recipient has just been updated")
->subject('Your default recipient has just been updated')
->markdown('mail.default_recipient_updated', [
'defaultRecipient' => $notifiable->email,
'newDefaultRecipient' => $this->newDefaultRecipient,
'recipientId' => $notifiable->id,
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -15,8 +15,11 @@ class DisallowedReplySendAttempt extends Notification implements ShouldQueue, Sh
use Queueable;
protected $aliasEmail;
protected $recipient;
protected $destination;
protected $authenticationResults;
/**
@ -26,7 +29,7 @@ class DisallowedReplySendAttempt extends Notification implements ShouldQueue, Sh
*/
public function __construct($alias, $recipient, $authenticationResults)
{
$this->aliasEmail = $alias['local_part'] . '@' . $alias['domain'];
$this->aliasEmail = $alias['local_part'].'@'.$alias['domain'];
$this->recipient = $recipient;
$this->destination = Str::replaceLast('=', '@', $alias['extension']);
$this->authenticationResults = $authenticationResults;
@ -61,7 +64,7 @@ class DisallowedReplySendAttempt extends Notification implements ShouldQueue, Sh
'destination' => $this->destination,
'authenticationResults' => $this->authenticationResults,
'recipientId' => $notifiable->id,
'fingerprint' => $fingerprint
'fingerprint' => $fingerprint,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -52,7 +52,7 @@ class DomainMxRecordsInvalid extends Notification implements ShouldQueue, Should
->markdown('mail.domain_mx_records_invalid', [
'domain' => $this->domain,
'recipientId' => $recipient->_id,
'fingerprint' => $fingerprint
'fingerprint' => $fingerprint,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -14,6 +14,7 @@ class DomainUnverifiedForSending extends Notification implements ShouldQueue, Sh
use Queueable;
protected $domain;
protected $reason;
/**
@ -50,12 +51,12 @@ class DomainUnverifiedForSending extends Notification implements ShouldQueue, Sh
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
->subject("Your domain has been unverified for sending on AnonAddy")
->subject('Your domain has been unverified for sending on AnonAddy')
->markdown('mail.domain_unverified_for_sending', [
'domain' => $this->domain,
'reason' => $this->reason,
'recipientId' => $recipient->id,
'fingerprint' => $fingerprint
'fingerprint' => $fingerprint,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -13,7 +13,9 @@ class FailedDeliveryNotification extends Notification implements ShouldQueue, Sh
use Queueable;
protected $aliasEmail;
protected $originalSender;
protected $originalSubject;
/**
@ -48,13 +50,13 @@ class FailedDeliveryNotification extends Notification implements ShouldQueue, Sh
public function toMail($notifiable)
{
return (new MailMessage())
->subject("New failed delivery on AnonAddy")
->subject('New failed delivery on AnonAddy')
->markdown('mail.failed_delivery_notification', [
'aliasEmail' => $this->aliasEmail,
'originalSender' => $this->originalSender,
'originalSubject' => $this->originalSubject,
'recipientId' => $notifiable->id,
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null,
])
->withSymfonyMessage(function ($message) {
$message->getHeaders()

View file

@ -33,9 +33,9 @@ class GpgKeyExpired extends Notification implements ShouldQueue, ShouldBeEncrypt
public function toMail($notifiable)
{
return (new MailMessage())
->subject("Your GPG key has expired on AnonAddy")
->subject('Your GPG key has expired on AnonAddy')
->markdown('mail.gpg_key_expired', [
'recipient' => $notifiable
'recipient' => $notifiable,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -36,12 +36,12 @@ class IncorrectOtpNotification extends Notification implements ShouldQueue, Shou
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
->subject("Failed Two Factor Authentication Login Attempt")
->subject('Failed Two Factor Authentication Login Attempt')
->markdown('mail.failed_login_attempt', [
'recipientId' => $recipient->id,
'hasVerifiedEmail' => $recipient->hasVerifiedEmail(),
'fingerprint' => $fingerprint,
'username' => $notifiable->username
'username' => $notifiable->username,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -14,6 +14,7 @@ class NearBandwidthLimit extends Notification implements ShouldQueue, ShouldBeEn
use Queueable;
protected $month;
protected $reset;
/**
@ -57,7 +58,7 @@ class NearBandwidthLimit extends Notification implements ShouldQueue, ShouldBeEn
'month' => $this->month,
'reset' => $this->reset,
'recipientId' => $recipient->id,
'fingerprint' => $fingerprint
'fingerprint' => $fingerprint,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

View file

@ -15,8 +15,11 @@ class SpamReplySendAttempt extends Notification implements ShouldQueue, ShouldBe
use Queueable;
protected $aliasEmail;
protected $recipient;
protected $destination;
protected $authenticationResults;
/**
@ -26,7 +29,7 @@ class SpamReplySendAttempt extends Notification implements ShouldQueue, ShouldBe
*/
public function __construct($alias, $recipient, $authenticationResults)
{
$this->aliasEmail = $alias['local_part'] . '@' . $alias['domain'];
$this->aliasEmail = $alias['local_part'].'@'.$alias['domain'];
$this->recipient = $recipient;
$this->destination = Str::replaceLast('=', '@', $alias['extension']);
$this->authenticationResults = $authenticationResults;
@ -59,7 +62,7 @@ class SpamReplySendAttempt extends Notification implements ShouldQueue, ShouldBe
'destination' => $this->destination,
'authenticationResults' => $this->authenticationResults,
'recipientId' => $notifiable->id,
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null
'fingerprint' => $notifiable->should_encrypt ? $notifiable->fingerprint : null,
])
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()

Some files were not shown because too many files have changed in this diff Show more