From 99fb80bf5dfdc475477ba30f194ca200e5c026f7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault <877217+dansup@users.noreply.github.com> Date: Thu, 1 Sep 2022 05:15:20 -0600 Subject: [PATCH] Update InboxPipeline, fix peertube attributedTo parsing --- app/Jobs/InboxPipeline/DeleteWorker.php | 14 +++++++++++--- app/Jobs/InboxPipeline/InboxValidator.php | 10 +++++++++- app/Jobs/InboxPipeline/InboxWorker.php | 10 +++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/Jobs/InboxPipeline/DeleteWorker.php b/app/Jobs/InboxPipeline/DeleteWorker.php index 5639f9752..25dbde6dd 100644 --- a/app/Jobs/InboxPipeline/DeleteWorker.php +++ b/app/Jobs/InboxPipeline/DeleteWorker.php @@ -140,9 +140,17 @@ class DeleteWorker implements ShouldQueue && is_array($bodyDecoded['object']) && isset($bodyDecoded['object']['attributedTo']) ) { - if(parse_url($bodyDecoded['object']['attributedTo'], PHP_URL_HOST) !== $keyDomain) { - return; - } + $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']); + if(is_array($attr)) { + if(isset($attr['id'])) { + $attr = $attr['id']; + } else { + $attr = ""; + } + } + if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) { + return; + } } if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) { return; diff --git a/app/Jobs/InboxPipeline/InboxValidator.php b/app/Jobs/InboxPipeline/InboxValidator.php index 481844bb2..070746cd4 100644 --- a/app/Jobs/InboxPipeline/InboxValidator.php +++ b/app/Jobs/InboxPipeline/InboxValidator.php @@ -167,7 +167,15 @@ class InboxValidator implements ShouldQueue && is_array($bodyDecoded['object']) && isset($bodyDecoded['object']['attributedTo']) ) { - if(parse_url(Helpers::pluckval($bodyDecoded['object']['attributedTo']), PHP_URL_HOST) !== $keyDomain) { + $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']); + if(is_array($attr)) { + if(isset($attr['id'])) { + $attr = $attr['id']; + } else { + $attr = ""; + } + } + if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) { return; } } diff --git a/app/Jobs/InboxPipeline/InboxWorker.php b/app/Jobs/InboxPipeline/InboxWorker.php index f475b2dc5..16ac4840a 100644 --- a/app/Jobs/InboxPipeline/InboxWorker.php +++ b/app/Jobs/InboxPipeline/InboxWorker.php @@ -157,7 +157,15 @@ class InboxWorker implements ShouldQueue && is_array($bodyDecoded['object']) && isset($bodyDecoded['object']['attributedTo']) ) { - if(parse_url(Helpers::pluckval($bodyDecoded['object']['attributedTo']), PHP_URL_HOST) !== $keyDomain) { + $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']); + if(is_array($attr)) { + if(isset($attr['id'])) { + $attr = $attr['id']; + } else { + $attr = ""; + } + } + if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) { return; } }