From 0e9914b26800ad9003e40ad081ac27e0b23c4f6c Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 1 May 2024 07:19:28 +1000 Subject: [PATCH] set default app --- include/misc.php | 4 ++-- include/xchan.php | 16 ++++++++++++++++ src/Lib/ThreadItem.php | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/misc.php b/include/misc.php index 74de73615..3f4dafb80 100644 --- a/include/misc.php +++ b/include/misc.php @@ -2657,11 +2657,11 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0) if ($abook) { $chans = q( "select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d - where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc", + left join site on site_url = hubloc_url where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc", intval($item['uid']) ); } else { - $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash + $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash left join site on site_url = hubloc_url where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc"); } $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and xchan_network in ('rss','unknown', 'anon')"); diff --git a/include/xchan.php b/include/xchan.php index 2e5fb19b8..fe40210cb 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -163,6 +163,22 @@ function xchan_store($arr) return true; } +function xchan_project($xchan) +{ + if (!empty($xchan['xchan_url'])) { + $parsed = parse_url($xchan['xchan_url']); + if ($parsed) { + $url = $parsed['scheme'] . '://' . $parsed['host']; + $record = q("select site_project from site where site_url = '%s'", + dbesc($url) + ); + if ($record) { + return $record[0]['site_project']; + } + } + } + return ''; +} function xchan_match($arr) { diff --git a/src/Lib/ThreadItem.php b/src/Lib/ThreadItem.php index daca48cb9..7627182cf 100644 --- a/src/Lib/ThreadItem.php +++ b/src/Lib/ThreadItem.php @@ -410,7 +410,10 @@ class ThreadItem if (!$locicon) { $locicon = ($item['verb'] === 'Leave') ? ' ' : ''; } - + $author_app = $item['author']['site_project'] ?? ''; + if (empty($item['app'])) { + $item['app'] = $author_app; + } $isContained = $thread_level === 1 && str_contains($item['tgt_type'],'Collection'); $tmp_item = [