From 8d3c201830020d63a5204df04fdcb2ae04bf2b0f Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 20:22:07 +0000 Subject: if we receive an item with a zot xchan as author or owner rewrite them to the zot6 xchan if we have their zot6 xchan in abook --- include/zot.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/include/zot.php b/include/zot.php index e10ef6fd7..ce5fd0174 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'])) { @@ -2044,6 +2070,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $result[] = $DR->get(); } else { + + hz_syslog(print_r($arr,true)); + + $item_result = item_store($arr); if($item_result['success']) { $item_id = $item_result['item_id']; @@ -5341,3 +5371,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; +} -- cgit v1.2.3 From 5f93157d5a5cc824d98c39d1983d882df0a13067 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 20:28:48 +0000 Subject: improve find_best_identity() and fix wrong variable --- Zotlabs/Lib/Activity.php | 17 +++++++++++------ Zotlabs/Lib/Libzot.php | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index f3885033b..4886f9239 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -3185,14 +3185,19 @@ class Activity { } static function find_best_identity($xchan) { - $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']; + + 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']; + } } + return $xchan; + } } diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index fb64626d6..654b0461b 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1469,8 +1469,8 @@ class Libzot { // Make sure we use the zot6 identity where applicable - $msg_arr['author_xchan'] = Activity::find_best_identity($msg_arr['author_xchan']); - $msg_arr['owner_xchan'] = Activity::find_best_identity($msg_arr['owner_xchan']); + $arr['author_xchan'] = Activity::find_best_identity($arr['author_xchan']); + $arr['owner_xchan'] = Activity::find_best_identity($arr['owner_xchan']); // We've validated the sender. Now make sure that the sender is the owner or author -- cgit v1.2.3 From 375986437ab94d3e25bb829409971adc89d4bdf9 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 20:58:30 +0000 Subject: fix php warnings --- include/conversation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index c8c36f241..0be50ce26 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -104,15 +104,15 @@ function localize_item(&$item){ if($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'); -- cgit v1.2.3 From 31e030af69bd5e542dff45b299718f6c12b08467 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 21:01:36 +0000 Subject: missing parenthesis --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index 0be50ce26..48a72aa21 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -105,7 +105,7 @@ function localize_item(&$item){ if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); elseif(is_array($obj['actor']) && $obj['actor']['url']) - $author_link = ((is_array($obj['actor']['url']) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); + $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); else $author_link = ''; -- cgit v1.2.3 From 8cd67a5d4a7072034df581e8ce212f1d24055348 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 21:37:44 +0000 Subject: fix more php warnings and remove temporary logging --- include/conversation.php | 5 +++-- include/zot.php | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 48a72aa21..e77404cff 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -102,7 +102,7 @@ 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(is_array($obj['actor']) && $obj['actor']['url']) $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); @@ -114,7 +114,8 @@ function localize_item(&$item){ if(!$author_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 ce5fd0174..38d6288cf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2070,10 +2070,6 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $result[] = $DR->get(); } else { - - hz_syslog(print_r($arr,true)); - - $item_result = item_store($arr); if($item_result['success']) { $item_id = $item_result['item_id']; -- cgit v1.2.3 From e12f375624d980702e0ae81cdd161c77ccd527ca Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Oct 2020 07:25:33 +0000 Subject: return if author or owner is missing and add more logging --- Zotlabs/Lib/Activity.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4886f9239..6d12f7ea1 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2499,11 +2499,17 @@ class Activity { $item['author_xchan'] = self::find_best_identity($item['author_xchan']); $item['owner_xchan'] = self::find_best_identity($item['owner_xchan']); - if(! ( $item['author_xchan'] && $item['owner_xchan'])) { - logger('owner or author missing.'); - return; + if(!$item['author_xchan']) { + logger('No author: ' . print_r($act, true)); } + if(!$item['owner_xchan']) { + logger('No owner: ' . print_r($act, true)); + } + + if(!$item['author_xchan'] || !$item['owner_xchan']) + return; + if($channel['channel_system']) { if(! MessageFilter::evaluate($item,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) { logger('post is filtered'); @@ -2699,6 +2705,7 @@ class Activity { static public function fetch_and_store_replies($channel, $arr) { logger('fetching replies'); + logger(print_r($arr,true)); $p = []; -- cgit v1.2.3 From b103993ad155c8b304a6ce6fa345251691c0fb54 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Oct 2020 08:14:14 +0000 Subject: this is not required here --- Zotlabs/Lib/Libzot.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 654b0461b..44f1f399e 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1467,11 +1467,6 @@ class Libzot { $result = []; - // Make sure we use the zot6 identity where applicable - - $arr['author_xchan'] = Activity::find_best_identity($arr['author_xchan']); - $arr['owner_xchan'] = Activity::find_best_identity($arr['owner_xchan']); - // We've validated the sender. Now make sure that the sender is the owner or author if(! $public) { -- cgit v1.2.3 From 08e7c7b249e123edaa81348e54180e89080de012 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Oct 2020 08:16:14 +0000 Subject: use a more neutral default cover image provided by bggenerator.com --- images/default_cover_photos/bggenerator/1200.png | Bin 0 -> 619094 bytes images/default_cover_photos/bggenerator/425.png | Bin 0 -> 90041 bytes images/default_cover_photos/bggenerator/850.png | Bin 0 -> 315235 bytes include/channel.php | 4 ++-- 4 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 images/default_cover_photos/bggenerator/1200.png create mode 100644 images/default_cover_photos/bggenerator/425.png create mode 100644 images/default_cover_photos/bggenerator/850.png diff --git a/images/default_cover_photos/bggenerator/1200.png b/images/default_cover_photos/bggenerator/1200.png new file mode 100644 index 000000000..53aaafd7f Binary files /dev/null and b/images/default_cover_photos/bggenerator/1200.png differ diff --git a/images/default_cover_photos/bggenerator/425.png b/images/default_cover_photos/bggenerator/425.png new file mode 100644 index 000000000..5dbfe1e2b Binary files /dev/null and b/images/default_cover_photos/bggenerator/425.png differ diff --git a/images/default_cover_photos/bggenerator/850.png b/images/default_cover_photos/bggenerator/850.png new file mode 100644 index 000000000..e9f476f86 Binary files /dev/null and b/images/default_cover_photos/bggenerator/850.png differ 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' ]; } -- cgit v1.2.3