From 41376ec2cda617549b717769f942019ebc2ba797 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 20 Nov 2022 20:31:59 +0000 Subject: fix issue in tag_deliver() and silence some more warnings --- include/items.php | 5 +++-- include/xchan.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4e4869aa8..0f477e761 100644 --- a/include/items.php +++ b/include/items.php @@ -2659,9 +2659,10 @@ function tag_deliver($uid, $item_id) { if ($is_group && intval($x[0]['item_wall'])) { // don't let the forked delivery chain recurse - if ($item['verb'] === 'Announce' && $item['author_xchan'] === $u['channel_hash']) { + if ($item['verb'] === 'Announce' && $item['author_xchan'] === $u[0]['channel_hash']) { return; } + // don't announce moderated content until it has been approved if (intval($item['item_blocked']) === ITEM_MODERATED) { return; @@ -2678,7 +2679,7 @@ function tag_deliver($uid, $item_id) { } elseif (intval($x[0]['item_uplink'])) { - start_delivery_chain($u,$item,$item_id,$x[0]); + start_delivery_chain($u[0], $item, $item_id, $x[0]); } } diff --git a/include/xchan.php b/include/xchan.php index a32064303..4a2d389c0 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -148,15 +148,15 @@ function xchan_store($arr) { function xchan_fetch($arr) { $key = ''; - if($arr['hash']) { + if(isset($arr['hash']) && $arr['hash']) { $key = 'xchan_hash'; $v = $arr['hash']; } - elseif($arr['guid']) { + elseif(isset($arr['guid']) && $arr['guid']) { $key = 'xchan_guid'; $v = $arr['guid']; } - elseif($arr['address']) { + elseif(isset($arr['address']) && $arr['address']) { $key = 'xchan_addr'; $v = $arr['address']; } -- cgit v1.2.3 From aeda31fda7ac6e788eb31b455970b349a1cc0fa7 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Nov 2022 09:52:50 +0000 Subject: fix warnings --- include/feedutils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index eea908fe8..43b95b966 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -2007,9 +2007,9 @@ function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $ if($enclosures) { foreach($enclosures as $enc) { $o .= '' . "\r\n"; } } -- cgit v1.2.3 From 680cf25f37348d2da978196554e07f1694475763 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 24 Nov 2022 16:08:57 +0100 Subject: de-duplicate by mid. there is no combined index for uid and uuid hence the query could be slow if an uid has a lot of items. the workaround for hubzilla < 4.0 is not required anymore --- include/items.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 0f477e761..b414928fd 100644 --- a/include/items.php +++ b/include/items.php @@ -1848,21 +1848,11 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if($parent_deleted) $arr['item_deleted'] = 1; - if($arr['uuid']) { - $r = q("SELECT id FROM item WHERE uuid = '%s' AND uid = %d and revision = %d LIMIT 1", - dbesc($arr['uuid']), - intval($arr['uid']), - intval($arr['revision']) - ); - } - else { - $r = q("SELECT id FROM item WHERE (mid = '%s' OR mid = '%s') AND uid = %d and revision = %d LIMIT 1", - dbesc($arr['mid']), - dbesc(basename(rawurldecode($arr['mid']))), // de-duplicate relayed comments from hubzilla < 4.0 - intval($arr['uid']), - intval($arr['revision']) - ); - } + $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d and revision = %d LIMIT 1", + dbesc($arr['mid']), + intval($arr['uid']), + intval($arr['revision']) + ); if($r) { logger('duplicate item ignored. ' . print_r($arr,true)); -- cgit v1.2.3 From ae1fad5de7aa8b42b9e7e0719502bf914228b1bf Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 25 Nov 2022 18:44:33 +0000 Subject: basically every incoming item should have a uuid by now --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index b414928fd..752251a7e 100644 --- a/include/items.php +++ b/include/items.php @@ -1848,8 +1848,8 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if($parent_deleted) $arr['item_deleted'] = 1; - $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d and revision = %d LIMIT 1", - dbesc($arr['mid']), + $r = q("SELECT id FROM item WHERE uuid = '%s' AND uid = %d and revision = %d LIMIT 1", + dbesc($arr['uuid']), intval($arr['uid']), intval($arr['revision']) ); -- cgit v1.2.3 From e87887c3287a22b0d4a261de9be21d13bc02f174 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 27 Nov 2022 09:40:23 +0000 Subject: re-install: make sure to fetch the latest hubloc in api_auth otherwise authentication might fail --- include/api_auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/api_auth.php b/include/api_auth.php index 0395dae7a..be886fbb2 100644 --- a/include/api_auth.php +++ b/include/api_auth.php @@ -102,13 +102,13 @@ function api_login(&$a) { if ($sigblock) { $keyId = str_replace('acct:', '', $sigblock['keyId']); if ($keyId) { - $r = q("select * from hubloc where hubloc_addr = '%s' or hubloc_id_url = '%s'", + $r = q("select * from hubloc where hubloc_addr = '%s' or hubloc_id_url = '%s' order by hubloc_id desc", dbesc($keyId), dbesc($keyId) ); if (!$r) { HTTPSig::get_zotfinger_key($keyId); - $r = q("select * from hubloc where hubloc_addr = '%s' or hubloc_id_url = '%s'", + $r = q("select * from hubloc where hubloc_addr = '%s' or hubloc_id_url = '%s' order by hubloc_id desc", dbesc($keyId), dbesc($keyId) ); -- cgit v1.2.3 From 004d0f074dfb72c7ab01e950620e97698dd51913 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 27 Nov 2022 12:20:04 +0000 Subject: disable context help until its content will be updated - it is not helpful otherwise --- include/nav.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 29d99aaee..2cdf7d42b 100644 --- a/include/nav.php +++ b/include/nav.php @@ -17,6 +17,7 @@ function nav($template = 'default') { App::$page['nav'] = App::$page['nav'] ?? ''; App::$page['htmlhead'] = App::$page['htmlhead'] ?? ''; App::$page['htmlhead'] .= ''; + $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); $observer = App::get_observer(); $chans = []; @@ -166,7 +167,8 @@ function nav($template = 'default') { $nav['register'] = ['register', t('Register'), "", t('Create an account'), 'register_nav_btn']; } - if (!get_config('system', 'hide_help')) { + // TODO: update help content for various modules + if (false /* !get_config('system', 'hide_help') */) { $help_url = z_root() . '/help?f=&cmd=' . App::$cmd; $context_help = ''; $enable_context_help = ((intval(get_config('system', 'enable_context_help')) === 1 || get_config('system', 'enable_context_help') === false) ? true : false); -- cgit v1.2.3 From d16b6c3838cd76eb7ce336444cbd37774857b64f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 2 Dec 2022 15:18:01 +0000 Subject: fix regression: new event not created --- include/event.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 7c81d6934..b27504296 100644 --- a/include/event.php +++ b/include/event.php @@ -502,7 +502,6 @@ function ev_compare($a, $b) { function event_store_event($arr) { - $arr['created'] = $arr['created'] ?? datetime_convert(); $arr['edited'] = $arr['edited'] ?? datetime_convert(); $arr['etype'] = $arr['etype'] ?? 'event'; @@ -533,7 +532,7 @@ function event_store_event($arr) { $existing_event = null; - if(isset($arr['event_hash'])) { + if(isset($arr['event_hash']) && $arr['event_hash']) { $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", dbesc($arr['event_hash']), intval($arr['uid']) @@ -543,7 +542,7 @@ function event_store_event($arr) { } } - if(isset($arr['id'])) { + if(isset($arr['id']) && $arr['id']) { $r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1", intval($arr['id']), intval($arr['uid']) @@ -647,7 +646,6 @@ function event_store_event($arr) { $hash = random_string(48); } } - $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,dtstart,dtend,summary,description,location,etype, adjust,nofinish, event_status, event_status_date, event_percent, event_repeat, event_sequence, event_priority, event_vdata, allow_cid,allow_gid,deny_cid,deny_gid) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' ) ", -- cgit v1.2.3 From 2bb58843ab303ba3e1a4a2c0c5a64138852ebbe0 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 2 Dec 2022 19:22:19 +0000 Subject: move queueworker to core and bump version --- include/hubloc.php | 8 ++++---- include/items.php | 27 +++++++++++++++------------ include/network.php | 17 +++++++++++------ 3 files changed, 30 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index bf5d8f120..016d82f23 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -155,8 +155,8 @@ function remove_obsolete_hublocs() { logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.'); - $interval = ((get_config('system', 'delivery_interval') !== false) - ? intval(get_config('system', 'delivery_interval')) : 2 ); + //$interval = ((get_config('system', 'delivery_interval') !== false) + //? intval(get_config('system', 'delivery_interval')) : 2 ); foreach($r as $rr) { q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", @@ -168,8 +168,8 @@ function remove_obsolete_hublocs() { ); if($x) { Master::Summon(array('Notifier', 'refresh_all', $x[0]['channel_id'])); - if($interval) - @time_sleep_until(microtime(true) + (float) $interval); + //if($interval) + //@time_sleep_until(microtime(true) + (float) $interval); } } } diff --git a/include/items.php b/include/items.php index 752251a7e..73fd584e1 100644 --- a/include/items.php +++ b/include/items.php @@ -4124,21 +4124,24 @@ function posted_dates($uid,$wall) { */ function fetch_post_tags($items, $link = false) { - $tag_finder = array(); - if($items) { - foreach($items as $item) { - if(is_array($item)) { - if(array_key_exists('item_id',$item)) { - if(! in_array($item['item_id'],$tag_finder)) - $tag_finder[] = $item['item_id']; - } - else { - if(! in_array($item['id'],$tag_finder)) - $tag_finder[] = $item['id']; - } + if (!is_array($items) || !$items) { + return $items; + } + + $tag_finder = []; + foreach($items as $item) { + if(is_array($item)) { + if(array_key_exists('item_id',$item)) { + if(! in_array($item['item_id'],$tag_finder)) + $tag_finder[] = $item['item_id']; + } + else { + if(! in_array($item['id'],$tag_finder)) + $tag_finder[] = $item['id']; } } } + $tag_finder_str = implode(', ', $tag_finder); if(strlen($tag_finder_str)) { diff --git a/include/network.php b/include/network.php index 36859bc2f..7deffe06c 100644 --- a/include/network.php +++ b/include/network.php @@ -1467,7 +1467,7 @@ function do_delivery($deliveries, $force = false) { if(! (is_array($deliveries) && count($deliveries))) return; - + /* $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000)) && (! $force)) { logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); @@ -1478,8 +1478,10 @@ function do_delivery($deliveries, $force = false) { } + $interval = ((get_config('system','delivery_interval') !== false) ? intval(get_config('system','delivery_interval')) : 2 ); + */ $deliveries_per_process = intval(get_config('system','delivery_batch_count')); @@ -1487,7 +1489,7 @@ function do_delivery($deliveries, $force = false) { $deliveries_per_process = 1; - $deliver = array(); + $deliver = []; foreach($deliveries as $d) { if(! $d) @@ -1496,17 +1498,20 @@ function do_delivery($deliveries, $force = false) { $deliver[] = $d; if(count($deliver) >= $deliveries_per_process) { - Zotlabs\Daemon\Master::Summon(array('Deliver',$deliver)); - $deliver = array(); + Zotlabs\Daemon\Master::Summon(['Deliver', $deliver]); + $deliver = []; + /* if($interval) @time_sleep_until(microtime(true) + (float) $interval); + */ } } // catch any stragglers - if($deliver) - Zotlabs\Daemon\Master::Summon(array('Deliver',$deliver)); + if($deliver) { + Zotlabs\Daemon\Master::Summon(['Deliver', $deliver]); + } } -- cgit v1.2.3 From 6952c5a3f5b2eb975b530aad48f3bbd57bcc1451 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 6 Dec 2022 11:15:53 +0000 Subject: $visitor is a string --- include/photos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/photos.php b/include/photos.php index de9cc6b13..6e00ffbf0 100644 --- a/include/photos.php +++ b/include/photos.php @@ -64,7 +64,7 @@ function photo_upload($channel, $observer, $args) { } $ac = $acl->get(); - +hz_syslog(print_r($ac,true)); $width = $height = 0; if ($args['getimagesize']) { @@ -405,7 +405,7 @@ function photo_upload($channel, $observer, $args) { } } - $attribution = (($visitor) ? $visitor['xchan_url'] : $channel['xchan_url']); + $attribution = (($visitor) ? $visitor : $channel['xchan_url']); //// Create item object $object = [ -- cgit v1.2.3 From abae5de4d8cf864b7a40445cb63191f09f17c248 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 7 Dec 2022 10:50:26 +0000 Subject: when uploading a image file, embed it in the item. otherwise attach it --- include/attach.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index fd418103d..fc146d008 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2105,8 +2105,22 @@ function attach_store_item($channel, $observer, $file) { $arr['verb'] = ACTIVITY_CREATE; $arr['obj_type'] = $type; $arr['title'] = $file['filename']; - $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . t('file') . '[/zrl]'); - $arr['body'] = $body_str; + + if ($type === 'Image') { + $arr['body'] = '[zrl=' . $path . '][zmg=' . $path . ']' . $file['display_path'] . '[/zmg][/zrl]'; + } + else { + $arr['attach'][] = [ + 'href' => z_root() . '/attach/' . $resource_id, + 'length' => $file['filesize'], + 'type' => $file['filetype'], + 'title' => urlencode($file['filename']), + 'revision' => $file['revision'] + ]; + } + + $body_str = sprintf((($type === 'Image') ? t('%s shared an %s with you') : t('%s shared a %s with you')), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . (($type === 'Image') ? t('image') : t('file')) . '[/zrl]'); + $arr['body'] .= $body_str; $meta = [ 'name' => $file['filename'], -- cgit v1.2.3 From 3ba27b9752a38da7d0108bfa181c10b50e5e9383 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 7 Dec 2022 11:01:28 +0000 Subject: add mark to html2bbcode parser --- include/html2bbcode.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 0aa067371..c928b91b1 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -171,6 +171,7 @@ function html2bbcode($message) node2bbcode($doc, 'i', array(), '[i]', '[/i]'); node2bbcode($doc, 'u', array(), '[u]', '[/u]'); node2bbcode($doc, 's', array(), '[s]', '[/s]'); + node2bbcode($doc, 'mark', array(), '[mark]', '[/mark]'); node2bbcode($doc, 'big', array(), "[size=large]", "[/size]"); node2bbcode($doc, 'small', array(), "[size=small]", "[/size]"); -- cgit v1.2.3 From 4f9a933108eb0a41671ec9464f1d7fb90c2d2233 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 8 Dec 2022 20:40:37 +0000 Subject: exclude not tagable xchan networks handle_tag() --- include/text.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index af6ad7ea2..cc480aacf 100644 --- a/include/text.php +++ b/include/text.php @@ -2969,7 +2969,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $newname = substr($name,1); $newname = substr($newname,0,-1); - $r = q("SELECT * FROM xchan WHERE ( xchan_addr = '%s' OR xchan_url = '%s' ) AND xchan_deleted = 0", + $r = q("SELECT * FROM xchan WHERE ( xchan_addr = '%s' OR xchan_url = '%s' ) AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", dbesc($newname), dbesc($newname) ); @@ -2995,7 +2995,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) // select someone from this user's contacts by name $r = q("SELECT * FROM abook LEFT JOIN xchan ON abook_xchan = xchan_hash - WHERE xchan_name = '%s' AND abook_channel = %d AND xchan_deleted = 0", + WHERE xchan_name = '%s' AND abook_channel = %d AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", dbesc($newname), intval($profile_uid) ); @@ -3004,7 +3004,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) if((! $r) && strpos($newname,'@')) { $r = q("SELECT * FROM xchan LEFT JOIN hubloc ON xchan_hash = hubloc_hash - WHERE hubloc_addr = '%s' AND xchan_deleted = 0 ", + WHERE hubloc_addr = '%s' AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", dbesc($newname) ); } @@ -3016,7 +3016,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $newname = str_replace('%','',$newname); $r = q("SELECT * FROM abook LEFT JOIN xchan ON abook_xchan = xchan_hash - WHERE xchan_addr LIKE ('%s') AND abook_channel = %d AND xchan_deleted = 0", + WHERE xchan_addr LIKE ('%s') AND abook_channel = %d AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", dbesc(((strpos($newname,'@')) ? $newname : $newname . '@%')), intval($profile_uid) ); -- cgit v1.2.3 From 1c17768dc5a4de21d8b431807fd184101c1d2c58 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 11 Dec 2022 10:40:02 +0000 Subject: minor fixes --- include/text.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index cc480aacf..1608f5435 100644 --- a/include/text.php +++ b/include/text.php @@ -303,6 +303,7 @@ function purify_html($s, $allow_position = false) { $def->addElement('footer', 'Block', 'Flow', 'Common'); //Inline $def->addElement('button', 'Inline', 'Inline', 'Common'); + $def->addElement('mark', 'Inline', 'Inline', 'Common'); if($allow_position) { -- cgit v1.2.3 From 45f8e43be425b9718aa9ac819256ea407af900f0 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 11 Dec 2022 20:46:02 +0000 Subject: debug from php log --- include/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 4f4d26a6c..8f0b137be 100644 --- a/include/auth.php +++ b/include/auth.php @@ -94,7 +94,7 @@ function account_verify_password($login, $pass) { $where = " where account_email = '" . dbesc($login) . "' "; } - $a = q("select * from account $where"); + $a = dbq("select * from account $where"); if(! $a) { return null; } -- cgit v1.2.3 From e3a19469eb6940249ad87662399d14dbf2a79847 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Dec 2022 09:03:49 +0000 Subject: bring back poll and delivery interval --- include/hubloc.php | 10 ++++++---- include/network.php | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index 016d82f23..edd452dd3 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -155,8 +155,8 @@ function remove_obsolete_hublocs() { logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.'); - //$interval = ((get_config('system', 'delivery_interval') !== false) - //? intval(get_config('system', 'delivery_interval')) : 2 ); + $interval = ((get_config('system', 'delivery_interval') !== false) + ? intval(get_config('system', 'delivery_interval')) : 2 ); foreach($r as $rr) { q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", @@ -168,8 +168,10 @@ function remove_obsolete_hublocs() { ); if($x) { Master::Summon(array('Notifier', 'refresh_all', $x[0]['channel_id'])); - //if($interval) - //@time_sleep_until(microtime(true) + (float) $interval); + + if($interval) { + @time_sleep_until(microtime(true) + (float) $interval); + } } } } diff --git a/include/network.php b/include/network.php index 7deffe06c..52c21d808 100644 --- a/include/network.php +++ b/include/network.php @@ -1476,12 +1476,12 @@ function do_delivery($deliveries, $force = false) { } return; } - + */ $interval = ((get_config('system','delivery_interval') !== false) ? intval(get_config('system','delivery_interval')) : 2 ); - */ + $deliveries_per_process = intval(get_config('system','delivery_batch_count')); @@ -1500,10 +1500,10 @@ function do_delivery($deliveries, $force = false) { if(count($deliver) >= $deliveries_per_process) { Zotlabs\Daemon\Master::Summon(['Deliver', $deliver]); $deliver = []; - /* - if($interval) + + if($interval) { @time_sleep_until(microtime(true) + (float) $interval); - */ + } } } -- cgit v1.2.3 From c9e170dfcc83a946fda7d4335c136ed40b3c579d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 12 Dec 2022 23:26:45 +0100 Subject: queueworker: introduce new interval config queueworker.queue_interval - defaults to 500000 microseconds. No config UI yet. --- include/hubloc.php | 5 ++--- include/network.php | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index edd452dd3..965725cba 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -155,8 +155,7 @@ function remove_obsolete_hublocs() { logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.'); - $interval = ((get_config('system', 'delivery_interval') !== false) - ? intval(get_config('system', 'delivery_interval')) : 2 ); + $interval = get_config('queueworker', 'queue_interval', 500000); foreach($r as $rr) { q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", @@ -170,7 +169,7 @@ function remove_obsolete_hublocs() { Master::Summon(array('Notifier', 'refresh_all', $x[0]['channel_id'])); if($interval) { - @time_sleep_until(microtime(true) + (float) $interval); + usleep($interval); } } } diff --git a/include/network.php b/include/network.php index 52c21d808..f0642d8f7 100644 --- a/include/network.php +++ b/include/network.php @@ -1479,9 +1479,7 @@ function do_delivery($deliveries, $force = false) { */ - $interval = ((get_config('system','delivery_interval') !== false) - ? intval(get_config('system','delivery_interval')) : 2 ); - + $interval = get_config('queueworker', 'queue_interval', 500000); $deliveries_per_process = intval(get_config('system','delivery_batch_count')); @@ -1502,7 +1500,7 @@ function do_delivery($deliveries, $force = false) { $deliver = []; if($interval) { - @time_sleep_until(microtime(true) + (float) $interval); + usleep($interval); } } } -- cgit v1.2.3 From 62eee07b6ee7ad7f34dbe7c5080630435acbb0bf Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 20 Dec 2022 14:06:14 +0100 Subject: make sure to include only zot6 hublocs in this query. including other networks could lead to unexpected results --- include/hubloc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index 965725cba..0236e4ae7 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -79,9 +79,10 @@ function prune_hub_reinstalls() { $r = q("select site_url from site where site_type = %d", intval(SITE_TYPE_ZOT) ); + if($r) { foreach($r as $rr) { - $x = q("select count(*) as t, hubloc_sitekey, max(hubloc_connected) as c from hubloc where hubloc_url = '%s' group by hubloc_sitekey order by c", + $x = q("select count(*) as t, hubloc_sitekey, max(hubloc_connected) as c from hubloc where hubloc_url = '%s' and hubloc_network = 'zot6' group by hubloc_sitekey order by c", dbesc($rr['site_url']) ); -- cgit v1.2.3 From c6e7a7eaee5b9bf97a8d02cac9cec05f5750b426 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 22 Dec 2022 12:42:44 +0100 Subject: comment out unused code --- include/items.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 73fd584e1..88efeb64e 100644 --- a/include/items.php +++ b/include/items.php @@ -4602,10 +4602,11 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $items = array(); } + /** @FIXME finish mark unseen sql if ($parents_str && (isset($arr['mark_seen']) && $arr['mark_seen'])) { $update_unseen = ' AND parent IN ( ' . dbesc($parents_str) . ' )'; - /** @FIXME finish mark unseen sql */ } + */ } return $items; -- cgit v1.2.3 From d2d6be73b8428c11c2461961a920ed3e3e656f64 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 26 Dec 2022 09:08:54 +0000 Subject: fix subquery in hq widget and order by hubloc_id desc in handle_tag() to make sure we get the most recent entry when using privacy tags --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 1608f5435..35ce465d6 100644 --- a/include/text.php +++ b/include/text.php @@ -2970,7 +2970,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $newname = substr($name,1); $newname = substr($newname,0,-1); - $r = q("SELECT * FROM xchan WHERE ( xchan_addr = '%s' OR xchan_url = '%s' ) AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", + $r = q("SELECT * FROM xchan LEFT JOIN hubloc ON hubloc_hash = xchan_hash WHERE ( xchan_addr = '%s' OR xchan_url = '%s' ) AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown') ORDER BY hubloc_id DESC", dbesc($newname), dbesc($newname) ); @@ -3005,7 +3005,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) if((! $r) && strpos($newname,'@')) { $r = q("SELECT * FROM xchan LEFT JOIN hubloc ON xchan_hash = hubloc_hash - WHERE hubloc_addr = '%s' AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown')", + WHERE hubloc_addr = '%s' AND xchan_deleted = 0 AND NOT xchan_network IN ('rss', 'anon', 'unknown') ORDER BY hubloc_id DESC", dbesc($newname) ); } -- cgit v1.2.3 From 0e71bfe2224b8fc54a58aff80894e1f22294bd6e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 2 Jan 2023 20:38:56 +0100 Subject: add sys channel to receiveres for public items --- include/items.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 88efeb64e..891f16b7f 100644 --- a/include/items.php +++ b/include/items.php @@ -97,7 +97,6 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { $private_envelope = false; require_once('include/channel.php'); - //$sys = get_sys_channel(); if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') { @@ -114,7 +113,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { $r = $hookinfo['recipients']; } else { $r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ", - intval($item['uid']) + intval($item['uid']) ); } @@ -141,18 +140,19 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { } } } -// we probably want to check that discovery channel delivery is allowed before uncommenting this. -// if($policy === 'pub') -// $recipients[] = $sys['xchan_hash']; } - // Forward to thread listeners, *unless* there is even a remote hint that the item - // might have some privacy attached. This could be (for instance) an ActivityPub DM + // Forward to thread listeners and pubstream (sys channel), *unless* there is even + // a remote hint that the item might have some privacy attached. + // This could be (for instance) an ActivityPub DM // in the middle of a public thread. Unless we can guarantee beyond all doubt that // this is public, don't allow it to go to thread listeners. if(! intval($item['item_private'])) { + $sys = get_sys_channel(); + $recipients[] = $sys['xchan_hash']; + $r = ThreadListener::fetch_by_target($item['parent_mid']); if($r) { foreach($r as $rv) { -- cgit v1.2.3 From de0d2afc154196ed80960435ac9c74ce37635576 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 2 Jan 2023 21:56:20 +0000 Subject: fix issues with pubstream tagcloud --- include/taxonomy.php | 92 +++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 45 deletions(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index 1eded055a..18cc39cd9 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -322,7 +322,7 @@ function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_H if($r) { $o = '

' . (($recent) ? t('Trending') : t('Tags')) . '

'; foreach($r as $rr) { - $o .= '#'.$rr[0].' ' . "\r\n"; + $o .= '#'.$rr[0].' ' . "\r\n"; } $o .= '
'; } @@ -335,53 +335,55 @@ function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) { $item_normal = item_normal(); $count = intval($limit); - $sql_extra = ""; - if($site) - $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; - else { - $sys = get_sys_channel(); - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; - $sql_extra = " and item_private = 0 "; - } - - if($recent) - $sql_extra .= " and item.created > NOW() - INTERVAL " . db_quoteinterval(intval($recent) . ' DAY') . " "; - - - if($safemode) { - $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); - if($unsafetags) { - $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; - } - } - - $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type); - - $content = Cache::get($key, '5 MINUTE'); - if(! $content) { - - $content = Cache::get($key, '1 MONTH'); - $arr = [ - "SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id - WHERE term.ttype = %d - AND otype = %d - AND item_type = %d - $sql_extra $uids $item_normal - GROUP BY term ORDER BY total DESC %s", - intval($type), - intval(TERM_OBJ_POST), - intval(ITEM_TYPE_POST), - (intval($count) ? "LIMIT $count" : '') - ]; - - \Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]); + $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $sql_extra = item_permissions_sql($sys['channel_id']); + + $site_firehose_sql = ''; + + if ($site) { + $site_firehose_sql = " and author_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) "; + } + + if($recent) { + $sql_extra .= " and item.created > NOW() - INTERVAL " . db_quoteinterval(intval($recent) . ' DAY') . " "; + } + + if($safemode) { + $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); + if($unsafetags) { + $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; } + } + + $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type); - $r = unserialize($content); - if(! $r) - return []; + $content = Cache::get($key, '5 MINUTE'); + if(! $content) { - return Zotlabs\Text\Tagadelic::calc($r); + $content = Cache::get($key, '1 MONTH'); + $arr = [ + "SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id + WHERE term.ttype = %d + AND otype = %d + AND item_type = %d + AND item_private = 0 + $uids $item_normal $site_firehose_sql $sql_extra + GROUP BY term ORDER BY total DESC %s", + intval($type), + intval(TERM_OBJ_POST), + intval(ITEM_TYPE_POST), + (intval($count) ? "LIMIT $count" : '') + ]; + + \Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]); + } + + $r = unserialize($content); + if(! $r) + return []; + + return Zotlabs\Text\Tagadelic::calc($r); } -- cgit v1.2.3 From 941135a0a63d72d6300ab93a608cd5c8354d9e0a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 4 Jan 2023 09:01:44 +0000 Subject: we should look for owner_xchan just like in mod pubstream --- include/taxonomy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index 18cc39cd9..671f96c2e 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -336,13 +336,13 @@ function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) { $item_normal = item_normal(); $count = intval($limit); $sys = get_sys_channel(); - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; $sql_extra = item_permissions_sql($sys['channel_id']); $site_firehose_sql = ''; if ($site) { - $site_firehose_sql = " and author_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) "; + $site_firehose_sql = " and owner_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) "; } if($recent) { -- cgit v1.2.3 From e16ea1ae0568238fa4c2236d1f050ef4a85749c7 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 4 Jan 2023 14:25:46 +0000 Subject: pdl editor for addon iitial commit --- include/plugin.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index ff5014c8b..ae73a847c 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -189,7 +189,7 @@ function plugin_is_installed($name) { function reload_plugins() { $plugins = get_config('system', 'addon'); if(strlen($plugins)) { - $r = q("SELECT * FROM addon WHERE installed = 1"); + $r = dbq("SELECT * FROM addon WHERE installed = 1"); if(count($r)) $installed = $r; else @@ -243,7 +243,7 @@ function reload_plugins() { function plugins_installed_list() { - $r = q("select * from addon where installed = 1 order by aname asc"); + $r = dbq("select * from addon where installed = 1 order by aname asc"); return(($r) ? ids_to_array($r,'aname') : []); } @@ -313,7 +313,7 @@ function plugins_sync() { */ function visible_plugin_list() { - $r = q("select * from addon where hidden = 0 order by aname asc"); + $r = dbq("select * from addon where hidden = 0 order by aname asc"); $x = (($r) ? ids_to_array($r,'aname') : array()); $y = []; if($x) { @@ -392,7 +392,7 @@ function load_hooks() { App::$hooks = []; - $r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC"); + $r = dbq("SELECT * FROM hook WHERE true ORDER BY priority DESC"); if($r) { foreach($r as $rv) { @@ -613,6 +613,17 @@ function get_widget_info($widget){ "addon/$widget.php" ]; + $addons = plugins_installed_list(); + + if ($addons) { + foreach ($addons as $name) { + $path = 'addon/' . $name . '/Widget/' . $ucwidget . '.php'; + if (is_file($path)) { + $checkpaths[] = $path ; + } + } + } + $widget_found = false; foreach ($checkpaths as $path) { -- cgit v1.2.3 From 2eb4d8762101df4e5dc6feddcfd479727853763b Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 4 Jan 2023 20:14:11 +0000 Subject: fix issue #1717 --- include/auth.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 8f0b137be..125aedffd 100644 --- a/include/auth.php +++ b/include/auth.php @@ -112,6 +112,7 @@ function account_verify_password($login, $pass) { } if($channel) { + // Try the authentication plugin again since weve determined we are using the channel login instead of account login $addon_auth = [ 'username' => $account['account_email'], -- cgit v1.2.3 From 23828f53bcd762f778b97c57a6d29ab59e83082d Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 5 Jan 2023 10:29:42 +0100 Subject: pubstream: when going to conv from unthreaded mode stay in the module --- include/conversation.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 46621a243..caad5bb0e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -675,7 +675,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa if($items) { - if(in_array($mode, [ 'network-new', 'search', 'community', 'moderate' ])) { + if(is_unthreaded($mode)) { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display @@ -772,14 +772,17 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) $is_new = true; - $conv_link_mid = (($mode == 'moderate') ? $item['parent_mid'] : $item['mid']); + $conv_link_mid = (($mode == 'moderate') ? gen_link_id($item['parent_mid']) : gen_link_id($item['mid'])); + + $conv_link = z_root() . '/display/' . $conv_link_mid; - $conv_link_module = 'display'; if(local_channel()) { - $conv_link_module = 'hq'; + $conv_link = z_root() . '/hq/' . $conv_link_mid; } - $conv_link = z_root() . '/' . $conv_link_module . '/' . gen_link_id($conv_link_mid); + if ($mode === 'pubstream-new') { + $conv_link = z_root() . '/pubstream?mid=' . $conv_link_mid; + } $contact = []; @@ -996,7 +999,7 @@ function thread_action_menu($item,$mode = '') { 'href' => '#' ]; - if(! in_array($mode, [ 'network-new', 'search', 'community'])) { + if(!is_unthreaded($mode)) { if($item['parent'] == $item['id'] && (get_observer_hash() != $item['author_xchan'])) { $menu[] = [ 'menu' => 'follow_thread', @@ -1784,3 +1787,13 @@ function get_response_button_text($v,$count) { break; } } + +function is_unthreaded($mode) { + return in_array($mode, [ + 'network-new', + 'pubstream-new', + 'search', + 'community', + 'moderate' + ]); +} -- cgit v1.2.3 From 16555b93bbe4ef69dbbce8085bb366134f8a5654 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 11 Jan 2023 16:34:23 +0000 Subject: fix race conditions when processing multiple choice polls --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 891f16b7f..900ffe2fa 100644 --- a/include/items.php +++ b/include/items.php @@ -1834,7 +1834,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['item_private'] = 0; if(in_array($arr['obj_type'], ['Note','Answer']) && $r[0]['obj_type'] === 'Question' && intval($r[0]['item_wall'])) { - Activity::update_poll($r[0],$arr); + Activity::update_poll($r[0]['id'], $arr); } } -- cgit v1.2.3