From 21ac4b513996df80a12e249b29eca0bee40e47cc Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 7 Dec 2020 09:49:38 +0000 Subject: remove announce activity from response activites array (cherry picked from commit 52c78c757ae73082ed29e48707b2313e65020db3) --- Zotlabs/Lib/ActivityStreams.php | 14 +++++++------- include/items.php | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index a0ba52aa6..f877fbb45 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -49,7 +49,7 @@ class ActivityStreams { if($this->data) { // verify and unpack JSalmon signature if present - + if(is_array($this->data) && array_key_exists('signed',$this->data)) { $ret = JSalmon::verify($this->data); $tmp = JSalmon::unpack($this->data['data']); @@ -103,7 +103,7 @@ class ActivityStreams { } // fetch recursive or embedded activities - + if ($this->obj && is_array($this->obj) && array_key_exists('object',$this->obj)) { $this->obj['object'] = $this->get_compound_property($this->obj['object']); } @@ -115,10 +115,10 @@ class ActivityStreams { $this->parent_id = $this->get_property_obj('inReplyTo'); - if((! $this->parent_id) && is_array($this->obj)) { + if((! $this->parent_id) && is_array($this->obj)) { $this->parent_id = $this->obj['inReplyTo']; } - if((! $this->parent_id) && is_array($this->obj)) { + if((! $this->parent_id) && is_array($this->obj)) { $this->parent_id = $this->obj['id']; } } @@ -286,7 +286,7 @@ class ActivityStreams { if (! $s) { return false; } - return (in_array($s, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject', 'emojiReaction', 'EmojiReaction', 'EmojiReact' ])); + return (in_array($s, [ 'Like', 'Dislike', 'Flag', 'Block', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject', 'emojiReaction', 'EmojiReaction', 'EmojiReact' ])); } /** @@ -302,7 +302,7 @@ class ActivityStreams { $x = $this->get_property_obj($property, $base, $namespace); if($this->is_url($x)) { - // SECURITY: If we have already stored the actor profile, re-generate it + // SECURITY: If we have already stored the actor profile, re-generate it // from cached data - don't refetch it from the network $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s' limit 1", @@ -344,7 +344,7 @@ class ActivityStreams { } // verify and unpack JSalmon signature if present - + if(is_array($x) && array_key_exists('signed',$x)) { $ret = JSalmon::verify($x); $tmp = JSalmon::unpack($x['data']); diff --git a/include/items.php b/include/items.php index a027be4b2..bcdc6c687 100755 --- a/include/items.php +++ b/include/items.php @@ -1551,7 +1551,7 @@ function get_mail_elements($x) { $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']); $arr['mail_flags'] = 0; - + if(array_key_exists('sig',$x)) $arr['sig'] = $x['sig']; @@ -3022,7 +3022,7 @@ function tgroup_check($uid, $item) { } // post to group via DM - + if ($is_group) { if (intval($item['item_private']) === 2 && $item['mid'] === $item['parent_mid']) { return true; @@ -3199,7 +3199,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false if ($group && (! $parent)) { $arr = []; - + if ($edit) { // process edit or delete action $r = q("select * from item where source_xchan = '%s' and body like '%s' and uid = %d limit 1", @@ -3231,12 +3231,12 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr['mid'] = z_root() . '/activity/' . $arr['uuid']; $arr['parent_mid'] = $arr['mid']; } - + $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; // WARNING: the presence of both source_xchan and non-zero item_uplink here will cause a delivery loop - + $arr['item_uplink'] = 0; $arr['source_xchan'] = $item['owner_xchan']; @@ -3246,14 +3246,14 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr['item_origin'] = 1; $arr['item_wall'] = 1; $arr['item_thread_top'] = 1; - + if (strpos($item['body'], "[/share]") !== false) { $pos = strpos($item['body'], "[share"); $bb = substr($item['body'], $pos); } else { $bb = "[share author='" . urlencode($item['author']['xchan_name']). "' profile='" . $item['author']['xchan_url'] . - "' portable_id='" . $item['author']['xchan_hash'] . + "' portable_id='" . $item['author']['xchan_hash'] . "' avatar='" . $item['author']['xchan_photo_s'] . "' link='" . $item['plink'] . "' auth='" . ((in_array($item['author']['xchan_network'], ['zot6','zot'])) ? 'true' : 'false') . -- cgit v1.2.3 From d984918c75f4721975a0db55d8d05cf424b55e16 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 7 Dec 2020 11:08:41 +0100 Subject: Skip profile photo query from addons for undefined channel id --- Zotlabs/Module/Photo.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index c88696578..01edda9ae 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -81,18 +81,18 @@ class Photo extends \Zotlabs\Web\Controller { else $data = dbunescbin($r[0]['content']); } - } - if(! $data) { - $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; - call_hooks('get_profile_photo',$d); - - $resolution = $d['imgscale']; - $uid = $d['channel_id']; - $default = $d['default']; - $data = $d['data']; - $mimetype = $d['mimetype']; - $modified = 0; + if(! $data) { + $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; + call_hooks('get_profile_photo',$d); + + $resolution = $d['imgscale']; + $uid = $d['channel_id']; + $default = $d['default']; + $data = $d['data']; + $mimetype = $d['mimetype']; + $modified = 0; + } } if(! $data) { -- cgit v1.2.3 From 8c1c49a45ed28f5235d6a5f7668d2c31158fbea3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Dec 2020 11:32:37 +0000 Subject: fix hubloc issue in mod getfile (cherry picked from commit b0b9b9f28974f9016e47491e81876224c57a7e3b) --- Zotlabs/Module/Getfile.php | 5 +++-- include/import.php | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 6d31d23fd..17d1c84b8 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; use Zotlabs\Web\HTTPSig; +use Zotlabs\Lib\Libzot; /** * module: getfile @@ -54,11 +55,11 @@ class Getfile extends \Zotlabs\Web\Controller { if($keyId) { $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where hubloc_addr = '%s' limit 1", + where hubloc_addr = '%s'", dbesc(str_replace('acct:','',$keyId)) ); if($r) { - $hubloc = $r[0]; + $hubloc = Libzot::zot_record_preferred($r); $verified = HTTPSig::verify('',$hubloc['xchan_pubkey']); if($verified && $verified['header_signed'] && $verified['header_valid'] && $hash == $hubloc['hubloc_hash']) { $header_verified = true; diff --git a/include/import.php b/include/import.php index 82c23e116..8f7c28f93 100644 --- a/include/import.php +++ b/include/import.php @@ -527,12 +527,12 @@ function sync_apps($channel, $apps) { /** * @brief Import system apps. - * System apps from the original server may not exist on this system + * System apps from the original server may not exist on this system * (e.g. apps associated with addons that are not installed here). * Check the system apps that were provided in the import file to see if they * exist here and if so, install them locally. Preserve categories that * might have been added by this channel on the other server. - * Do not use any paths from the original as they will point to a different server. + * Do not use any paths from the original as they will point to a different server. * @param array $channel * @param array $apps */ @@ -1373,7 +1373,7 @@ function sync_files($channel, $files) { logger('attachment store failed',LOGGER_NORMAL,LOG_ERR); } if($f['photo']) { - + foreach($f['photo'] as $p) { unset($p['id']); $p['aid'] = $channel['channel_account_id']; @@ -1446,7 +1446,7 @@ function sync_files($channel, $files) { $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); - + // Override remote hub thumbnails storage settings if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) { $p['os_storage'] = 0; @@ -1488,12 +1488,12 @@ function sync_files($channel, $files) { create_table_from_array('photo',$p, [ 'content' ] ); } } - + } - + // Set xchan photo date to prevent thumbnails fetch for clones on profile update packet recieve if(isset($update_xchan)) { - + $x = q("UPDATE xchan SET xchan_photo_date = '%s' WHERE xchan_hash = '%s'", dbescdate($update_xchan), dbesc($channel['channel_hash']) @@ -1522,13 +1522,13 @@ function sync_addressbook($channel, $data) { if(! \Zotlabs\Lib\Apps::system_app_installed($channel['channel_id'], 'CardDAV')) return; - + logger("debug: " . print_r($data,true), LOGGER_DEBUG); require_once('include/cdav.php'); $principalUri = 'principals/' . $channel['channel_address']; - + if($data['action'] !== 'create') { $id = get_cdav_id($principalUri, $data['uri'], 'addressbooks'); if(! $id) @@ -1630,7 +1630,7 @@ function sync_calendar($channel, $data) { break; case 'update_card': - $caldavBackend->updateCalendarObject($id, $data['carduri'], $data['card']); + $caldavBackend->updateCalendarObject($id, $data['carduri'], $data['card']); break; case 'switch': -- cgit v1.2.3