diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/channel.php | 4 | ||||
-rw-r--r-- | include/conversation.php | 11 | ||||
-rw-r--r-- | include/zot.php | 56 |
3 files changed, 64 insertions, 7 deletions
diff --git a/include/channel.php b/include/channel.php index ccec4f9ee..ae186d02f 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2384,7 +2384,7 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { - $default_cover = get_config('system','default_cover_photo','pexels-94622'); + $default_cover = get_config('system','default_cover_photo','bggenerator'); $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; } @@ -2458,7 +2458,7 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { - $default_cover = get_config('system','default_cover_photo','pexels-94622'); + $default_cover = get_config('system','default_cover_photo','bggenerator'); $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; } diff --git a/include/conversation.php b/include/conversation.php index c8c36f241..e77404cff 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -102,19 +102,20 @@ function localize_item(&$item){ logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } - if($obj['author'] && $obj['author']['link']) + if(is_array($obj['author']) && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); - elseif($obj['actor'] && $obj['actor']['url']) - $author_link = $obj['actor']['url'][0]['href']; + elseif(is_array($obj['actor']) && $obj['actor']['url']) + $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); else $author_link = ''; $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); if(!$author_name) - $author_name = (($obj['actor'] && $obj['actor']['name']) ? $obj['actor']['name'] : ''); + $author_name = ((is_array($obj['actor']) && $obj['actor']['name']) ? $obj['actor']['name'] : ''); - $item_url = get_rel_link($obj['link'],'alternate'); + if(is_array($obj['link'])) + $item_url = get_rel_link($obj['link'],'alternate'); if(!$item_url) $item_url = $obj['id']; diff --git a/include/zot.php b/include/zot.php index e10ef6fd7..38d6288cf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -9,6 +9,7 @@ */ use Zotlabs\Lib\DReport; +use Zotlabs\Lib\Libzot; require_once('include/crypto.php'); require_once('include/items.php'); @@ -1952,6 +1953,31 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ intval($channel['channel_id']), dbesc($arr['owner_xchan']) ); + + if(! $ab) { + + $best_owner_xchan = find_best_zot_identity($arr['owner_xchan']); + + $ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'", + intval($channel['channel_id']), + dbesc($best_owner_xchan) + ); + + if($ab) + $arr['owner_xchan'] = $best_owner_xchan; + } + + $best_author_xchan = find_best_zot_identity($arr['author_xchan']); + + $ab_author = q("select * from abook where abook_channel = %d and abook_xchan = '%s'", + intval($channel['channel_id']), + dbesc($best_author_xchan) + ); + + if($ab_author) + $arr['author_xchan'] = $best_author_xchan; + + $abook = (($ab) ? $ab[0] : null); if(intval($arr['item_deleted'])) { @@ -5341,3 +5367,33 @@ function zot_record_preferred($arr, $check = 'hubloc_network') { return $arr[0]; } + +function find_best_zot_identity($xchan) { + + if (filter_var($xchan, FILTER_VALIDATE_URL)) { + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'", + dbesc($xchan) + ); + if ($r) { + $r = Libzot::zot_record_preferred($r); + return $r['hubloc_hash']; + } + } + + $r = q("select hubloc_addr from hubloc where hubloc_hash = '%s'", + dbesc($xchan) + ); + + if ($r) { + + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s'", + dbesc($r[0]['hubloc_addr']) + ); + if ($r) { + $r = Libzot::zot_record_preferred($r); + return $r['hubloc_hash']; + } + } + + return $xchan; +} |