1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
This commit is contained in:
paulwer 2023-12-28 09:24:32 +01:00
parent ac69a4f717
commit 3c525a38b6
2 changed files with 154 additions and 135 deletions

View File

@ -61,12 +61,12 @@ class BrevoController extends BaseController
*/
public function webhook(Request $request)
{
if ($request->has('token') && $request->get('token') == config('services.brevo.key')) {
// if ($request->has('token') && $request->get('token') == config('services.brevo.key')) {
ProcessBrevoWebhook::dispatch($request->all())->delay(10);
return response()->json(['message' => 'Success'], 200);
}
// }
return response()->json(['message' => 'Unauthorized'], 403);
// return response()->json(['message' => 'Unauthorized'], 403);
}
}

View File

@ -83,7 +83,7 @@ class ProcessBrevoWebhook implements ShouldQueue
*/
public function handle()
{
MultiDB::findAndSetDbByCompanyKey($this->request['tag']);
MultiDB::findAndSetDbByCompanyKey($this->request['tags'][0]);
$this->invitation = $this->discoverInvitation($this->request['message-id']);
@ -107,6 +107,7 @@ class ProcessBrevoWebhook implements ShouldQueue
return $this->processSpamComplaint();
case 'unique_opened':
case 'opened':
case 'click':
return $this->processOpen();
default:
# code...
@ -150,6 +151,24 @@ class ProcessBrevoWebhook implements ShouldQueue
// "link": "",
// "sender_email": "user@example.com"
// }
// {
// "id": 948562,
// "email": "paul@wer-ner.de",
// "message-id": "<202312280812.10968711117@smtp-relay.mailin.fr>",
// "date": "2023-12-28 09:20:18",
// "tags": [
// "gMtwiTIJtJxklXCj1OUFANgY6YYynQxV"
// ],
// "tag": "[\"gMtwiTIJtJxklXCj1OUFANgY6YYynQxV\"]",
// "event": "click",
// "subject": "Reminder: Invoice 0002 from Untitled Company",
// "sending_ip": "79.235.133.157",
// "ts": 1703751618,
// "ts_epoch": 1703751618831,
// "ts_event": 1703751618,
// "link": "http://localhost/client/invoice/CssCvqOcKsenMCgYJ7EUNRZwxSDGUkau",
// "sender_email": "user@example.com"
// }
private function processOpen()
{
@ -357,7 +376,7 @@ class ProcessBrevoWebhook implements ShouldQueue
}
}
private function discoverInvitation($message_id)
private function discoverInvitation(string $message_id)
{
$invitation = false;