diff --git a/src/Module/Inbox.php b/src/Module/Inbox.php index 0ac1f1113..e5d96f5b5 100644 --- a/src/Module/Inbox.php +++ b/src/Module/Inbox.php @@ -6,6 +6,7 @@ namespace Code\Module; use App; +use Code\Lib\ActorId; use Code\Lib\Time; use Code\Web\HTTPSig; use Code\Lib\ActivityStreams; @@ -261,7 +262,7 @@ class Inbox extends Controller $collections = Activity::get_actor_collections($observer_hash); - if (is_array($collections) && in_array($collections['followers'], $AS->recips) + if ((is_array($collections) && in_array($collections['followers'], $AS->recips)) || in_array(ACTIVITY_PUBLIC_INBOX, $AS->recips) || in_array('Public', $AS->recips) || in_array('as:Public', $AS->recips)) { @@ -280,14 +281,23 @@ class Inbox extends Controller // deliver to anybody at this site directly addressed $channel_addr = ''; foreach($AS->recips as $recip) { - if (str_starts_with($recip, z_root())) { - $channel_addr .= '\'' . dbesc(basename($recip)) . '\','; + if (!str_starts_with($recip, z_root())) { + continue; + } + $actorId = new ActorId($recip); + if ($actorId->getType() === ActorId::ACTORID_TYPE_URL) { + $query = q("SELECT * from channel left join xchan on channel_hash = xchan_hash where xchan_url = '%s' and channel_removed = 0", + dbesc($recip) + ); + } + else { + $query = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_epubkey = '%s' and channel_removed = 0", + dbesc(str_replace('did:key:', '', $actorId->getId())) + ); + } + if ($query) { + $channels[] = array_shift($query); } - } - if ($channel_addr) { - $channel_addr = rtrim($channel_addr, ','); - $channels = dbq("SELECT * FROM channel - WHERE channel_address IN ($channel_addr) AND channel_removed = 0"); } }