From b7f124072fd8d4fec5b0c1ec1e56b3b854f640e7 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 May 2021 11:25:36 +0000 Subject: import_author_xchan(): do not import legacy zot --- Zotlabs/Lib/Libzot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index c7d001d21..5cd304679 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2664,9 +2664,9 @@ class Libzot { // we may only end up with one; which results in posts with no author name or photo and are a bit // of a hassle to repair. If either or both are missing, do a full discovery probe. - //if (!array_key_exists('id', $x)) { - //return import_author_activitypub($x); - //} + if(!isset($x['id']) && !isset($x['key']) && !isset($x['id_sig'])) { + return false; + } $hash = self::make_xchan_hash($x['id'], $x['key']); -- cgit v1.2.3 From b742910107720797b05ec69ae626b420699e0630 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 May 2021 11:28:33 +0000 Subject: remove legacy zot from supported protocols --- Zotlabs/Lib/Libzot.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 5cd304679..e44a82b71 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2927,7 +2927,7 @@ class Libzot { $hookinfo = [ 'channel_id' => $id, - 'protocols' => ['zot6', 'zot'] + 'protocols' => ['zot6'] ]; /** * @hooks channel_protocols @@ -3231,11 +3231,6 @@ class Libzot { return $v; } } - foreach ($arr as $v) { - if ($v[$check] === 'zot') { - return $v; - } - } return $arr[0]; -- cgit v1.2.3 From 1fa4bc9ac024983d4748262f98c6ddf323ad327c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 May 2021 12:18:59 +0000 Subject: remove most legacy zot quirks --- Zotlabs/Lib/Activity.php | 2 +- Zotlabs/Lib/Apps.php | 2 +- Zotlabs/Lib/Connect.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 6e8344def..500e99ee8 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -3496,7 +3496,7 @@ class Activity { static function find_best_identity($xchan) { if (filter_var($xchan, FILTER_VALIDATE_URL)) { - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_network in ('zot6', 'zot') and hubloc_deleted = 0", + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' and hubloc_deleted = 0", dbesc($xchan) ); if ($r) { diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 5ef4ecc8d..bd51f0896 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -524,7 +524,7 @@ class Apps { } elseif(remote_channel()) { $observer = \App::get_observer(); - if($observer && in_array($observer['xchan_network'], ['zot6', 'zot'])) { + if($observer && $observer['xchan_network'] === 'zot6') { // some folks might have xchan_url redirected offsite, use the connurl $x = parse_url($observer['xchan_connurl']); if($x) { diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php index 21bec171b..38fe69995 100644 --- a/Zotlabs/Lib/Connect.php +++ b/Zotlabs/Lib/Connect.php @@ -146,7 +146,7 @@ class Connect { } - $allowed = ((in_array($xchan['xchan_network'],['rss','zot','zot6'])) ? 1 : 0); + $allowed = ((in_array($xchan['xchan_network'],['rss', 'zot6'])) ? 1 : 0); $hookdata = ['channel_id' => $uid, 'follow_address' => $url, 'xchan' => $xchan, 'allowed' => $allowed, 'singleton' => 0]; call_hooks('follow_allow',$hookdata); -- cgit v1.2.3 From 1c8000d02679e2465b0e86be673f68375703db4a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 May 2021 19:02:13 +0000 Subject: remove more legacy zot quirks --- Zotlabs/Lib/DReport.php | 3 +-- Zotlabs/Lib/Libzotdir.php | 18 +++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php index 7515d3292..2263529b2 100644 --- a/Zotlabs/Lib/DReport.php +++ b/Zotlabs/Lib/DReport.php @@ -87,8 +87,7 @@ class DReport { // Is the sender one of our channels? - $c = q("select channel_id from channel where channel_hash = '%s' or channel_portable_id = '%s' limit 1", - dbesc($dr['sender']), + $c = q("select channel_id from channel where channel_hash = '%s' limit 1", dbesc($dr['sender']) ); diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 41c0a54e9..e095502dd 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -345,7 +345,7 @@ class Libzotdir { logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG); - $p = q("select channel.channel_hash, channel_address, channel_timezone, channel_portable_id, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", + $p = q("select channel.channel_hash, channel_address, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", intval($uid) ); @@ -354,7 +354,6 @@ class Libzotdir { if ($p) { $hash = $p[0]['channel_hash']; - $legacy_hash = $p[0]['channel_portable_id']; $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; @@ -393,10 +392,9 @@ class Libzotdir { ); if(intval($r[0]['xchan_hidden']) != $hidden) { - $r = q("update xchan set xchan_hidden = %d where xchan_hash in ('%s', '%s')", + $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'", intval($hidden), - dbesc($hash), - dbesc($legacy_hash) + dbesc($hash) ); } @@ -410,13 +408,11 @@ class Libzotdir { } else { // they may have made it private - q("delete from xprof where xprof_hash in ('%s', '%s')", - dbesc($hash), - dbesc($legacy_hash) + q("delete from xprof where xprof_hash = '%s'", + dbesc($hash) ); - q("delete from xtag where xtag_hash in ('%s', '%s')", - dbesc($hash), - dbesc($legacy_hash) + q("delete from xtag where xtag_hash = '%s'", + dbesc($hash) ); } -- cgit v1.2.3 From 4e4bffe5c5e04e40a0a4c9bc7190704f404225e8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 May 2021 07:52:18 +0000 Subject: deprecate queue_deliver() --- Zotlabs/Lib/Queue.php | 92 ++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 68 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 373a7d304..35eb1e264 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -2,6 +2,9 @@ namespace Zotlabs\Lib; +use Zotlabs\Zot6\Receiver; +use Zotlabs\Zot6\Zot6Handler; + class Queue { static function update($id, $add_priority = 0) { @@ -28,19 +31,19 @@ class Queue { $might_be_down = ((datetime_convert('UTC','UTC',$y[0]['earliest']) < datetime_convert('UTC','UTC','now - 2 days')) ? true : false); - // Set all other records for this destination way into the future. + // Set all other records for this destination way into the future. // The queue delivers by destination. We'll keep one queue item for // this destination (this one) with a shorter delivery. If we succeed // once, we'll try to deliver everything for that destination. - // The delivery will be set to at most once per hour, and if the + // The delivery will be set to at most once per hour, and if the // queue item is less than 12 hours old, we'll schedule for fifteen - // minutes. + // minutes. q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'", dbesc(datetime_convert('UTC','UTC','now + 5 days')), dbesc($x[0]['outq_posturl']) ); - + $since = datetime_convert('UTC','UTC',$x[0]['outq_created']); if(($might_be_down) || ($since < datetime_convert('UTC','UTC','now - 12 hour'))) { @@ -50,9 +53,9 @@ class Queue { $next = datetime_convert('UTC','UTC','now + ' . intval($add_priority) . ' minutes'); } - q("UPDATE outq SET outq_updated = '%s', - outq_priority = outq_priority + %d, - outq_scheduled = '%s' + q("UPDATE outq SET outq_updated = '%s', + outq_priority = outq_priority + %d, + outq_scheduled = '%s' WHERE outq_hash = '%s'", dbesc(datetime_convert()), @@ -66,7 +69,7 @@ class Queue { static function remove($id,$channel_id = 0) { logger('queue: remove queue item ' . $id,LOGGER_DEBUG); $sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : ''); - + q("DELETE FROM outq WHERE outq_hash = '%s' $sql_extra", dbesc($id) ); @@ -75,7 +78,7 @@ class Queue { static function remove_by_posturl($posturl) { logger('queue: remove queue posturl ' . $posturl,LOGGER_DEBUG); - + q("DELETE FROM outq WHERE outq_posturl = '%s' ", dbesc($posturl) ); @@ -88,7 +91,7 @@ class Queue { $sql_extra = (($channel['channel_id']) ? " and outq_channel = " . intval($channel['channel_id']) . " " : ''); // Set the next scheduled run date so far in the future that it will be expired - // long before it ever makes it back into the delivery chain. + // long before it ever makes it back into the delivery chain. q("update outq set outq_delivered = 1, outq_updated = '%s', outq_scheduled = '%s' where outq_hash = '%s' $sql_extra ", dbesc(datetime_convert()), @@ -108,7 +111,7 @@ class Queue { } $x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority, - outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg ) + outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )", dbesc($arr['hash']), intval($arr['account_id']), @@ -133,7 +136,7 @@ class Queue { $base = null; $h = parse_url($outq['outq_posturl']); - if($h !== false) + if($h !== false) $base = $h['scheme'] . '://' . $h['host'] . (isset($h['port']) ? ':' . $h['port'] : ''); if(($base) && ($base !== z_root()) && ($immediate)) { @@ -147,7 +150,7 @@ class Queue { return; } if($y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { - self::update($outq['outq_hash'],10); + self::update($outq['outq_hash'], 10); logger('immediate delivery deferred for site ' . $base); return; } @@ -158,12 +161,12 @@ class Queue { // your site has existed. Since we don't know for sure what these sites are, // call them unknown - site_store_lowlevel( + site_store_lowlevel( [ 'site_url' => $base, 'site_update' => datetime_convert(), 'site_dead' => 0, - 'site_type' => intval(($outq['outq_driver'] === 'post') ? SITE_TYPE_NOTZOT : SITE_TYPE_UNKNOWN), + 'site_type' => SITE_TYPE_UNKNOWN, 'site_crypto' => '' ] ); @@ -171,65 +174,17 @@ class Queue { } $arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate); - call_hooks('queue_deliver',$arr); + call_hooks('queue_deliver', $arr); if($arr['handled']) return; - // "post" queue driver - used for diaspora and friendica-over-diaspora communications. - - if($outq['outq_driver'] === 'post') { - $result = z_post_url($outq['outq_posturl'],$outq['outq_msg']); - if($result['success'] && $result['return_code'] < 300) { - logger('deliver: queue post success to ' . $outq['outq_posturl'], LOGGER_DEBUG); - if($base) { - q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ", - dbesc(datetime_convert()), - dbesc($base) - ); - } - q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s'", - dbesc('accepted for delivery'), - dbesc(datetime_convert()), - dbesc($outq['outq_hash']) - ); - self::remove($outq['outq_hash']); - - // server is responding - see if anything else is going to this destination and is piled up - // and try to send some more. We're relying on the fact that do_delivery() results in an - // immediate delivery otherwise we could get into a queue loop. - - if(! $immediate) { - $x = q("select outq_hash from outq where outq_posturl = '%s' and outq_delivered = 0", - dbesc($outq['outq_posturl']) - ); - - $piled_up = array(); - if($x) { - foreach($x as $xx) { - $piled_up[] = $xx['outq_hash']; - } - } - if($piled_up) { - // call do_delivery() with the force flag - do_delivery($piled_up, true); - } - } - } - else { - logger('deliver: queue post returned ' . $result['return_code'] - . ' from ' . $outq['outq_posturl'],LOGGER_DEBUG); - self::update($outq['outq_hash'],10); - } - return; - } - // normal zot delivery logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG); if($outq['outq_posturl'] === z_root() . '/zot') { // local delivery - $zot = new \Zotlabs\Zot6\Receiver(new \Zotlabs\Zot6\Zot6Handler(),$outq['outq_notify']); + $zot = new Receiver(new Zot6Handler(), $outq['outq_notify']); $result = $zot->run(); logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']); @@ -246,7 +201,8 @@ class Queue { $host_crypto = null; if($channel && $base) { - $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_sitekey != '' order by hubloc_id desc limit 1", + $h = q("SELECT hubloc_sitekey, site_crypto FROM hubloc LEFT JOIN site ON hubloc_url = site_url + WHERE site_url = '%s' AND hubloc_network = 'zot6' ORDER BY hubloc_id DESC LIMIT 1", dbesc($base) ); if($h) { @@ -256,7 +212,7 @@ class Queue { $msg = $outq['outq_notify']; - $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + $result = Libzot::zot($outq['outq_posturl'], $msg, $channel, $host_crypto); if($result['success']) { logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']); @@ -265,7 +221,7 @@ class Queue { else { logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']); logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); - self::update($outq['outq_hash'],10); + self::update($outq['outq_hash'], 10); } } return; -- cgit v1.2.3 From 2765a0a9fd9d243108c44b9fcfda24bcae80e703 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 27 May 2021 10:50:53 +0000 Subject: missing includes --- Zotlabs/Lib/Activity.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 500e99ee8..a24c17815 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -11,6 +11,7 @@ use Zotlabs\Web\HTTPSig; require_once('include/event.php'); require_once('include/html2plain.php'); +require_once('include/items.php'); class Activity { -- cgit v1.2.3 From 30f258b3f9f51af3cfc66e3e7318ec506a2905d7 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 07:19:49 +0000 Subject: add check for type --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index a24c17815..41e394dbc 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -650,7 +650,7 @@ class Activity { $atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'], true)); if ($atts) { foreach ($atts as $att) { - if (strpos($att['type'], 'image')) { + if (isset($att['type']) && strpos($att['type'], 'image')) { $ret[] = ['type' => 'Image', 'url' => $att['href']]; } else { -- cgit v1.2.3 From 0718ac514d2421a96ab191f874a0cd8b120a5a78 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 08:11:40 +0000 Subject: remove deprecated mail code --- Zotlabs/Lib/Libsync.php | 3 -- Zotlabs/Lib/Libzot.php | 86 ------------------------------------------------- 2 files changed, 89 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index 5455aa2ea..67603a0e3 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -255,9 +255,6 @@ class Libsync { if (array_key_exists('chatroom', $arr) && $arr['chatroom']) sync_chatrooms($channel, $arr['chatroom']); - if (array_key_exists('conv', $arr) && $arr['conv']) - import_conv($channel, $arr['conv']); - if (array_key_exists('mail', $arr) && $arr['mail']) sync_mail($channel, $arr['mail']); diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index e44a82b71..b04c0ea3c 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1377,8 +1377,6 @@ class Libzot { $check_mentions = true; } } - elseif ($msg['type'] === 'mail') - $perm = 'post_mail'; $r = []; @@ -2210,90 +2208,6 @@ class Libzot { return $post_id; } - static function process_mail_delivery($sender, $arr, $deliveries) { - - $result = []; - - if ($sender != $arr['from_xchan']) { - logger('process_mail_delivery: sender is not mail author'); - return; - } - - foreach ($deliveries as $d) { - - $DR = new DReport(z_root(), $sender, $d, $arr['mid']); - - $r = q("select * from channel where channel_hash = '%s' limit 1", - dbesc($d['hash']) - ); - - if (!$r) { - $DR->update('recipient not found'); - $result[] = $DR->get(); - continue; - } - - $channel = $r[0]; - $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); - - - if (!perm_is_allowed($channel['channel_id'], $sender, 'post_mail')) { - - /* - * Always allow somebody to reply if you initiated the conversation. It's anti-social - * and a bit rude to send a private message to somebody and block their ability to respond. - * If you are being harrassed and want to put an end to it, delete the conversation. - */ - - $return = false; - if ($arr['parent_mid']) { - $return = q("select * from mail where mid = '%s' and channel_id = %d limit 1", - dbesc($arr['parent_mid']), - intval($channel['channel_id']) - ); - } - if (!$return) { - logger("permission denied for mail delivery {$channel['channel_id']}"); - $DR->update('permission denied'); - $result[] = $DR->get(); - continue; - } - } - - - $r = q("select id from mail where mid = '%s' and channel_id = %d limit 1", - dbesc($arr['mid']), - intval($channel['channel_id']) - ); - if ($r) { - if (intval($arr['mail_recalled'])) { - $x = q("delete from mail where id = %d and channel_id = %d", - intval($r[0]['id']), - intval($channel['channel_id']) - ); - $DR->update('mail recalled'); - $result[] = $DR->get(); - logger('mail_recalled'); - } - else { - $DR->update('duplicate mail received'); - $result[] = $DR->get(); - logger('duplicate mail received'); - } - continue; - } - else { - $arr['account_id'] = $channel['channel_account_id']; - $arr['channel_id'] = $channel['channel_id']; - $item_id = mail_store($arr); - $DR->update('mail delivered'); - $result[] = $DR->get(); - } - } - - return $result; - } - /** * @brief Processes delivery of profile. -- cgit v1.2.3 From f1aace5a22368a703e562169f855a0e387c5b93a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 08:28:32 +0000 Subject: remove unobscure() --- Zotlabs/Lib/MessageFilter.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php index 750d6d424..21e6ca26a 100644 --- a/Zotlabs/Lib/MessageFilter.php +++ b/Zotlabs/Lib/MessageFilter.php @@ -11,8 +11,6 @@ class MessageFilter { require_once('include/html2plain.php'); - unobscure($item); - $text = prepare_text($item['body'],$item['mimetype']); $text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text); -- cgit v1.2.3 From e1721b8496ec61aeb5f3967abfbb88b952357dfe Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 May 2021 20:14:15 +0000 Subject: remove masto hack - it does not make sense in threaded view --- Zotlabs/Lib/Activity.php | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 41e394dbc..3c1b140a0 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1743,14 +1743,9 @@ class Activity { static function create_note($channel, $observer_hash, $act) { $s = []; - - // Mastodon only allows visibility in public timelines if the public inbox is listed in the 'to' field. - // They are hidden in the public timeline if the public inbox is listed in the 'cc' field. - // This is not part of the activitypub protocol - we might change this to show all public posts in pubstream at some point. - $pubstream = ((is_array($act->obj) && array_key_exists('to', $act->obj) && in_array(ACTIVITY_PUBLIC_INBOX, $act->obj['to'])) ? true : false); $is_sys_channel = is_sys_channel($channel['channel_id']); - $parent = ((array_key_exists('inReplyTo', $act->obj)) ? urldecode($act->obj['inReplyTo']) : ''); + if ($parent) { $r = q("select * from item where uid = %d and ( mid = '%s' or mid = '%s' ) limit 1", @@ -1765,7 +1760,7 @@ class Activity { } if ($r[0]['owner_xchan'] === $channel['channel_hash']) { - if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) { + if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) { logger('no comment permission.'); return; } @@ -1777,7 +1772,7 @@ class Activity { } else { - if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) { + if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) { logger('no permission'); return; } @@ -2546,12 +2541,6 @@ class Activity { return; }*/ - // Mastodon only allows visibility in public timelines if the public inbox is listed in the 'to' field. - // They are hidden in the public timeline if the public inbox is listed in the 'cc' field. - // This is not part of the activitypub protocol - we might change this to show all public posts in pubstream at some point. - - $pubstream = ((is_array($act->obj) && array_key_exists('to', $act->obj) && in_array(ACTIVITY_PUBLIC_INBOX, $act->obj['to'])) ? true : false); - // TODO: this his handled in pubcrawl atm. // very unpleasant and imperfect way of determining a Mastodon DM /*if ($act->raw_recips && array_key_exists('to',$act->raw_recips) && is_array($act->raw_recips['to']) && count($act->raw_recips['to']) === 1 && $act->raw_recips['to'][0] === channel_url($channel) && ! $act->raw_recips['cc']) { @@ -2612,7 +2601,7 @@ class Activity { $allowed = true; // reject public stream comments that weren't sent by the conversation owner - if ($is_sys_channel && $pubstream && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) { + if ($is_sys_channel && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) { $allowed = false; } } @@ -2627,7 +2616,7 @@ class Activity { // The $item['item_fetched'] flag is set in fetch_and_store_parents(). // In this case we should check against author permissions because sender is not owner. - if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || ($is_sys_channel && $pubstream)) { + if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) { $allowed = true; } // TODO: not implemented @@ -2765,7 +2754,7 @@ class Activity { $fetch = false; // TODO: debug // if (perm_is_allowed($channel['channel_id'],$observer_hash,'send_stream') && (PConfig::Get($channel['channel_id'],'system','hyperdrive',true) || $act->type === 'Announce')) { - if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || ($is_sys_channel && $pubstream)) { + if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || $is_sys_channel) { $fetch = (($fetch_parents) ? self::fetch_and_store_parents($channel, $observer_hash, $item, $force) : false); } if ($fetch) { @@ -3074,15 +3063,9 @@ class Activity { static function announce_note($channel, $observer_hash, $act) { $s = []; - $is_sys_channel = is_sys_channel($channel['channel_id']); - // Mastodon only allows visibility in public timelines if the public inbox is listed in the 'to' field. - // They are hidden in the public timeline if the public inbox is listed in the 'cc' field. - // This is not part of the activitypub protocol - we might change this to show all public posts in pubstream at some point. - $pubstream = ((is_array($act->obj) && array_key_exists('to', $act->obj) && in_array(ACTIVITY_PUBLIC_INBOX, $act->obj['to'])) ? true : false); - - if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) { + if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) { logger('no permission'); return; } -- cgit v1.2.3 From 3fe2a2b181ec2f96b5950560fc50859d6b3ff78a Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 31 May 2021 07:12:36 +0000 Subject: do not overwrite the original rawmsg iconfig that came with the item --- Zotlabs/Lib/Libzot.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index b04c0ea3c..d5768cc84 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1270,10 +1270,6 @@ class Libzot { if ($AS->data['signed_data']) { IConfig::Set($arr, 'activitypub', 'signed_data', $AS->data['signed_data'], false); - $j = json_decode($AS->data['signed_data'], true); - if ($j) { - IConfig::Set($arr, 'activitypub', 'rawmsg', json_encode(JSalmon::unpack($j['data'])), true); - } } logger('Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); -- cgit v1.2.3 From b3df15a3c6e017ce3858ee484c6d2d70a5f18a17 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 2 Jun 2021 09:41:57 +0200 Subject: fix regression where authors from non zot6, activitypub networks got dismissed (e.g. relayed diaspora comments) --- Zotlabs/Lib/ActivityStreams.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index a5fb4a756..2324a8136 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -304,11 +304,12 @@ class ActivityStreams { // SECURITY: If we have already stored the actor profile, re-generate it // from cached data - don't refetch it from the network - $r = q("select * from xchan join hubloc on xchan_hash = hubloc_hash where hubloc_network in ('zot6', 'activitypub') and hubloc_id_url = '%s'", + $r = q("select * from xchan join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s'", dbesc($x) ); if ($r) { - $y = Activity::encode_person($r[0]); + $r = Libzot::zot_record_preferred($r); + $y = Activity::encode_person($r); $y['cached'] = true; return $y; } -- cgit v1.2.3 From 440f7bacd62cd277e8d9d4341675e8c5f5e7485a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 3 Jun 2021 10:59:12 +0200 Subject: directory improvements --- Zotlabs/Lib/Libzotdir.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index e095502dd..9042bcd16 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -207,8 +207,6 @@ class Libzotdir { ); } - - // If there are no directory servers, setup the fallback master /** @FIXME What to do if we're in a different realm? */ @@ -249,6 +247,7 @@ class Libzotdir { $syncdate = (($rr['site_sync'] <= NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']); $x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate) . (($token) ? '&t=' . $token : '')); + if (! $x['success']) continue; @@ -319,6 +318,14 @@ class Libzotdir { } if(array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { $xc = Libzot::import_xchan($zf['data'], 0, $ud); + // This is a workaround for a missing xchan_updated column + // TODO: implement xchan_updated in the xchan table and update this column instead + if($zf['data']['primary_location']['address'] && $zf['data']['primary_location']['url']) { + q("UPDATE hubloc SET hubloc_updated = '%s' WHERE hubloc_id_url = '%s' AND hubloc_primary = 1", + dbesc(datetime_convert()), + dbesc($zf['data']['primary_location']['url']) + ); + } } else { q("update updates set ud_last = '%s' where ud_addr = '%s'", -- cgit v1.2.3 From 67322c12643ced03bec0be70667f8b1c45de752f Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 5 Jun 2021 18:40:23 +0000 Subject: more work on directory sync --- Zotlabs/Lib/Libzotdir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 9042bcd16..507ddb674 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -252,7 +252,7 @@ class Libzotdir { continue; $j = json_decode($x['body'],true); - if (!($j['transactions']) || ($j['ratings'])) + if (!$j['transactions']) continue; q("update site set site_sync = '%s' where site_url = '%s'", -- cgit v1.2.3 From b55676d08914d58927b5503a1bfa283397cd6d44 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 17 Jun 2021 07:33:45 +0000 Subject: New landing page HQ with separate views for direct messages, public/limited messages and starred messages if the feature is enabled --- Zotlabs/Lib/Apps.php | 5 +++-- Zotlabs/Lib/Enotify.php | 20 ++++++++++---------- Zotlabs/Lib/ThreadStream.php | 8 ++++---- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index bd51f0896..30c108cc1 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -76,7 +76,8 @@ class Apps { 'Directory', 'Search', 'Help', - 'Profile Photo' + 'Profile Photo', + 'HQ' ]); /** @@ -374,7 +375,7 @@ class Apps { 'Permission Categories' => t('Permission Categories'), 'Public Stream' => t('Public Stream'), 'My Chatrooms' => t('My Chatrooms'), - 'Channel Export' => t('Channel Export') + 'Channel Export' => t('Channel Export'), ); if(array_key_exists('name',$arr)) { diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 7e33f09b8..50b564bde 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -124,14 +124,14 @@ class Enotify { if ($params['type'] == NOTIFY_MAIL) { logger('notification: mail'); - $subject = sprintf( t('[$Projectname:Notify] New mail received at %s'),$sitename); - - $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'), $sender['xchan_name'],$sitename); - $epreamble = sprintf( t('%1$s sent you %2$s.'),'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a private message') . '[/zrl]'); - $sitelink = t('Please visit %s to view and/or reply to your private messages.'); - $tsitelink = sprintf( $sitelink, $siteurl . '/mail/' . $params['item']['id'] ); - $hsitelink = sprintf( $sitelink, '' . $sitename . ''); - $itemlink = $siteurl . '/mail/' . $params['item']['id']; + $subject = sprintf( t('[$Projectname:Notify] New direct message received at %s'),$sitename); + + $preamble = sprintf( t('%1$s sent you a new direct message at %2$s.'), $sender['xchan_name'],$sitename); + $epreamble = sprintf( t('%1$s sent you %2$s.'),'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a direct message') . '[/zrl]'); + $sitelink = t('Please visit %s to view and/or reply to your direct messages.'); + $tsitelink = sprintf( $sitelink, $siteurl . '/hq/' . gen_link_id($params['item']['mid'])); + $hsitelink = sprintf( $sitelink, '' . $sitename . ''); + $itemlink = $siteurl . '/hq/' . gen_link_id($params['item']['mid']); } if ($params['type'] == NOTIFY_COMMENT) { @@ -886,7 +886,7 @@ class Enotify { $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); $x = [ - 'notify_link' => z_root() . '/notify/view/' . $tt['id'], + 'notify_link' => (($tt['ntype'] === NOTIFY_MAIL) ? $tt['link'] : z_root() . '/notify/view/' . $tt['id']), 'name' => $tt['xname'], 'url' => $tt['url'], 'photo' => $tt['photo'], @@ -945,7 +945,7 @@ class Enotify { 'photo' => $rr['xchan_photo_s'], 'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['created']), 'hclass' => (intval($rr['mail_seen']) ? 'notify-seen' : 'notify-unseen'), - 'message' => t('sent you a private message'), + 'message' => t('sent you a direct message'), ]; return $x; diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 68b2c70dd..7fe8fcc2e 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -77,7 +77,7 @@ class ThreadStream { $this->reload = $_SESSION['return_url']; break; case 'display': - // in this mode we set profile_owner after initialisation (from conversation()) and then + // in this mode we set profile_owner after initialisation (from conversation()) and then // pull some trickery which allows us to re-invoke this function afterward // it's an ugly hack so @FIXME $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); @@ -170,14 +170,14 @@ class ThreadStream { * Only add things that will be displayed */ - + if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) { return false; } $item->set_commentable(false); $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : ''); - + if(! comments_are_now_closed($item->get_data())) { if(($item->get_data_value('author_xchan') === $ob_hash) || ($item->get_data_value('owner_xchan') === $ob_hash)) $item->set_commentable(true); @@ -194,7 +194,7 @@ class ThreadStream { } if($this->mode === 'pubstream' && (! local_channel())) { $item->set_commentable(false); - } + } $item->set_conversation($this); -- cgit v1.2.3