From 08d06064cec2f7653310d3ed0ceeea29c3c1bb7c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 22 Nov 2023 11:07:18 +0000 Subject: [PATCH] Issue 13627: DMs now work bidirectional again --- src/Protocol/ActivityPub/Receiver.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index cd48768cc7..f195c8b9e6 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -682,7 +682,7 @@ class Receiver self::addArrivedId($object_data['object_id']); } - $decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE]); + $decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE]) && empty($object_data['directmessage']); if ($decouple && ($trust_source || DI::config()->get('debug', 'ap_inbox_store_untrusted'))) { $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source); diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 83155bf4f1..0a36f0c5bd 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1121,19 +1121,17 @@ class Transmitter */ public static function fetchTargetInboxesFromMail(int $mail_id): array { - $mail = DBA::selectFirst('mail', ['uid', 'parent-uri', 'from-url'], ['id' => $mail_id]); + $mail = DBA::selectFirst('mail', ['contact-id'], ['id' => $mail_id]); if (!DBA::isResult($mail)) { return []; } - $reply = DBA::selectFirst('mail', ['from-url'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]); - if (!DBA::isResult($reply)) { - $reply = $mail; + $account = DBA::selectFirst('account-user-view', ['ap-inbox'], ['id' => $mail['contact-id']]); + if (empty($account['ap-inbox'])) { + return []; } - $apcontact = APContact::getByURL($reply['from-url'], false); - - return [$apcontact['inbox'] => [Contact::getIdForURL($reply['from-url'])]]; + return [$account['ap-inbox'] => [$mail['contact-id']]]; } /** -- 2.39.5