2021-02-22 10:46:01 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-02-22 10:46:01 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-02-22 10:46:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2021-09-29 03:17:04 +02:00
|
|
|
use App\DataMapper\Analytics\Mail\EmailBounce;
|
2021-08-08 09:58:40 +02:00
|
|
|
use App\DataMapper\Analytics\Mail\EmailSpam;
|
2022-01-16 04:11:48 +01:00
|
|
|
use App\Jobs\PostMark\ProcessPostmarkWebhook;
|
2021-02-23 23:56:23 +01:00
|
|
|
use App\Jobs\Util\SystemLogger;
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
use App\Models\CreditInvitation;
|
|
|
|
use App\Models\InvoiceInvitation;
|
|
|
|
use App\Models\QuoteInvitation;
|
|
|
|
use App\Models\RecurringInvoiceInvitation;
|
|
|
|
use App\Models\SystemLog;
|
2022-01-05 04:41:57 +01:00
|
|
|
use App\Notifications\Ninja\EmailBounceNotification;
|
|
|
|
use App\Notifications\Ninja\EmailSpamNotification;
|
2021-02-22 10:46:01 +01:00
|
|
|
use Illuminate\Http\Request;
|
2021-05-04 04:49:32 +02:00
|
|
|
use Turbo124\Beacon\Facades\LightLogs;
|
2021-02-22 10:46:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class PostMarkController.
|
|
|
|
*/
|
|
|
|
class PostMarkController extends BaseController
|
|
|
|
{
|
2021-02-23 23:56:23 +01:00
|
|
|
private $invitation;
|
2021-02-22 10:46:01 +01:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Postmark Webhook.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/postmark_webhook",
|
|
|
|
* operationId="postmarkWebhook",
|
|
|
|
* tags={"postmark"},
|
|
|
|
* summary="Processing webhooks from PostMark",
|
|
|
|
* description="Adds an credit to the system",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the saved credit object",
|
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
|
|
|
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
|
|
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Credit"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response="default",
|
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function webhook(Request $request)
|
|
|
|
{
|
2023-01-11 09:29:27 +01:00
|
|
|
if ($request->header('X-API-SECURITY') && $request->header('X-API-SECURITY') == config('services.postmark.token')) {
|
2022-01-16 04:11:48 +01:00
|
|
|
ProcessPostmarkWebhook::dispatch($request->all());
|
2021-02-22 10:46:01 +01:00
|
|
|
|
2021-02-23 23:56:23 +01:00
|
|
|
return response()->json(['message' => 'Success'], 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
return response()->json(['message' => 'Unauthorized'], 403);
|
|
|
|
}
|
2021-02-22 10:46:01 +01:00
|
|
|
}
|