From 70b8c57d220aaaa361967343e2ca7dfa62632569 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 13 Jul 2023 09:47:50 +0000 Subject: basic per item rtl language support - issue ##1780 --- Zotlabs/Lib/ThreadItem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 14c9500ff..7fa621470 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -506,7 +506,8 @@ class ThreadItem { 'contact_id' => (($contact) ? $contact['abook_id'] : ''), 'moderate' => ($item['item_blocked'] == ITEM_MODERATED), 'moderate_approve' => t('Approve'), - 'moderate_delete' => t('Delete') + 'moderate_delete' => t('Delete'), + 'rtl' => in_array($item['lang'], rtl_languages()) ); -- cgit v1.2.3 From a06e8bfaee7de3bc8c2691e8d6462a52d5345e09 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 18 Jul 2023 20:18:42 +0200 Subject: Zotlabs: Improve type safety for AccessList class. Add type annotations for constructor and set* methods, and throw an exception if the passed in arrays are missing required keys. This means that both invalid input types and missing keys will throw and exception rather than just die with a runtime error. There's not checks to verify that the contents of the required array keys are valid or make sense, though. They are just assigned, and returned as is by the get method when requested. Also, the set_from_array method is not well tested at the moment. --- Zotlabs/Access/AccessList.php | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php index 790ef4745..a7da1274f 100644 --- a/Zotlabs/Access/AccessList.php +++ b/Zotlabs/Access/AccessList.php @@ -2,6 +2,7 @@ namespace Zotlabs\Access; + /** * @brief AccessList class which represents individual content ACLs. * @@ -40,6 +41,25 @@ class AccessList { */ private $explicit; + /** + * @brief Keys required by the constructor if the channel array is given. + */ + private const REQUIRED_KEYS_CONSTRUCTOR = [ + 'channel_allow_cid', + 'channel_allow_gid', + 'channel_deny_cid', + 'channel_deny_gid' + ]; + + /** + * @brief Keys required by the set method. + */ + private const REQUIRED_KEYS_SET = [ + 'allow_cid', + 'allow_gid', + 'deny_cid', + 'deny_gid' + ]; /** * @brief Constructor for AccessList class. @@ -53,8 +73,9 @@ class AccessList { * * \e string \b channel_deny_cid => string of denied cids * * \e string \b channel_deny_gid => string of denied gids */ - function __construct($channel) { + function __construct(array $channel) { if ($channel) { + $this->validate_input_array($channel, self::REQUIRED_KEYS_CONSTRUCTOR); $this->allow_cid = $channel['channel_allow_cid']; $this->allow_gid = $channel['channel_allow_gid']; $this->deny_cid = $channel['channel_deny_cid']; @@ -70,6 +91,17 @@ class AccessList { $this->explicit = false; } + private function validate_input_array(array $arr, array $required_keys) { + $missing_keys = array_diff($required_keys, array_keys($arr)); + + if (!empty($missing_keys)) { + throw new \Exception( + 'Invalid AccessList object: Expected array with keys: ' + . implode(', ', $missing_keys) + ); + } + } + /** * @brief Get if we are using the default constructor values * or values that have been set explicitly. @@ -94,7 +126,9 @@ class AccessList { * * \e string \b deny_gid => string of denied gids * @param boolean $explicit (optional) default true */ - function set($arr, $explicit = true) { + function set(array $arr, bool $explicit = true) { + $this->validate_input_array($arr, self::REQUIRED_KEYS_SET); + $this->allow_cid = $arr['allow_cid']; $this->allow_gid = $arr['allow_gid']; $this->deny_cid = $arr['deny_cid']; @@ -138,7 +172,7 @@ class AccessList { * * \e array|string \b group_deny => array with gids or comma-seperated string * @param boolean $explicit (optional) default true */ - function set_from_array($arr, $explicit = true) { + function set_from_array(array $arr, bool $explicit = true) { $arr['contact_allow'] = $arr['contact_allow'] ?? []; $arr['group_allow'] = $arr['group_allow'] ?? []; $arr['contact_deny'] = $arr['contact_deny'] ?? []; -- cgit v1.2.3 From 7200c716736d879501a665c9797ccf9e0131b24c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 19 Jul 2023 12:52:41 +0000 Subject: ignore internal follow activity --- Zotlabs/Module/Sse_bs.php | 24 +++++++++++++----------- Zotlabs/Widget/Messages.php | 6 ++++-- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 970c482a9..a3a3afd23 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -169,12 +169,12 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; + $sql_extra2 = " AND CASE WHEN verb = '" . dbesc(ACTIVITY_SHARE) . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; $item_normal = item_normal(); - // FEP-5624 filter approvals for comments - $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + // Filter FEP-5624 approvals for comments and internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -184,7 +184,6 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -258,8 +257,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // FEP-5624 filter approvals for comments - $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + // Filter FEP-5624 approvals for comments and internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -269,7 +268,6 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -343,8 +341,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // FEP-5624 filter approvals for comments - $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + // Filter FEP-5624 approvals for comments and internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -445,8 +443,8 @@ class Sse_bs extends Controller { $item_normal = item_normal(); - // FEP-5624 filter approvals for comments - $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + // Filter FEP-5624 approvals for comments and internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; if ($notifications) { $items = q("SELECT * FROM item @@ -641,6 +639,10 @@ class Sse_bs extends Controller { $item_normal = item_normal(); + // Filter FEP-5624 approvals for comments and internal follow activities + $item_normal .= " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject', '" . dbesc(ACTIVITY_FOLLOW) . "') "; + + $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 0a8900c4f..cdd889121 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -60,8 +60,10 @@ class Messages { } $channel = App::get_channel(); - $item_normal_i = str_replace('item.', 'i.', item_normal()); - $item_normal_c = str_replace('item.', 'c.', item_normal()); + $item_normal = item_normal(); + $item_normal .= " and item.verb != '" . ACTIVITY_FOLLOW . "'"; + $item_normal_i = str_replace('item.', 'i.', $item_normal); + $item_normal_c = str_replace('item.', 'c.', $item_normal); $entries = []; $limit = 30; $dummy_order_sql = ''; -- cgit v1.2.3 From 718c303086e6ab6061b2a920bd8293b2c0d11348 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 19 Jul 2023 20:19:00 +0200 Subject: Zotlabs: More type safety for AccessList class. Add more type declarations to class attributes and functions. This should ensure that only strings and null values can be assigned to the various access list members. This is still a bit loose, as we should probably aim for lists of channel or group id's instead of a generic type like a string. I'll leave that for later, though. --- Zotlabs/Access/AccessList.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php index a7da1274f..3f5271e87 100644 --- a/Zotlabs/Access/AccessList.php +++ b/Zotlabs/Access/AccessList.php @@ -18,28 +18,28 @@ class AccessList { * @brief Allow contacts * @var string */ - private $allow_cid; + private ?string $allow_cid; /** * @brief Allow groups * @var string */ - private $allow_gid; + private ?string $allow_gid; /** * @brief Deny contacts * @var string */ - private $deny_cid; + private ?string $deny_cid; /** * @brief Deny groups * @var string */ - private $deny_gid; + private ?string $deny_gid; /** * @brief Indicates if we are using the default constructor values or * values that have been set explicitly. * @var boolean */ - private $explicit; + private bool $explicit; /** * @brief Keys required by the constructor if the channel array is given. @@ -91,7 +91,7 @@ class AccessList { $this->explicit = false; } - private function validate_input_array(array $arr, array $required_keys) { + private function validate_input_array(array $arr, array $required_keys) : void { $missing_keys = array_diff($required_keys, array_keys($arr)); if (!empty($missing_keys)) { @@ -108,7 +108,7 @@ class AccessList { * * @return boolean */ - function get_explicit() { + function get_explicit() : bool { return $this->explicit; } @@ -126,7 +126,7 @@ class AccessList { * * \e string \b deny_gid => string of denied gids * @param boolean $explicit (optional) default true */ - function set(array $arr, bool $explicit = true) { + function set(array $arr, bool $explicit = true) : void { $this->validate_input_array($arr, self::REQUIRED_KEYS_SET); $this->allow_cid = $arr['allow_cid']; @@ -146,7 +146,7 @@ class AccessList { * * \e string \b deny_cid => string of denied cids * * \e string \b deny_gid => string of denied gids */ - function get() { + function get() : array { return [ 'allow_cid' => $this->allow_cid, 'allow_gid' => $this->allow_gid, @@ -172,7 +172,7 @@ class AccessList { * * \e array|string \b group_deny => array with gids or comma-seperated string * @param boolean $explicit (optional) default true */ - function set_from_array(array $arr, bool $explicit = true) { + function set_from_array(array $arr, bool $explicit = true) : void { $arr['contact_allow'] = $arr['contact_allow'] ?? []; $arr['group_allow'] = $arr['group_allow'] ?? []; $arr['contact_deny'] = $arr['contact_deny'] ?? []; @@ -195,7 +195,7 @@ class AccessList { * * @return boolean Return true if any of allow_* deny_* values is set. */ - function is_private() { + function is_private() : bool { return (($this->allow_cid || $this->allow_gid || $this->deny_cid || $this->deny_gid) ? true : false); } -- cgit v1.2.3 From 5181e575b4eb91de3ec71a125d45c29e65372c76 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 20 Jul 2023 11:46:40 +0000 Subject: fix accesslist in two cases --- Zotlabs/Lib/ThreadItem.php | 2 +- Zotlabs/Module/Chat.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 7fa621470..7d2bcde56 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -101,7 +101,7 @@ class ThreadItem { $conv = $this->get_conversation(); $observer = $conv->get_observer(); - $acl = new AccessList(false); + $acl = new AccessList([]); $acl->set($item); $lock = ((intval($item['item_private']) || ($item['uid'] == local_channel() && $acl->is_private())) diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index fc74016ab..2d36e022a 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -181,7 +181,7 @@ class Chat extends Controller { ); if($x) { - $acl = new AccessList(false); + $acl = new AccessList([]); $acl->set($x[0]); $private = $acl->is_private(); -- cgit v1.2.3 From 3bd2a919925965c42dfab14ac13dfc5747955f01 Mon Sep 17 00:00:00 2001 From: "DM42.Net Hubzilla Development" Date: Tue, 25 Jul 2023 09:07:32 -0400 Subject: Fix Typo --- Zotlabs/Module/Manifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Manifest.php b/Zotlabs/Module/Manifest.php index 4c418a56a..40bfde87d 100644 --- a/Zotlabs/Module/Manifest.php +++ b/Zotlabs/Module/Manifest.php @@ -23,7 +23,7 @@ class Manifest extends Controller { [ 'src' => '/images/app/hz-144.png', 'sizes' => '144x144', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-152.png', 'sizes' => '152x152', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any maskable' ], - [ 'src' => '/images/app/hz-348.png', 'sizes' => '384x384', 'type' => 'image/png' ], + [ 'src' => '/images/app/hz-384.png', 'sizes' => '384x384', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-512.png', 'sizes' => '512x512', 'type' => 'image/png' ], [ 'src' => '/images/app/hz.svg', 'sizes' => '64x64', 'type' => 'image/xml+svg' ] ], -- cgit v1.2.3 From e6a261a7897eb2ab07d592649306729e65d87ade Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 9 Aug 2023 08:01:18 +0000 Subject: now all acl fields are checked. if they are not complete the check will fail --- Zotlabs/Module/Wall_attach.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index 80892f0f3..0d5c9e983 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -81,13 +81,22 @@ class Wall_attach extends \Zotlabs\Web\Controller { } } - $observer = \App::get_observer(); - - $def_album = get_pconfig($channel['channel_id'],'system','photo_path'); $def_attach = get_pconfig($channel['channel_id'],'system','attach_path'); - $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''),'', array('source' => 'editor', 'visible' => 0, 'album' => $def_album, 'directory' => $def_attach, 'flags' => 1, 'allow_cid' => '<' . $channel['channel_hash'] . '>')); + $data = [ + 'source' => 'editor', + 'visible' => 0, + 'album' => $def_album, + 'directory' => $def_attach, + 'flags' => 1, + 'allow_cid' => '<' . $channel['channel_hash'] . '>', + 'allow_gid' => '', + 'deny_cid' => '', + 'deny_gid' => '' + ]; + + $r = attach_store($channel, get_observer_hash(), '', $data); if(! $r['success']) { notice( $r['message'] . EOL); -- cgit v1.2.3 From 0ec715d7c9d4bdce71210f9d025cf8ac0c02160d Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 9 Aug 2023 08:18:27 +0000 Subject: remove unused variable --- Zotlabs/Module/Sse_bs.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index a3a3afd23..fdaab4ab8 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -213,7 +213,6 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $approvals $sql_extra LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) @@ -295,7 +294,6 @@ class Sse_bs extends Controller { $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_private = 2 $item_normal - $approvals $sql_extra AND author_xchan != '%s' LIMIT 100", intval(self::$uid), @@ -352,7 +350,6 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -380,7 +377,6 @@ class Sse_bs extends Controller { $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1) $item_normal - $approvals $sql_extra AND author_xchan != '%s' LIMIT 100", intval(self::$uid), @@ -454,7 +450,6 @@ class Sse_bs extends Controller { AND author_xchan != '%s' AND created > '%s' $item_normal - $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -482,7 +477,6 @@ class Sse_bs extends Controller { WHERE true $uids AND created > '%s' $item_normal - $approvals $sql_extra AND author_xchan != '%s' LIMIT 100", dbescdate($_SESSION['static_loadtime']), -- cgit v1.2.3 From c4af4e3297f09aa0c6f8ed8e21d6f54729ebfc4d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Aug 2023 08:17:47 +0000 Subject: fix unable to create folders with name 0 --- Zotlabs/Module/File_upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 39a30cb1a..8956ce16f 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -35,7 +35,7 @@ class File_upload extends \Zotlabs\Web\Controller { $_REQUEST['deny_cid'] = ((isset($_REQUEST['contact_deny'])) ? perms2str($_REQUEST['contact_deny']) : ''); $_REQUEST['deny_gid'] = ((isset($_REQUEST['group_deny'])) ? perms2str($_REQUEST['group_deny']) : ''); - if(isset($_REQUEST['filename']) && $_REQUEST['filename']) { + if(isset($_REQUEST['filename']) && strlen($_REQUEST['filename'])) { $r = attach_mkdir($channel, get_observer_hash(), $_REQUEST); if($r['success']) { $hash = $r['data']['hash']; -- cgit v1.2.3 From a5a1bbf5d789f19fcb007802eee5e9a29abb72e7 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Aug 2023 09:21:45 +0000 Subject: move profile photo fetching to background --- Zotlabs/Daemon/Xchan_photo.php | 34 ++++++++++++++++++++++++++++++++++ Zotlabs/Lib/Activity.php | 10 +--------- 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 Zotlabs/Daemon/Xchan_photo.php (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Xchan_photo.php b/Zotlabs/Daemon/Xchan_photo.php new file mode 100644 index 000000000..f90d1d726 --- /dev/null +++ b/Zotlabs/Daemon/Xchan_photo.php @@ -0,0 +1,34 @@ + Date: Mon, 14 Aug 2023 18:13:58 +0000 Subject: only try to fetch the icon if we actually got one --- Zotlabs/Lib/Activity.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 2741cc79a..49628c24b 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1697,7 +1697,7 @@ class Activity { $webfinger_addr = escape_tags($person_obj['preferredUsername']) . '@' . $hostname; } - $icon = z_root() . '/' . get_default_profile_photo(300); + $icon = null; if (isset($person_obj['icon'])) { if (is_array($person_obj['icon'])) { if (array_key_exists('url', $person_obj['icon'])) { @@ -1807,6 +1807,9 @@ class Activity { 'xchan_addr' => $webfinger_addr, 'xchan_url' => $profile, 'xchan_name' => escape_tags($name), + 'xchan_photo_l' => z_root() . '/' . get_default_profile_photo(), + 'xchan_photo_m' => z_root() . '/' . get_default_profile_photo(80), + 'xchan_photo_s' => z_root() . '/' . get_default_profile_photo(48), 'xchan_name_date' => datetime_convert(), 'xchan_network' => 'activitypub', 'xchan_pubforum' => intval($group_actor) @@ -1846,8 +1849,9 @@ class Activity { } } - Master::Summon(['Xchan_photo', bin2hex($icon), bin2hex($url)]); - + if ($icon) { + Master::Summon(['Xchan_photo', bin2hex($icon), bin2hex($url)]); + } } static function create_action($channel, $observer_hash, $act) { -- cgit v1.2.3 From 816bbad28a6292be1c697fe3ac4073f3f110dc10 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 21 Aug 2023 10:07:51 +0200 Subject: allow public stream comments/reactions if item_fetched is set, when fetching parent of a reaction fetch the thr_parent --- Zotlabs/Lib/Activity.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 49628c24b..532bbba45 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2277,6 +2277,7 @@ class Activity { } static function decode_note($act) { + $response_activity = false; $s = []; @@ -3003,7 +3004,7 @@ class Activity { $allowed = true; // reject public stream comments that weren't sent by the conversation owner - if ($is_sys_channel && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) { + if ($is_sys_channel && $item['owner_xchan'] !== $observer_hash && !$fetch_parents && empty($item['item_fetched'])) { $allowed = false; } } @@ -3139,8 +3140,6 @@ 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) { $fetch = (($fetch_parents) ? self::fetch_and_store_parents($channel, $observer_hash, $item, $force) : false); } @@ -3285,7 +3284,7 @@ class Activity { $current_item = $item; while ($current_item['parent_mid'] !== $current_item['mid']) { - $n = self::fetch($current_item['parent_mid'], $channel); + $n = self::fetch(((in_array($current_item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? $current_item['thr_parent'] : $current_item['parent_mid']), $channel); if (!$n) { break; -- cgit v1.2.3 From 0a3094fc9a708c4e83d6dd91250ac2105e21b03f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 21 Aug 2023 10:45:12 +0200 Subject: test refactor the previous commit --- Zotlabs/Lib/Activity.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 532bbba45..1158acb08 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2359,6 +2359,9 @@ class Activity { $s['mid'] = $act->id; $s['uuid'] = ((!empty($act->data['diaspora:guid'])) ? $act->data['diaspora:guid'] : uuid_from_url($s['mid'])); + $s['parent_mid'] = $act->objprop('id') ?: $act->obj; + +/* if ($act->objprop('inReplyTo')) { $s['parent_mid'] = $act->objprop('inReplyTo'); } @@ -2369,7 +2372,7 @@ class Activity { logger('response activity without parent_mid or thr_parent'); return; } - +*/ // over-ride the object timestamp with the activity if (isset($act->data['published'])) { @@ -3157,7 +3160,7 @@ class Activity { return; } -/* + if ($parent[0]['parent_mid'] !== $item['parent_mid']) { $item['thr_parent'] = $item['parent_mid']; } @@ -3165,7 +3168,7 @@ class Activity { $item['thr_parent'] = $parent[0]['parent_mid']; } $item['parent_mid'] = $parent[0]['parent_mid']; -*/ + /* * @@ -3284,7 +3287,7 @@ class Activity { $current_item = $item; while ($current_item['parent_mid'] !== $current_item['mid']) { - $n = self::fetch(((in_array($current_item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? $current_item['thr_parent'] : $current_item['parent_mid']), $channel); + $n = self::fetch($current_item['parent_mid'], $channel); if (!$n) { break; -- cgit v1.2.3 From bad7b778b3ae91285d3170d8cac11f4814031a3c Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 27 Aug 2023 17:48:10 +0000 Subject: fix php warning --- Zotlabs/Module/Pubstream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 9d3a4f92b..4bd1faeff 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -40,7 +40,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); - $mid = (($_REQUEST['mid']) ? unpack_link_id($_REQUEST['mid']) : ''); + $mid = ((isset($_REQUEST['mid'])) ? unpack_link_id($_REQUEST['mid']) : ''); if ($mid === false) { notice(t('Malformed message id.') . EOL); -- cgit v1.2.3 From 053a247cc86f9f3a7ab0b393bfec43b3b231f73d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 28 Aug 2023 08:11:32 +0000 Subject: work around sabre caldav php warnings --- Zotlabs/Module/Cdav.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index b6d7ff5a3..892f02d10 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -1087,7 +1087,11 @@ class Cdav extends Controller { $filters['name'] = 'VCALENDAR'; $filters['prop-filters'][0]['name'] = 'VEVENT'; + $filters['prop-filters'][0]['is-not-defined'] = null; + $filters['prop-filters'][0]['param-filters'] = null; + $filters['prop-filters'][0]['text-match'] = null; $filters['comp-filters'][0]['name'] = 'VEVENT'; + $filters['comp-filters'][0]['is-not-defined'] = null; $filters['comp-filters'][0]['time-range']['start'] = $start; $filters['comp-filters'][0]['time-range']['end'] = $end; -- cgit v1.2.3 From e16aefec2c46760a1c78ce55dc82b801ef988689 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 30 Aug 2023 08:44:18 +0000 Subject: call init allthough it does not contain anything atm. it will set up things we need later e.g. App::$page["htmlhead"] and php will raise a warning if it does not exist. Also minor cleanup --- Zotlabs/Module/Display.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 1a1c09d7c..31f6bb7a4 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -2,15 +2,13 @@ namespace Zotlabs\Module; use App; +use Zotlabs\Web\Controller; -require_once("include/bbcode.php"); -require_once('include/security.php'); -require_once('include/conversation.php'); -require_once('include/acl_selectors.php'); -require_once('include/items.php'); +class Display extends Controller { + function init() { -class Display extends \Zotlabs\Web\Controller { + } function get($update = 0, $load = false) { -- cgit v1.2.3 From 1157dc7dc8544b190004bd014ee85c6e5e0441f3 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 Sep 2023 19:55:15 +0000 Subject: make sure to set the other relevant dates aswell to omit discrepancies if they would be set a splitsecond later when we store the item --- Zotlabs/Module/Like.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 5779faa19..54daf6471 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -554,7 +554,14 @@ class Like extends Controller { $arr['deny_cid'] = $deny_cid; $arr['deny_gid'] = $deny_gid; $arr['item_private'] = $private; - $arr['created'] = datetime_convert(); + + $created = datetime_convert(); + + $arr['created'] = $created; + $arr['edited'] = $created; + $arr['commented'] = $created; + $arr['received'] = $created; + $arr['changed'] = $created; call_hooks('post_local', $arr); -- cgit v1.2.3 From a88236b36fc9828e6dccbbc044aa37b2f7b46581 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Sep 2023 18:52:30 +0000 Subject: possible fix for item widget not respecting ACL if added by title - issue #1799 --- Zotlabs/Widget/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Item.php b/Zotlabs/Widget/Item.php index 9fd703dfe..6f943ffdf 100644 --- a/Zotlabs/Widget/Item.php +++ b/Zotlabs/Widget/Item.php @@ -34,7 +34,7 @@ class Item { if($arr['title']) { $r = q("select item.* from item left join iconfig on item.id = iconfig.iid where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' - and iconfig.k = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1", + and iconfig.k = 'WEBPAGE' and item_type = %d $sql_extra $revision limit 1", intval($channel_id), dbesc($arr['title']), intval(ITEM_TYPE_WEBPAGE) -- cgit v1.2.3 From 75e75b93cff5b2fb5d6243a908ee003b3faf010a Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Sep 2023 19:09:55 +0000 Subject: an attempt to cache seen item mids for the purpose that we can hide seen pubstream items from the notifications - might revert if it turns out that it does not scale --- Zotlabs/Lib/Cache.php | 14 +++++++------- Zotlabs/Module/Pubstream.php | 3 --- Zotlabs/Module/Sse_bs.php | 40 +++++++++++++++++++++++++++++++++------- Zotlabs/Widget/Notifications.php | 2 ++ 4 files changed, 42 insertions(+), 17 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index a5052a183..60bf64611 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -5,17 +5,17 @@ namespace Zotlabs\Lib; /** * cache api */ - + class Cache { - + /** * @brief Returns cached content - * + * * @param string $key * @param string $age in SQL format, default is '30 DAY' * @return string */ - + public static function get($key, $age = '') { $hash = hash('whirlpool',$key); @@ -25,12 +25,12 @@ class Cache { db_utcnow(), db_quoteinterval(($age ? $age : get_config('system','object_cache_days', '30') . ' DAY')) ); - + if ($r) return $r[0]['v']; return null; } - + public static function set($key,$value) { $hash = hash('whirlpool',$key); @@ -45,7 +45,7 @@ class Cache { dbesc($hash)); } else { - q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')", + q("INSERT INTO cache (k, v, updated) VALUES ('%s', '%s', '%s')", dbesc($hash), dbesc($value), dbesc(datetime_convert())); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 4bd1faeff..4b1cd6afb 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -99,9 +99,6 @@ class Pubstream extends \Zotlabs\Web\Controller { nav_set_selected(t('Public Stream')); - if(!$mid) - $_SESSION['static_loadtime'] = datetime_convert(); - $maxheight = get_config('system','home_divmore_height'); if(! $maxheight) $maxheight = 400; diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index fdaab4ab8..78adf1859 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -7,6 +7,7 @@ use Zotlabs\Lib\Apps; use Zotlabs\Web\Controller; use Zotlabs\Lib\Enotify; use Zotlabs\Lib\XConfig; +use Zotlabs\Lib\Cache; class Sse_bs extends Controller { @@ -117,14 +118,29 @@ class Sse_bs extends Controller { function mark_read($arr) { - if(! self::$uid) - return; - $mids = []; $str = ''; + $mids_all_json = Cache::get('sse_mids_all_' . session_id()); + + if (!$mids_all_json) + $mids_all_json = '[]'; + + $mids_all = json_decode($mids_all_json, true); + foreach($arr as $a) { - $mids[] = '\'' . dbesc(unpack_link_id($a)) . '\''; + $mid_str = '\'' . dbesc(unpack_link_id($a)) . '\''; + $mids[] = $mid_str; + + if (!in_array($mid_str, $mids_all)) { + $mids_all[] = $mid_str; + } + } + + Cache::set('sse_mids_all_' . session_id(), json_encode($mids_all)); + + if(! self::$uid) { + return; } $str = implode(',', $mids); @@ -411,8 +427,9 @@ class Sse_bs extends Controller { } } - if(! isset($_SESSION['static_loadtime'])) + if(!isset($_SESSION['static_loadtime'])) { $_SESSION['static_loadtime'] = datetime_convert(); + } $limit = intval(self::$limit); $offset = self::$offset; @@ -430,6 +447,13 @@ class Sse_bs extends Controller { if(self::$xchans) $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; + $sql_extra3 = ''; + $sse_mids_all_json = Cache::get('sse_mids_all_' . session_id()); + if ($sse_mids_all_json) { + $sse_mids_all = json_decode($sse_mids_all_json, true); + $sql_extra3 = " AND mid NOT IN (" . protect_sprintf(implode(',', $sse_mids_all)) . ") "; + } + $uids = " AND uid IN ( " . $sys['channel_id'] . " ) "; $site_firehose = get_config('system', 'site_firehose', 0); @@ -452,10 +476,11 @@ class Sse_bs extends Controller { $item_normal $sql_extra $sql_extra2 + $sql_extra3 ORDER BY created DESC LIMIT $limit OFFSET $offset", dbescdate($_SESSION['sse_loadtime']), dbesc(self::$ob_hash), - dbescdate($_SESSION['static_loadtime']) + dbescdate($_SESSION['last_login_date'] ?? $_SESSION['static_loadtime']) ); if($items) { @@ -478,8 +503,9 @@ class Sse_bs extends Controller { AND created > '%s' $item_normal $sql_extra + $sql_extra3 AND author_xchan != '%s' LIMIT 100", - dbescdate($_SESSION['static_loadtime']), + dbescdate($_SESSION['last_login_date'] ?? $_SESSION['static_loadtime']), dbesc(self::$ob_hash) ); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index a4e632a9f..b16303be6 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -157,9 +157,11 @@ class Notifications { 'url' => 'pubstream', 'label' => t('Public stream') ], + /* 'markall' => [ 'label' => t('Mark all notifications seen') ], + */ 'filter' => [ 'posts_label' => t('Show new posts only'), 'name_label' => t('Filter by name or address') -- cgit v1.2.3 From 8a21c8e618023cc0fb35a843697871649610b079 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Sep 2023 20:56:27 +0000 Subject: more theme fixes --- Zotlabs/Module/Settings/Display.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index ea9ae2da1..ee9692014 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -163,7 +163,8 @@ class Display { $title_tosource = get_pconfig(local_channel(),'system','title_tosource'); $title_tosource = (($title_tosource===false)? '0': $title_tosource); // default if not set: 0 - $theme_config = ""; + $theme_config = null; + $schemas = null; if(($themeconfigfile = $this->get_theme_config_file($theme)) != null){ require_once($themeconfigfile); if(class_exists('\\Zotlabs\\Theme\\' . ucfirst($theme) . 'Config')) { @@ -188,7 +189,7 @@ class Display { '$uid' => local_channel(), '$theme' => (($themes) ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false), - '$schema' => array('schema', t('Select scheme'), $existing_schema, '' , $schemas), + '$schema' => (($schemas) ? array('schema', t('Select scheme'), $existing_schema, '' , $schemas) : false), '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), -- cgit v1.2.3 From 0cb5d0d63e3150331999c51c5807603d74b7d4dc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 14 Sep 2023 12:30:14 +0000 Subject: also look for widgets in view/theme/themename/widget --- Zotlabs/Module/Pdledit_gui.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pdledit_gui.php b/Zotlabs/Module/Pdledit_gui.php index 45a06c00a..ebb2d558a 100644 --- a/Zotlabs/Module/Pdledit_gui.php +++ b/Zotlabs/Module/Pdledit_gui.php @@ -268,7 +268,8 @@ class Pdledit_gui extends Controller { $checkpaths = [ - 'Zotlabs/Widget/*.php' + 'Zotlabs/Widget/*.php', + 'view/theme/' . lcfirst(App::$theme_info['name']) . '/widget/*.php' ]; $addons = plugins_installed_list(); -- cgit v1.2.3 From b628af2258225f029abada5bd71e064947d2c611 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Sep 2023 06:55:27 +0000 Subject: allow themes to manipulate app icons (photos) via a hook --- Zotlabs/Lib/Apps.php | 21 +++++++++++++++++++-- Zotlabs/Module/Admin/Themes.php | 23 +++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 497a9d299..00e65479e 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -419,11 +419,28 @@ class Apps { static public function app_render($papp, $mode = 'view') { $installed = false; - if(! $papp) + if(!$papp) { return; + } + + /** + * @hooks app_render_before + * Hook to manipulate the papp array before rendering + */ - if(! $papp['photo']) + $hookinfo = [ + 'name' => $papp['name'], + 'photo' => $papp['photo'] + ]; + + call_hooks('app_render_manipulate_photo', $hookinfo); + + // We will only allow to manipulate the photo + $papp['photo'] = $hookinfo['photo']; + + if(!$papp['photo']) { $papp['photo'] = 'icon:gear'; + } self::translate_system_apps($papp); diff --git a/Zotlabs/Module/Admin/Themes.php b/Zotlabs/Module/Admin/Themes.php index 8e72a1318..7f615afa8 100644 --- a/Zotlabs/Module/Admin/Themes.php +++ b/Zotlabs/Module/Admin/Themes.php @@ -80,10 +80,25 @@ class Themes { $this->toggle_theme($themes, $theme, $result); $s = $this->rebuild_theme_table($themes); - if($result) - info( sprintf('Theme %s enabled.', $theme)); - else - info( sprintf('Theme %s disabled.', $theme)); + + if($result) { + if (is_file("view/theme/$theme/php/config.php")){ + require_once("view/theme/$theme/php/config.php"); + if (function_exists($theme . '_theme_admin_enable')){ + call_user_func($theme . '_theme_admin_enable'); + } + } + info(sprintf('Theme %s enabled.', $theme)); + } + else { + if (is_file("view/theme/$theme/php/config.php")){ + require_once("view/theme/$theme/php/config.php"); + if (function_exists($theme . '_theme_admin_disable')){ + call_user_func($theme . '_theme_admin_disable'); + } + } + info(sprintf('Theme %s disabled.', $theme)); + } set_config('system', 'allowed_themes', $s); goaway(z_root() . '/admin/themes' ); -- cgit v1.2.3 From a06b28b6934cda8a8cacd3ebf7c76b881a69b74e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Sep 2023 13:45:24 +0000 Subject: more type checking --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1158acb08..cc0ac547c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2596,11 +2596,11 @@ class Activity { if (!$response_activity) { if ($act->type === 'Announce') { $s['author_xchan'] = self::get_attributed_to_actor_url($act); - $s['mid'] = $act->obj['id']; + $s['mid'] = $act->objprop('id') ?: $act->obj; // Do not force new thread if the announce is from a group actor if ($act->actor['type'] !== 'Group') { - $s['parent_mid'] = $act->obj['id']; + $s['parent_mid'] = $act->objprop('id') ?: $act->obj; } } -- cgit v1.2.3 From bb38a90ddaa6f57397d62fd0414b4b9d6968f719 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Sep 2023 13:35:55 +0000 Subject: use small profile images instead of medium --- Zotlabs/Lib/ThreadItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 7d2bcde56..037ddb19e 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -185,7 +185,7 @@ class ThreadItem { $filer = ((($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) ? t("Save to Folder") : false); - $profile_avatar = $item['author']['xchan_photo_m']; + $profile_avatar = $item['author']['xchan_photo_s']; $profile_link = chanlink_hash($item['author_xchan']); $profile_name = $item['author']['xchan_name']; @@ -874,7 +874,7 @@ class ThreadItem { if($this->is_toplevel() && ($this->get_data_value('author_xchan') != $this->get_data_value('owner_xchan'))) { $this->owner_url = chanlink_hash($this->data['owner']['xchan_hash']); - $this->owner_photo = $this->data['owner']['xchan_photo_m']; + $this->owner_photo = $this->data['owner']['xchan_photo_s']; $this->owner_name = $this->data['owner']['xchan_name']; $this->wall_to_wall = true; } -- cgit v1.2.3 From d88c67eba37569a95691bc967046eed318e39b46 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 20 Sep 2023 10:45:33 +0000 Subject: deprecate the ancient $a variable --- Zotlabs/Web/Router.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index a6a841ccb..2876fcc3c 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -224,7 +224,7 @@ class Router { } elseif(function_exists(App::$module . '_init')) { $func = App::$module . '_init'; - $func($a); + $func(); } } @@ -257,13 +257,13 @@ class Router { if(function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) { $func = str_replace('-', '_', $current_theme[0]) . '_init'; - $func($a); + $func(); } elseif (x(App::$theme_info, 'extends') && file_exists('view/theme/' . App::$theme_info['extends'] . '/php/theme.php')) { require_once('view/theme/' . App::$theme_info['extends'] . '/php/theme.php'); if(function_exists(str_replace('-', '_', App::$theme_info['extends']) . '_init')) { $func = str_replace('-', '_', App::$theme_info['extends']) . '_init'; - $func($a); + $func(); } } @@ -275,7 +275,7 @@ class Router { } elseif(function_exists(App::$module . '_post')) { $func = App::$module . '_post'; - $func($a); + $func(); } } @@ -289,7 +289,7 @@ class Router { } elseif(function_exists(App::$module . '_content')) { $func = App::$module . '_content'; - $arr = array('content' => $func($a)); + $arr = array('content' => $func()); } } call_hooks(App::$module . '_mod_aftercontent', $arr); -- cgit v1.2.3 From 9627c3e7c850b3532c3840910c0862f093cd8fb1 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 06:14:24 +0000 Subject: store the actor cache date so we can easily invalidate it after a period of time --- Zotlabs/Lib/Activity.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index cc0ac547c..9b94c4d8d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -142,6 +142,7 @@ class Activity { logger('returned: ' . json_encode($y, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DEBUG); if (isset($y['type']) && ActivityStreams::is_an_actor($y['type'])) { + $y['actor_cache_date'] = datetime_convert(); XConfig::Set($y['id'], 'system', 'actor_record', $y); } @@ -1668,11 +1669,6 @@ class Activity { return; } - // store the actor record in XConfig - - // we already store this in Activity::fetch() - // XConfig::Set($url, 'system', 'actor_record', $person_obj); - $name = $person_obj['name'] ?? ''; if (!$name) { $name = $person_obj['preferredUsername'] ?? ''; @@ -4033,7 +4029,8 @@ class Activity { $cache_url = ((strpos($id, '#')) ? substr($id, 0, strpos($id, '#')) : $id); $actor = XConfig::Get($cache_url, 'system', 'actor_record'); - if ($actor) { + if ($actor && isset($actor['actor_cache_date']) && $actor['actor_cache_date'] > datetime_convert('UTC', 'UTC', ' now - 3 days')) { + unset($actor['actor_cache_date']); return $actor; } -- cgit v1.2.3 From a5e32dc3de997c3a3d9046161ce1ec149abb65c1 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 08:34:02 +0000 Subject: more deprecate $a --- Zotlabs/Module/Admin/Accounts.php | 2 +- Zotlabs/Module/Admin/Channels.php | 2 +- Zotlabs/Module/Blocks.php | 2 +- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Connections.php | 1 - Zotlabs/Module/Display.php | 2 +- Zotlabs/Module/Editblock.php | 2 +- Zotlabs/Module/Editlayout.php | 2 +- Zotlabs/Module/Editpost.php | 2 +- Zotlabs/Module/Editwebpage.php | 10 +++++----- Zotlabs/Module/Hq.php | 2 +- Zotlabs/Module/Layouts.php | 2 +- Zotlabs/Module/Network.php | 2 +- Zotlabs/Module/Photos.php | 9 +++++---- Zotlabs/Module/Pubstream.php | 2 +- Zotlabs/Module/Rpost.php | 2 +- Zotlabs/Module/Webpages.php | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php index 1c1911b3a..b067b4bf6 100644 --- a/Zotlabs/Module/Admin/Accounts.php +++ b/Zotlabs/Module/Admin/Accounts.php @@ -346,7 +346,7 @@ class Accounts { '$users' => $users, '$msg' => t('Message') )); - $o .= paginate($a); + $o .= paginate(); return $o; } diff --git a/Zotlabs/Module/Admin/Channels.php b/Zotlabs/Module/Admin/Channels.php index 09769a166..c6b7ad17a 100644 --- a/Zotlabs/Module/Admin/Channels.php +++ b/Zotlabs/Module/Admin/Channels.php @@ -168,7 +168,7 @@ class Channels { '$baseurl' => z_root(), '$channels' => $channels, )); - $o .= paginate($a); + $o .= paginate(); return $o; } diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php index e0de23fdb..84f769612 100644 --- a/Zotlabs/Module/Blocks.php +++ b/Zotlabs/Module/Blocks.php @@ -107,7 +107,7 @@ class Blocks extends \Zotlabs\Web\Controller { $x['pagetitle'] = $_REQUEST['pagetitle'] ?? ''; $a = ''; - $editor = status_editor($a,$x,false,'Blocks'); + $editor = status_editor($x, false, 'Blocks'); $r = q("select iconfig.iid, iconfig.k, iconfig.v, mid, title, body, mimetype, created, edited from iconfig diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 036663681..e8c3316e9 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -268,7 +268,7 @@ class Channel extends Controller { ]; $a = ''; - $o .= status_editor($a, $x, false, 'Channel'); + $o .= status_editor($x, false, 'Channel'); } // Add pinned content diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index e0f463c76..8a06ab8e0 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -409,7 +409,6 @@ class Connections extends \Zotlabs\Web\Controller { '$approve' => t('Approve'), '$cmd' => App::$cmd, '$contacts' => $contacts, - '$paginate' => paginate($a), '$abook_usage_message' => $abook_usage_message, '$group_label' => t('This is a group/forum channel') ]); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 31f6bb7a4..9e46d7620 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -89,7 +89,7 @@ class Display extends Controller { $o .= '
'; $a = ''; - $o .= status_editor($a,$x,false,'Display'); + $o .= status_editor($x, false, 'Display'); $o .= '
'; } diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index c031f32a1..1cbb1aee2 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -132,7 +132,7 @@ class Editblock extends \Zotlabs\Web\Controller { 'bbcode' => (($mimetype == 'text/bbcode') ? true : false) ); - $editor = status_editor($a, $x, false, 'Editblock'); + $editor = status_editor($x, false, 'Editblock'); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Block'), diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index 50096f1a1..1a3f5614c 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -131,7 +131,7 @@ class Editlayout extends \Zotlabs\Web\Controller { 'profile_uid' => intval($owner), ); - $editor = status_editor($a, $x, false, 'Editlayout'); + $editor = status_editor($x, false, 'Editlayout'); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Layout'), diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index b21c58af2..5e405bdbc 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -107,7 +107,7 @@ class Editpost extends \Zotlabs\Web\Controller { ); $a = ''; - $editor = status_editor($a, $x, false, 'Editpost'); + $editor = status_editor($x, false, 'Editpost'); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit post'), diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 785eeb4ec..ab4858d63 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -75,7 +75,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { // Figure out which post we're editing $post_id = ((argc() > 2) ? intval(argv(2)) : 0); - + if(! $post_id) { notice( t('Item not found') . EOL); return; @@ -90,7 +90,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { return; } - // We've already figured out which item we want and whose copy we need, + // We've already figured out which item we want and whose copy we need, // so we don't need anything fancy here $sql_extra = item_permissions_sql($owner); @@ -122,13 +122,13 @@ class Editwebpage extends \Zotlabs\Web\Controller { return; } } - + $layout = $itm[0]['layout_mid']; $content = $itm[0]['body']; if($itm[0]['mimetype'] === 'text/markdown') $content = \Zotlabs\Lib\MarkdownSoap::unescape($itm[0]['body']); - + $rp = 'webpages/' . $which; $x = array( @@ -160,7 +160,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { 'bbcode' => (($mimetype == 'text/bbcode') ? true : false) ); - $editor = status_editor($a, $x, false, 'Editwebpage'); + $editor = status_editor($x, false, 'Editwebpage'); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Webpage'), diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 05b48f119..4fb1891d5 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -104,7 +104,7 @@ class Hq extends \Zotlabs\Web\Controller { ]; $a = ''; - $o .= status_editor($a, $x, true); + $o .= status_editor($x, true, 'Hq'); } diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php index 949f8e8ec..143e4110b 100644 --- a/Zotlabs/Module/Layouts.php +++ b/Zotlabs/Module/Layouts.php @@ -139,7 +139,7 @@ class Layouts extends \Zotlabs\Web\Controller { $x['pagetitle'] = $_REQUEST['pagetitle'] ?? ''; $a = ''; - $editor = status_editor($a,$x,false,'Layouts'); + $editor = status_editor($x, false, 'Layouts'); $r = q("select iconfig.iid, iconfig.v, mid, title, body, mimetype, created, edited, item_type from iconfig left join item on iconfig.iid = item.id diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index dcc209d1d..4f8e2f4e4 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -214,7 +214,7 @@ class Network extends \Zotlabs\Web\Controller { ); $a = ''; - $status_editor = status_editor($a, $x, false, 'Network'); + $status_editor = status_editor($x, false, 'Network'); $o .= $status_editor; } diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 68f7c55e7..6c73c411e 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -851,6 +851,10 @@ class Photos extends \Zotlabs\Web\Controller { dbesc($datum) ); + $tags = []; + $likebuttons = []; + $comments = ''; + if(! ($ph && $x)) { /* Check again - this time without specifying permissions */ @@ -981,7 +985,6 @@ class Photos extends \Zotlabs\Web\Controller { $r = conv_sort($r,'commented'); } - $tags = array(); if(x($link_item, 'term')) { $cnt = 0; foreach($link_item['term'] as $t) { @@ -1075,7 +1078,6 @@ class Photos extends \Zotlabs\Web\Controller { ]; } - $comments = ''; if(! $r) { if($observer && ($can_post || $can_comment)) { $commentbox = replace_macros($cmnt_tpl,array( @@ -1209,13 +1211,12 @@ class Photos extends \Zotlabs\Web\Controller { } } - $paginate = paginate($a); } $album_e = array($album_link,$ph[0]['album']); $like_e = $like; $dislike_e = $dislike; - + $paginate = paginate(); $response_verbs = array('like'); if(feature_enabled($owner_uid,'dislike')) diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 4b1cd6afb..08de168cb 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -91,7 +91,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $o .= '
'; $a = ''; - $o .= status_editor($a,$x,false,'Pubstream'); + $o .= status_editor($x, false, 'Pubstream'); $o .= '
'; } diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index f0194fdfd..a5750edcb 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -205,7 +205,7 @@ class Rpost extends \Zotlabs\Web\Controller { ); $a = ''; - $editor = status_editor($a,$x,false,'Rpost'); + $editor = status_editor($x, false, 'Rpost'); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit post'), diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index b58c23b34..ffb0d94ea 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -204,7 +204,7 @@ class Webpages extends Controller { $x['pagetitle'] = 'home'; $a = ''; - $editor = status_editor($a,$x,false,'Webpages'); + $editor = status_editor($x, false, 'Webpages'); $pages = null; -- cgit v1.2.3 From 1ced89a869483e693540129df64efd4411a50058 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 09:14:15 +0000 Subject: fix javascript error --- Zotlabs/Module/Hq.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 4fb1891d5..5c3ae9273 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -85,6 +85,7 @@ class Hq extends \Zotlabs\Web\Controller { $x = [ 'is_owner' => true, + 'profile_uid' => $channel['channel_id'], 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], -- cgit v1.2.3 From c925e13e5ae26a93dae292c27dfcdea5be25d21b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 14:47:56 +0000 Subject: cleanup and warnings --- Zotlabs/Module/Rpost.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index a5750edcb..5c417daf2 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -1,7 +1,9 @@ $arg) { if($key === 'q') continue; @@ -80,7 +82,10 @@ class Rpost extends \Zotlabs\Web\Controller { 'album' => $def_album, 'directory' => $def_attach, 'flags' => 1, // indicates temporary permissions are created - 'allow_cid' => '<' . $channel['channel_hash'] . '>' + 'allow_cid' => '<' . $channel['channel_hash'] . '>', + 'allow_gid' => '', + 'deny_cid' => '', + 'deny_gid' => '' ]); if (! $r['success']) { @@ -167,9 +172,9 @@ class Rpost extends \Zotlabs\Web\Controller { $_REQUEST['body'] = html2bbcode($_REQUEST['body']); } - $channel = \App::get_channel(); + $channel = App::get_channel(); - $acl = new \Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $channel_acl = $acl->get(); if(isset($_REQUEST['url']) && $_REQUEST['url']) { -- cgit v1.2.3 From 01b747287a47436d63253dd443120322363e82a9 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Sep 2023 09:24:04 +0000 Subject: fix php warnings --- Zotlabs/Lib/Activity.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 9b94c4d8d..190777b5f 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2391,25 +2391,25 @@ class Activity { $mention = self::get_actor_bbmention($obj_actor['id']); if ($act->type === 'Like') { - $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? ''; + $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . EOL . EOL . ($content['content'] ?? ''); } if ($act->type === 'Dislike') { - $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? ''; + $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . EOL . EOL . ($content['content'] ?? ''); } // handle event RSVPs if (($act->objprop('type') === 'Event') || ($act->objprop('type') === 'Invite' && array_path_exists('object/type', $act->obj) && $act->obj['object']['type'] === 'Event')) { if ($act->type === 'Accept') { - $content['content'] = sprintf(t('Will attend %s\'s event'), $mention) . EOL . EOL . $content['content']; + $content['content'] = sprintf(t('Will attend %s\'s event'), $mention) . EOL . EOL . ($content['content'] ?? ''); } if ($act->type === 'Reject') { - $content['content'] = sprintf(t('Will not attend %s\'s event'), $mention) . EOL . EOL . $content['content']; + $content['content'] = sprintf(t('Will not attend %s\'s event'), $mention) . EOL . EOL . ($content['content'] ?? ''); } if ($act->type === 'TentativeAccept') { - $content['content'] = sprintf(t('May attend %s\'s event'), $mention) . EOL . EOL . $content['content']; + $content['content'] = sprintf(t('May attend %s\'s event'), $mention) . EOL . EOL . ($content['content'] ?? ''); } if ($act->type === 'TentativeReject') { - $content['content'] = sprintf(t('May not attend %s\'s event'), $mention) . EOL . EOL . $content['content']; + $content['content'] = sprintf(t('May not attend %s\'s event'), $mention) . EOL . EOL . ($content['content'] ?? ''); } } -- cgit v1.2.3 From 08d85798ed431e20ce391636a7bff7d4a5e7830e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 27 Sep 2023 13:27:35 +0000 Subject: since the activity filter widget requires the network module we can link to the module directly so that it will work as quicklink widget in other modules --- Zotlabs/Widget/Activity_filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index daaf5fb67..a8a00bda6 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -26,7 +26,7 @@ class Activity_filter { $starred_active = ''; $conv_active = ''; $tabs = []; - $cmd = \App::$cmd; + $cmd = 'network'; //\App::$cmd; if(x($_GET,'dm')) { $dm_active = (($_GET['dm'] == 1) ? 'active' : ''); -- cgit v1.2.3 From 56e54ac820b32f4b5f7d3f554191079003ac78a5 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 28 Sep 2023 16:55:49 +0000 Subject: if the item is sourced and provides an event add it to the calendar --- Zotlabs/Lib/Libzot.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 032fae3fc..383785992 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1871,8 +1871,9 @@ class Libzot { // if it's a sourced post, call the post_local hooks as if it were // posted locally so that crosspost connectors will be triggered. + $item_source = check_item_source($arr['uid'], $arr); - if (check_item_source($arr['uid'], $arr) || ($channel['xchan_pubforum'] == 1)) { + if ($item_source || ($channel['xchan_pubforum'] == 1)) { /** * @hooks post_local * Called when an item has been posted on this machine via mod/item.php (also via API). @@ -1898,7 +1899,13 @@ class Libzot { if (post_is_importable($arr['uid'], $arr, $abook)) { $item_result = item_store($arr); if ($item_result['success']) { + $item_id = $item_result['item_id']; + + if ($item_source && in_array($item_result['item']['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) { + event_addtocal($item_id, $channel['channel_id']); + } + $parr = [ 'item_id' => $item_id, 'item' => $arr, -- cgit v1.2.3 From 2bd09d3b305e0bf4fc81f9694f8054bdd8edc868 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 4 Oct 2023 17:00:19 +0200 Subject: work with Mastodon-style keyId --- Zotlabs/Module/Owa.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 4de4d32d6..e41435ecd 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -30,18 +30,32 @@ class Owa extends Controller { $sigblock = HTTPSig::parse_sigheader($_SERVER['HTTP_AUTHORIZATION']); if ($sigblock) { $keyId = $sigblock['keyId']; + $parsed = parse_url($keyId); + if (str_starts_with($parsed['scheme'],'http')) { + unset($parsed['fragment']); + unset($parsed['query']); + $keyId = unparse_url($parsed); + } + else { + $keyId = str_replace('acct:', '', $keyId); + } if ($keyId) { $r = q("SELECT * FROM hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash - WHERE (hubloc_addr = '%s' OR hubloc_id_url = '%s') AND hubloc_deleted = 0 AND xchan_pubkey != '' ORDER BY hubloc_id DESC", - dbesc(str_replace('acct:', '', $keyId)), + WHERE (hubloc_addr = '%s' OR hubloc_id_url = '%s' OR xchan_hash = '%s') + AND hubloc_deleted = 0 AND xchan_pubkey != '' + ORDER BY hubloc_id DESC", + dbesc($keyId), + dbesc($keyId), dbesc($keyId) ); if (! $r) { $found = discover_by_webbie($keyId); + logger('found = ' . print_r($found, true)); if ($found) { $r = q("SELECT * FROM hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash - WHERE (hubloc_addr = '%s' OR hubloc_id_url = '%s') AND hubloc_deleted = 0 AND xchan_pubkey != '' ORDER BY hubloc_id DESC ", - dbesc(str_replace('acct:', '', $keyId)), + WHERE (hubloc_addr = '%s' OR hubloc_id_url = '%s' OR xchan_hash = '%s') AND hubloc_deleted = 0 AND xchan_pubkey != '' ORDER BY hubloc_id DESC ", + dbesc($keyId), + dbesc($keyId), dbesc($keyId) ); } -- cgit v1.2.3 From d1421d720c3f8ae9a7c409423fcbea4ff8132676 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Oct 2023 20:11:05 +0200 Subject: parse the event object in first place and use the body bbcode as backup --- Zotlabs/Lib/Activity.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 190777b5f..227739fea 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2344,7 +2344,7 @@ class Activity { $s['expires'] = datetime_convert('UTC', 'UTC', $act->obj['expires']); } - if ($act->type === 'Invite' && $act->objprop('type') === 'Event') { + if (in_array($act->type, ['Invite', 'Create']) && $act->objprop('type') === 'Event') { $s['mid'] = $s['parent_mid'] = $act->id; } @@ -2899,6 +2899,10 @@ class Activity { set_iconfig($s, 'activitypub', 'recips', $act->raw_recips); } + if ($act->objprop('type') === 'Event' && $act->objprop('timezone')) { + set_iconfig($s, 'event', 'timezone', $act->objprop('timezone'), true); + } + $hookinfo = [ 'act' => $act, 's' => $s @@ -3257,7 +3261,12 @@ class Activity { } } - if (is_array($x) && $x['item_id']) { + if ($x['success']) { + + if (check_item_source($channel['channel_id'], $x['item']) && in_array($x['item']['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) { + event_addtocal($x['item_id'], $channel['channel_id']); + } + if ($is_child_node) { if ($item['owner_xchan'] === $channel['channel_hash']) { // We are the owner of this conversation, so send all received comments back downstream -- cgit v1.2.3 From fed9bc70727ed3f8feb2b01f7ffdfd4e0a52cd7e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Oct 2023 08:49:36 +0000 Subject: use encode_person() instead of plain xchan_url since the function makes some special effort to determine the real actor id --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 227739fea..312fcdb5f 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -544,7 +544,7 @@ class Activity { $ret['commentPolicy'] .= 'until=' . datetime_convert('UTC', 'UTC', $i['comments_closed'], ATOM_TIME); } - $ret['attributedTo'] = $i['author']['xchan_url']; + $ret['attributedTo'] = self::encode_person($item['author'], false); if ($i['mid'] !== $i['parent_mid']) { $ret['inReplyTo'] = ((strpos($i['thr_parent'], 'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); -- cgit v1.2.3 From fe38c81e074df0e1b264d6ccf0b033294439594b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Oct 2023 08:50:11 +0000 Subject: use the correct variable --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 312fcdb5f..36e6ecc8c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -544,7 +544,7 @@ class Activity { $ret['commentPolicy'] .= 'until=' . datetime_convert('UTC', 'UTC', $i['comments_closed'], ATOM_TIME); } - $ret['attributedTo'] = self::encode_person($item['author'], false); + $ret['attributedTo'] = self::encode_person($i['author'], false); if ($i['mid'] !== $i['parent_mid']) { $ret['inReplyTo'] = ((strpos($i['thr_parent'], 'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); -- cgit v1.2.3 From 763b69bf5be8c907cc55dfbab5453fd36b86fc04 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 12 Oct 2023 08:39:18 +0000 Subject: enable reset button in mod rpost --- Zotlabs/Module/Rpost.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 5c417daf2..23324ee3a 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -206,7 +206,8 @@ class Rpost extends \Zotlabs\Web\Controller { 'bbco_autocomplete' => 'bbcode', 'editor_autocomplete' => true, 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ); $a = ''; -- cgit v1.2.3 From d7c005a2f1c2bed183b2a79f3f689a8597f73c3f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 19 Oct 2023 06:59:13 +0000 Subject: refactor actor_store() --- Zotlabs/Lib/Activity.php | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 36e6ecc8c..4cb208b18 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -120,7 +120,9 @@ class Activity { } $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), false); + $start_timestamp = microtime(true); $x = z_fetch_url($url, true, $redirects, ['headers' => $h]); + logger('queueworker_stats_process_duration: cmd:Activity_fetch' . ' start_timestamp:' . $start_timestamp . ' ' . 'end_timestamp:' . microtime(true) . ' meta:' . $url . '##' . random_string(16)); } if ($x['success']) { @@ -142,6 +144,9 @@ class Activity { logger('returned: ' . json_encode($y, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DEBUG); if (isset($y['type']) && ActivityStreams::is_an_actor($y['type'])) { + + logger('queueworker_stats_process_duration: cmd:Actor_fetch' . ' start_timestamp:' . $start_timestamp . ' ' . 'end_timestamp:' . microtime(true) . ' meta:' . $url . '##' . random_string(16)); + btlogger('actor fetch'); $y['actor_cache_date'] = datetime_convert(); XConfig::Set($y['id'], 'system', 'actor_record', $y); } @@ -152,6 +157,8 @@ class Activity { logger('fetch failed: ' . $url); logger($x['body']); } + + return null; } @@ -1370,7 +1377,7 @@ class Activity { // store their xchan and hubloc - self::actor_store($person_obj['id'], $person_obj); + self::actor_store($person_obj); // Find any existing abook record @@ -1601,15 +1608,7 @@ class Activity { } - static function actor_store($url, $person_obj = null, $force = false) { - - if ($person_obj === null) { - $tgt = self::fetch($url); - if (is_array($tgt) && ActivityStreams::is_an_actor($tgt['type'])) { - self::actor_store($tgt['id'], $tgt); - } - return; - } + static function actor_store($person_obj, $force = false) { if (!is_array($person_obj)) { return; @@ -1619,13 +1618,14 @@ class Activity { if (array_key_exists('movedTo',$person_obj) && $person_obj['movedTo'] && ! is_array($person_obj['movedTo'])) { $tgt = self::fetch($person_obj['movedTo']); if (is_array($tgt)) { - self::actor_store($person_obj['movedTo'],$tgt); + self::actor_store($tgt); ActivityPub::move($person_obj['id'],$tgt); } return; } */ + $url = null; $ap_hubloc = null; $hublocs = self::get_actor_hublocs($url); @@ -1646,7 +1646,7 @@ class Activity { if ($ap_hubloc) { // we already have a stored record. Determine if it needs updating. if ($ap_hubloc['hubloc_updated'] < datetime_convert('UTC', 'UTC', ' now - 3 days') || $force) { - $person_obj = self::fetch($url); + $person_obj = self::get_cached_actor($url); } else { return; @@ -2300,7 +2300,7 @@ class Activity { } // ensure we store the original actor - self::actor_store($act->actor['id'], $act->actor); + self::actor_store($act->actor); $s['owner_xchan'] = $act->actor['id']; $s['author_xchan'] = $act->actor['id']; @@ -2386,7 +2386,7 @@ class Activity { } // ensure we store the original actor - self::actor_store($obj_actor['id'], $obj_actor); + self::actor_store($obj_actor); $mention = self::get_actor_bbmention($obj_actor['id']); @@ -3387,7 +3387,7 @@ class Activity { } if (is_array($a->actor) && array_key_exists('id', $a->actor)) { - self::actor_store($a->actor['id'], $a->actor); + self::actor_store($a->actor); } $replies = null; @@ -4054,6 +4054,22 @@ class Activity { return $hookdata['actor']; } + static function get_actor($actor_id) { + $actor = self::get_cached_actor($actor_id); + + if ($actor) { + return $actor; + } + + $actor = self::fetch($actor_id); + + if ($actor) { + return $actor; + } + + return null; + } + static function get_unknown_actor($act) { // try other get_actor providers (e.g. diaspora) -- cgit v1.2.3 From f2d7298cf4f81674c808c34ea35d7c7de98b6de1 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Oct 2023 09:30:29 +0000 Subject: check if we have the record in the short time cache before actually fetching it --- Zotlabs/Web/HTTPSig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 531b18649..b709d3e44 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -324,7 +324,7 @@ class HTTPSig { } // The record wasn't in cache. Fetch it now. - $r = Activity::fetch($id); + $r = Activity::get_actor($id); $signatureAlgorithm = EMPTY_STR; if ($r) { -- cgit v1.2.3 From bd9cc23681cf71938cccffef3c2b23a1d76c60b4 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Oct 2023 09:30:52 +0000 Subject: update logger statements --- Zotlabs/Lib/Activity.php | 7 ++++--- Zotlabs/Lib/QueueWorker.php | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4cb208b18..7089f043c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -122,7 +122,6 @@ class Activity { $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), false); $start_timestamp = microtime(true); $x = z_fetch_url($url, true, $redirects, ['headers' => $h]); - logger('queueworker_stats_process_duration: cmd:Activity_fetch' . ' start_timestamp:' . $start_timestamp . ' ' . 'end_timestamp:' . microtime(true) . ' meta:' . $url . '##' . random_string(16)); } if ($x['success']) { @@ -144,12 +143,14 @@ class Activity { logger('returned: ' . json_encode($y, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DEBUG); if (isset($y['type']) && ActivityStreams::is_an_actor($y['type'])) { - - logger('queueworker_stats_process_duration: cmd:Actor_fetch' . ' start_timestamp:' . $start_timestamp . ' ' . 'end_timestamp:' . microtime(true) . ' meta:' . $url . '##' . random_string(16)); + logger('logger_stats_data cmd:Actor_fetch' . ' start:' . $start_timestamp . ' ' . 'end:' . microtime(true) . ' meta:' . $url . '#' . random_string(16)); btlogger('actor fetch'); $y['actor_cache_date'] = datetime_convert(); XConfig::Set($y['id'], 'system', 'actor_record', $y); } + else { + logger('logger_stats_data cmd:Activity_fetch' . ' start:' . $start_timestamp . ' ' . 'end:' . microtime(true) . ' meta:' . $url . '#' . random_string(16)); + } return json_decode($x['body'], true); } diff --git a/Zotlabs/Lib/QueueWorker.php b/Zotlabs/Lib/QueueWorker.php index 1c74b42d8..68e747b0f 100644 --- a/Zotlabs/Lib/QueueWorker.php +++ b/Zotlabs/Lib/QueueWorker.php @@ -63,6 +63,8 @@ class QueueWorker { return; } + logger('queueworker_stats_summon: cmd:' . $argv[0] . ' ' . 'timestamp:' . time()); + self::qstart(); $r = q("INSERT INTO workerq (workerq_priority, workerq_data, workerq_uuid, workerq_cmd) VALUES (%d, '%s', '%s', '%s')", intval($priority), @@ -299,12 +301,16 @@ class QueueWorker { $cls = '\\Zotlabs\\Daemon\\' . $argv[0]; $argv = flatten_array_recursive($argv); $argc = count($argv); - $rnd = random_string(); + $rnd = random_string(16); logger('PROCESSING: ' . $rnd . ' ' . print_r($argv[0], true)); + $start_timestamp = microtime(true); + $cls::run($argc, $argv); + logger('logger_stats_data cmd:' . $argv[0] . ' start:' . $start_timestamp . ' ' . 'end:' . microtime(true) . ' meta:' . $rnd); + logger('COMPLETED: ' . $rnd); // @FIXME: Right now we assume that if we get a return, everything is OK. -- cgit v1.2.3 From 8ea6ead08ad56c1698e870f694cafe4ccb7bab2d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 21 Oct 2023 21:42:14 +0200 Subject: use Activity::get_actor() which will check for the cache record in xconfig before fetching --- Zotlabs/Lib/ActivityStreams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 8b8c95ad8..4c3e3d8f8 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -351,7 +351,7 @@ class ActivityStreams { $x = $this->get_property_obj($property, $base, $namespace); if ($this->is_url($x)) { - $y = Activity::get_cached_actor($x); + $y = Activity::get_actor($x); if ($y) { return $y; } -- cgit v1.2.3 From 286104a988e4c21fc903518128317ce6abf204ce Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 25 Oct 2023 14:45:26 +0200 Subject: slightly less noise when logging normal --- Zotlabs/Lib/JSalmon.php | 2 +- Zotlabs/Lib/Libzot.php | 2 +- Zotlabs/Lib/Zotfinger.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php index f9fe99706..5531f791f 100644 --- a/Zotlabs/Lib/JSalmon.php +++ b/Zotlabs/Lib/JSalmon.php @@ -52,7 +52,7 @@ class JSalmon { . base64url_encode($x['alg'],true); $key = HTTPSig::get_key(EMPTY_STR,'zot6',base64url_decode($x['sigs']['key_id'])); - logger('key: ' . print_r($key,true)); + logger('key: ' . print_r($key,true), LOGGER_DATA); if($key['portable_id'] && $key['public_key']) { if(Crypto::verify($signed_data,base64url_decode($x['sigs']['value']),$key['public_key'])) { logger('verified'); diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 383785992..fba9f118e 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2013,7 +2013,7 @@ class Libzot { // logger($AS->debug()); if(empty($AS->actor['id'])) { - logger('No actor id!'); + logger('No actor id: ' . print_r($AS, true)); continue; } diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php index fa57ab56d..cbfa85f2d 100644 --- a/Zotlabs/Lib/Zotfinger.php +++ b/Zotlabs/Lib/Zotfinger.php @@ -37,7 +37,7 @@ class Zotfinger { $redirects = 0; $x = z_post_url($resource,$data,$redirects, [ 'headers' => $h ] ); - logger('fetch: ' . print_r($x,true)); + logger('fetch: ' . print_r($x,true), LOGGER_DATA); if (in_array(intval($x['return_code']), [ 404, 410 ]) && $recurse) { @@ -74,7 +74,7 @@ class Zotfinger { $result['data'] = json_decode(Crypto::unencapsulate($result['data'],get_config('system','prvkey')),true); } - logger('decrypted: ' . print_r($result,true)); + logger('decrypted: ' . print_r($result,true), LOGGER_DATA); return $result; } -- cgit v1.2.3 From 61b46f1a3e3291ec8b3ea0251d5165b8eb7b08d7 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Oct 2023 13:05:56 +0000 Subject: add stats logging to zotfinger --- Zotlabs/Lib/Zotfinger.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php index fa57ab56d..16ed772c0 100644 --- a/Zotlabs/Lib/Zotfinger.php +++ b/Zotlabs/Lib/Zotfinger.php @@ -35,7 +35,11 @@ class Zotfinger { $result = []; $redirects = 0; + + $start_timestamp = microtime(true); $x = z_post_url($resource,$data,$redirects, [ 'headers' => $h ] ); + logger('logger_stats_data cmd:Zotfinger' . ' start:' . $start_timestamp . ' ' . 'end:' . microtime(true) . ' meta:' . $resource . '#' . random_string(16)); + btlogger('Zotfinger'); logger('fetch: ' . print_r($x,true)); -- cgit v1.2.3 From 67aaa979049ea2666da1fb313b2b095e27422128 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 26 Oct 2023 16:06:15 +0200 Subject: remove the directory updates entry if the channel was removed --- Zotlabs/Lib/Libzotdir.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 58138850c..ca3902a9e 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -362,12 +362,9 @@ class Libzotdir { self::delete_by_hash($ud['ud_hash']); } - // backwards compatibility: Libzot::import_xchan(), where self::update() is called, - // will fail with versions < 8.4 if the channel has been locally deleted. - // In this case we will update the updates record here without bumping the date - // since we could not verify if anything changed. - if (!$xc['success'] && !empty($zf['data']['deleted_locally'])) { - self::update($ud['ud_hash'], $ud['ud_addr'], false); + // if the channel was deleted - delete the entry in updates + if (!empty($zf['data']['deleted_locally'])) { + self::delete_by_hash($ud['ud_hash']); } // This is a workaround for a missing xchan_updated column -- cgit v1.2.3 From 4f334525c2fcb17bee095a02495a025c7bf1a501 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Nov 2023 15:38:53 +0000 Subject: only show tools to creators if they still have perms --- Zotlabs/Storage/Browser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 590c1cd9c..912b4442d 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -209,7 +209,6 @@ class Browser extends DAV\Browser\Plugin { // upload access. system.thumbnail_security should be set to 1 if you want to include these // types - $is_creator = false; $photo_icon = ''; $preview_style = intval(get_config('system','thumbnail_security',0)); @@ -369,6 +368,7 @@ class Browser extends DAV\Browser\Plugin { '$upload' => t('Add Files'), '$is_owner' => $is_owner, '$is_admin' => is_site_admin(), + '$has_perms' => perm_is_allowed($channel_id, get_observer_hash(), 'write_storage'), '$admin_delete_label' => t('Admin Delete'), '$parentpath' => $parent_path, '$folder_parent' => $folder_parent, -- cgit v1.2.3 From 331622309f3f21ea08a1d767967c6143a16f49ef Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Nov 2023 15:47:16 +0000 Subject: if channel is not defined we need to provide an empty array --- Zotlabs/Module/Chat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index 2d36e022a..356071256 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -225,7 +225,7 @@ class Chat extends Controller { $o = ''; - $acl = new AccessList($channel); + $acl = new AccessList($channel ?? []); $channel_acl = $acl->get(); $lockstate = (($channel_acl['allow_cid'] || $channel_acl['allow_gid'] || $channel_acl['deny_cid'] || $channel_acl['deny_gid']) ? 'lock' : 'unlock'); -- cgit v1.2.3 From c74068ae4d1b5af9dcaf9fac04cdabdcc5729b33 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Nov 2023 08:33:22 +0000 Subject: libzot: correctly attribute streams repeats --- Zotlabs/Lib/Libzot.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index fba9f118e..13cc8b1ae 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1114,6 +1114,7 @@ class Libzot { */ static function import($arr) { + $env = $arr; $private = false; $return = []; @@ -1219,13 +1220,20 @@ class Libzot { return; } - $r = Activity::get_actor_hublocs($AS->actor['id']); + $author_url = $AS->actor['id']; + + if ($AS->type === 'Announce') { + hz_syslog(print_r($AS, true)); + $author_url = Activity::get_attributed_to_actor_url($AS); + } + + $r = Activity::get_actor_hublocs($author_url); - if (! $r) { + if (!$r) { // Author is unknown to this site. Perform channel discovery and try again. - $z = discover_by_webbie($AS->actor['id']); + $z = discover_by_webbie($author_url); if ($z) { - $r = Activity::get_actor_hublocs($AS->actor['id']); + $r = Activity::get_actor_hublocs($author_url); } } @@ -1829,6 +1837,11 @@ class Libzot { if ($r) { // We already have this post. + // Dismiss its announce + if ($act->type === 'Announce') { + return; + } + $item_id = $r[0]['id']; if (intval($r[0]['item_deleted'])) { -- cgit v1.2.3 From 95c13eaf5a0f63b9b98fdff0fe887546953bc76f Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Nov 2023 08:34:13 +0000 Subject: remove logging --- Zotlabs/Lib/Libzot.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 13cc8b1ae..d7692ee4a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1223,7 +1223,6 @@ class Libzot { $author_url = $AS->actor['id']; if ($AS->type === 'Announce') { - hz_syslog(print_r($AS, true)); $author_url = Activity::get_attributed_to_actor_url($AS); } -- cgit v1.2.3 From 42651707f82bb0f46153eb964d828787d9ba3c3c Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Nov 2023 08:40:34 +0000 Subject: check if required keys are set --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index d7692ee4a..e812dbd92 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1455,7 +1455,7 @@ class Libzot { if ($act && $act->obj) { if (isset($act->obj['tag']) && is_array($act->obj['tag']) && $act->obj['tag']) { foreach ($act->obj['tag'] as $tag) { - if ($tag['type'] === 'Mention' && (strpos($tag['href'], z_root()) !== false)) { + if (isset($tag['type'], $tag['href']) && $tag['type'] === 'Mention' && (strpos($tag['href'], z_root()) !== false)) { $address = basename($tag['href']); if ($address) { $z = q("select channel_hash as hash from channel where channel_address = '%s' and channel_hash != '%s' -- cgit v1.2.3 From 85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Nov 2023 19:32:29 +0000 Subject: some low level work on native repeats --- Zotlabs/Daemon/Notifier.php | 7 ++++- Zotlabs/Lib/DReport.php | 3 ++- Zotlabs/Lib/Libzot.php | 42 ++++++++++++++++------------- Zotlabs/Module/Share.php | 64 +++++++++++++++++++++++++-------------------- 4 files changed, 67 insertions(+), 49 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 592dd2c38..4b74a7ba9 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -300,6 +300,11 @@ class Notifier { return; } + if ($target_item['verb'] === ACTIVITY_SHARE) { + // Provide correct representation across the wire. Internally this is treated as a comment. + $target_item['parent_mid'] = $target_item['thr_parent'] = $target_item['mid']; + } + if ($target_item['mid'] === $target_item['parent_mid']) { $parent_item = $target_item; $top_level_post = true; @@ -377,7 +382,7 @@ class Notifier { if (($relay_to_owner || $uplink) && ($cmd !== 'relay')) { logger('notifier: followup relay', LOGGER_DEBUG); - $sendto = (($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']); + $sendto = (($uplink) ? $parent_item['source_xchan'] : (($parent_item['verb'] === ACTIVITY_SHARE) ? $parent_item['author_xchan'] : $parent_item['owner_xchan'])); self::$recipients = [$sendto]; self::$private = true; $upstream = true; diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php index e22ed65be..c5c2eb088 100644 --- a/Zotlabs/Lib/DReport.php +++ b/Zotlabs/Lib/DReport.php @@ -119,8 +119,9 @@ class DReport { if((! $r) && ($dr['status'] === 'recipient_not_found')) return false; - $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + $r = q("select abook_id from abook where (abook_xchan = '%s' OR abook_xchan = '%s') and abook_channel = %d limit 1", dbesc($dr['recipient']), + dbesc($dr['sender']), intval($c[0]['channel_id']) ); if($r) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index e812dbd92..e9cb2c35c 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1516,11 +1516,9 @@ class Libzot { */ static function process_delivery($sender, $act, $arr, $deliveries, $relay, $public = false, $request = false, $force = false) { - $result = []; // We've validated the sender. Now make sure that the sender is the owner or author - if (!$public) { if ($sender != $arr['owner_xchan'] && $sender != $arr['author_xchan']) { logger("Sender $sender is not owner {$arr['owner_xchan']} or author {$arr['author_xchan']} - mid {$arr['mid']}"); @@ -1641,6 +1639,13 @@ class Libzot { if (!$allowed && $permit_mentions) { $allowed = true; } + + if (!$allowed) { + if (PConfig::Get($channel['channel_id'], 'system', 'moderate_unsolicited_comments') && $arr['obj_type'] !== 'Answer') { + $arr['item_blocked'] = ITEM_MODERATED; + $allowed = true; + } + } } } elseif ($permit_mentions) { @@ -1649,7 +1654,6 @@ class Libzot { } if ($request) { - // Conversation fetches (e.g. $request == true) take place for // a) new comments on expired posts // b) hyperdrive (friend-of-friend) conversations @@ -1838,7 +1842,9 @@ class Libzot { // We already have this post. // Dismiss its announce if ($act->type === 'Announce') { - return; + $DR->update('update ignored'); + $result[] = $DR->get(); + continue; } $item_id = $r[0]['id']; @@ -1847,7 +1853,6 @@ class Libzot { // It was deleted locally. $DR->update('update ignored'); $result[] = $DR->get(); - continue; } // Maybe it has been edited? @@ -1855,17 +1860,17 @@ class Libzot { $arr['id'] = $r[0]['id']; $arr['uid'] = $channel['channel_id']; - if (post_is_importable($channel['channel_id'], $arr, $abook)) { - $item_result = self::update_imported_item($sender, $arr, $r[0], $channel['channel_id'], $tag_delivery); - $DR->update('updated'); - $result[] = $DR->get(); - if (!$relay) { - add_source_route($item_id, $sender); - } - } else { - $DR->update('update ignored'); - $result[] = $DR->get(); - } + if (post_is_importable($channel['channel_id'], $arr, $abook)) { + $item_result = self::update_imported_item($sender, $arr, $r[0], $channel['channel_id'], $tag_delivery); + $DR->update('updated'); + $result[] = $DR->get(); + if (!$relay) { + add_source_route($item_id, $sender); + } + } else { + $DR->update('update ignored'); + $result[] = $DR->get(); + } } else { $DR->update('update ignored'); @@ -1940,7 +1945,8 @@ class Libzot { add_source_route($item_id, $sender); } } - $DR->update(($item_id) ? 'posted' : 'storage failed: ' . $item_result['message']); + + $DR->update(($item_id) ? (($item_result['item']['item_blocked'] === ITEM_MODERATED) ? 'accepted for moderation' : 'posted') : 'storage failed: ' . $item_result['message']); $result[] = $DR->get(); } else { $DR->update('post ignored'); @@ -1957,7 +1963,7 @@ class Libzot { retain_item($stored['item']['parent']); } - if ($relay && $item_id) { + if ($relay && $item_id && $stored['item_blocked'] !== ITEM_MODERATED) { logger('Invoking relay'); Master::Summon(['Notifier', 'relay', intval($item_id)]); $DR->addto_update('relayed'); diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index c0db9978e..716f7229b 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -14,47 +14,53 @@ require_once('include/bbcode.php'); class Share extends \Zotlabs\Web\Controller { function init() { - - $post_id = ((argc() > 1) ? intval(argv(1)) : 0); - - if(! $post_id) - killme(); - - if(! local_channel()) { + + if (!intval(argv(1))) { killme(); } - $observer = App::get_observer(); + if (! local_channel()) { + killme(); + } + $observer = App::get_observer(); $channel = App::get_channel(); + $sys_channel = get_sys_channel(); $r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1", - intval($post_id) + intval(argv(1)) ); - if(! $r) - killme(); - + if ($r[0]['uid'] === $sys_channel['channel_id']) { + $r = [copy_of_pubitem($channel, $r[0]['mid'])]; + } + + if(! $r) { + killme(); + } + $item_id = $r[0]['id']; - if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss')) + if ($r[0]['item_private']) { killme(); - + } + $sql_extra = item_permissions_sql($r[0]['uid']); - + $r = q("select * from item where id = %d $sql_extra", - intval($post_id) + intval($item_id) ); + if(! $r) killme(); - + /** @FIXME we only share bbcode */ - + if($r[0]['mimetype'] !== 'text/bbcode') killme(); - - xchan_query($r); - + + xchan_query($r,true); + $arr = []; $item = $r[0]; @@ -81,7 +87,7 @@ class Share extends \Zotlabs\Web\Controller { $thread_owner = $r[0]; else killme(); - + $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['author_xchan']) ); @@ -89,7 +95,7 @@ class Share extends \Zotlabs\Web\Controller { $item_author = $r[0]; else killme(); - + $arr['aid'] = $owner_aid; $arr['uid'] = $owner_uid; @@ -109,12 +115,12 @@ class Share extends \Zotlabs\Web\Controller { $arr['obj_type'] = $item['obj_type']; $arr['verb'] = ACTIVITY_SHARE; - $post = item_store($arr); + $post = item_store($arr); $post_id = $post['item_id']; $arr['id'] = $post_id; - + call_hooks('post_local_end', $arr); info( t('Post repeated') . EOL); @@ -128,10 +134,10 @@ class Share extends \Zotlabs\Web\Controller { Libsync::build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]); } - Master::Summon([ 'Notifier','like',$post_id ]); - + Master::Summon([ 'Notifier', 'like', $post_id ]); + killme(); - + } - + } -- cgit v1.2.3 From aad6042d425c390ebc3eed1b77636c854df739cc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Nov 2023 20:09:49 +0000 Subject: DB Update 1259 --- Zotlabs/Update/_1259.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Zotlabs/Update/_1259.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1259.php b/Zotlabs/Update/_1259.php new file mode 100644 index 000000000..235ca62f9 --- /dev/null +++ b/Zotlabs/Update/_1259.php @@ -0,0 +1,30 @@ + Date: Thu, 16 Nov 2023 15:57:03 +0000 Subject: work around a possible privacy mismatch when processing zot requests --- Zotlabs/Module/Item.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index b564396c9..4c6b345fb 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -84,7 +84,7 @@ class Item extends Controller { } observer_auth($portable_id); - $i = q("select id as item_id, uid from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1", + $i = q("select id as item_id, uid, item_private from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1", dbesc($r[0]['parent_mid']), dbesc($portable_id) ); @@ -99,7 +99,7 @@ class Item extends Controller { $sql_extra = item_permissions_sql(0); if (!$i) { - $i = q("select id as item_id, uid from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1", + $i = q("select id as item_id, uid, item_private from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1", dbesc($r[0]['parent_mid']) ); } @@ -119,9 +119,11 @@ class Item extends Controller { } $parents_str = ids_to_querystr($i, 'item_id'); + $parent_item_private = $i[0]['item_private']; - $total = q("SELECT count(*) AS count FROM item WHERE parent = %d $item_normal", - intval($parents_str) + $total = q("SELECT count(*) AS count FROM item WHERE parent = %d and item_private = %d $item_normal", + intval($parents_str), + intval($parent_item_private) ); App::set_pager_total($total[0]['count']); @@ -134,8 +136,9 @@ class Item extends Controller { as_return_and_die($i ,$chan); } else { - $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent = %d $item_normal ORDER BY item.id", - intval($parents_str) + $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent = %d and item_private = %d $item_normal ORDER BY item.id", + intval($parents_str), + intval($parent_item_private) ); xchan_query($items, true); -- cgit v1.2.3 From af58364fefd52b03c32ac9594f87f6bbaed8e002 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 17 Nov 2023 07:50:10 +0000 Subject: only check for privacy mismatch if observer != owner --- Zotlabs/Module/Item.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 4c6b345fb..25ccb0cbf 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -84,7 +84,7 @@ class Item extends Controller { } observer_auth($portable_id); - $i = q("select id as item_id, uid, item_private from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1", + $i = q("select id as item_id, uid from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1", dbesc($r[0]['parent_mid']), dbesc($portable_id) ); @@ -119,11 +119,12 @@ class Item extends Controller { } $parents_str = ids_to_querystr($i, 'item_id'); - $parent_item_private = $i[0]['item_private']; - $total = q("SELECT count(*) AS count FROM item WHERE parent = %d and item_private = %d $item_normal", - intval($parents_str), - intval($parent_item_private) + // We won't need to check for privacy mismatches if the verified observer is also owner + $parent_item_private = ((isset($i[0]['item_private'])) ? " and item_private = " . intval($i[0]['item_private']) . " " : ''); + + $total = q("SELECT count(*) AS count FROM item WHERE parent = %d $parent_item_private $item_normal ", + intval($parents_str) ); App::set_pager_total($total[0]['count']); @@ -136,9 +137,8 @@ class Item extends Controller { as_return_and_die($i ,$chan); } else { - $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent = %d and item_private = %d $item_normal ORDER BY item.id", - intval($parents_str), - intval($parent_item_private) + $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent = %d $parent_item_private $item_normal ORDER BY item.id", + intval($parents_str) ); xchan_query($items, true); -- cgit v1.2.3 From 74911e9f6d44643facd6fa1b45c2035b780570e4 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Nov 2023 20:32:14 +0000 Subject: revert dreport changes - too chatty --- Zotlabs/Lib/DReport.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php index c5c2eb088..e22ed65be 100644 --- a/Zotlabs/Lib/DReport.php +++ b/Zotlabs/Lib/DReport.php @@ -119,9 +119,8 @@ class DReport { if((! $r) && ($dr['status'] === 'recipient_not_found')) return false; - $r = q("select abook_id from abook where (abook_xchan = '%s' OR abook_xchan = '%s') and abook_channel = %d limit 1", + $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($dr['recipient']), - dbesc($dr['sender']), intval($c[0]['channel_id']) ); if($r) -- cgit v1.2.3 From 80bdb39ae3fe7600d5a855ade1d4e8863ca866ee Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Nov 2023 16:41:44 +0000 Subject: case insensitive digest algo --- Zotlabs/Web/HTTPSig.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index b709d3e44..36a00528e 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -212,7 +212,8 @@ class HTTPSig { if (in_array('digest', $signed_headers)) { $result['content_signed'] = true; - $digest = explode('=', $headers['digest'], 2); + $digest = explode('=', $headers['digest'], 2); + $digest[0] = strtoupper($digest[0]); if ($digest[0] === 'SHA-256') $hashalg = 'sha256'; if ($digest[0] === 'SHA-512') -- cgit v1.2.3 From a396e74a79238779bd7efaac0c6ae59b20d5f114 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Nov 2023 13:21:56 +0000 Subject: like in get_cached_actor() also remove fragment in get_actor() --- Zotlabs/Lib/Activity.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 7089f043c..835909849 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -4056,6 +4056,9 @@ class Activity { } static function get_actor($actor_id) { + // remove fragment + $actor_id = ((strpos($actor_id, '#')) ? substr($actor_id, 0, strpos($actor_id, '#')) : $actor_id); + $actor = self::get_cached_actor($actor_id); if ($actor) { -- cgit v1.2.3