diff options
-rw-r--r-- | Zotlabs/Lib/Activity.php | 32 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 21 | ||||
-rw-r--r-- | Zotlabs/Module/Contactedit.php | 32 | ||||
-rw-r--r-- | Zotlabs/Module/Setup.php | 5 | ||||
-rw-r--r-- | Zotlabs/Web/HTTPSig.php | 41 | ||||
-rw-r--r-- | composer.json | 1 | ||||
-rw-r--r-- | view/tpl/contact_edit_tools.tpl | 1 |
7 files changed, 84 insertions, 49 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 0f76fce9a..ab96423d7 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1659,7 +1659,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::get_cached_actor($url); + $person_obj = self::get_actor($url, $force); } else { return; @@ -2370,6 +2370,7 @@ class Activity { } if (!$response_activity) { +/* if ($act->type === 'Announce') { $s['author_xchan'] = self::get_attributed_to_actor_url($act); $s['mid'] = $act->objprop('id') ?: $act->obj; @@ -2379,6 +2380,7 @@ class Activity { $s['parent_mid'] = $act->objprop('id') ?: $act->obj; } } +*/ // we will need a hook here to extract magnet links e.g. peertube // right now just link to the largest mp4 we find that will fit in our @@ -2713,12 +2715,12 @@ class Activity { } // An ugly and imperfect way to recognise a mastodon or friendica direct message - if (empty($act->recips) || // friendica - ($item['item_private'] === 1 && + if ( + $item['item_private'] === 1 && !isset($act->raw_recips['cc']) && is_array($act->raw_recips['to']) && in_array(channel_url($channel), $act->raw_recips['to']) && - !in_array($act->actor['followers'], $act->raw_recips['to'])) + !in_array($act->actor['followers'], $act->raw_recips['to']) ) { $item['item_private'] = 2; } @@ -3076,10 +3078,12 @@ class Activity { $p = []; $announce_init = false; + $group_announce_init = false; if (is_object($act) && is_array($item)) { $p[] = [$act, $item]; $announce_init = ($item['verb'] === 'Announce'); + $group_announce_init = ($announce_init && $act->actor['type'] === 'Group'); } if (is_string($item)) { @@ -3149,12 +3153,22 @@ class Activity { $item['source_xchan'] = $observer_hash; // WARNING: the presence of both source_xchan and non-zero item_uplink here will cause a delivery loop $item['item_uplink'] = 0; - $item['verb'] = 'Announce'; - $item['parent_mid'] = $item['thr_parent'] = $item['mid']; - $item['item_thread_top'] = 1; + + if ($item['item_thread_top']) { + $item['verb'] = 'Announce'; + } + + if (!$group_announce_init) { + // Force a new thread if the announce init actor is not a group + $item['verb'] = 'Announce'; + $item['parent_mid'] = $item['thr_parent'] = $item['mid']; + $item['item_thread_top'] = 1; + } + } else { $announce_init = ($i === 0 && $item['verb'] === 'Announce'); + $group_announce_init = ($announce_init && $a->actor['type'] === 'Group'); } if (intval($channel['channel_system']) && intval($item['item_private'])) { @@ -3483,11 +3497,11 @@ class Activity { return $hookdata['actor']; } - static function get_actor($actor_id) { + static function get_actor($actor_id, $force = false) { // remove fragment $actor_id = ((strpos($actor_id, '#')) ? substr($actor_id, 0, strpos($actor_id, '#')) : $actor_id); - $actor = self::get_cached_actor($actor_id); + $actor = ((!$force) ? self::get_cached_actor($actor_id) : null); if ($actor) { return $actor; diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index b3b58af89..9f028bb46 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -89,7 +89,7 @@ class ActivityStreams { // Attempt to assemble an Activity from what we were given. if ($this->is_valid()) { - $this->id = $this->get_property_obj('id'); + $this->id = $this->get_property_obj('id'); if (!$this->id) { logger('Data with mmissing id: ' . print_r($this->data, true)); @@ -130,24 +130,31 @@ class ActivityStreams { } } - // fetch recursive or embedded activities + // 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('object', $this->obj); } - if ($this->obj && is_array($this->obj) && isset($this->obj['actor'])) + // Enumerate and store actors in referenced objects + + if ($this->obj && is_array($this->obj) && isset($this->obj['actor'])) { $this->obj['actor'] = $this->get_actor('actor', $this->obj); - if ($this->tgt && is_array($this->tgt) && isset($this->tgt['actor'])) + } + + if ($this->tgt && is_array($this->tgt) && isset($this->tgt['actor'])) { $this->tgt['actor'] = $this->get_actor('actor', $this->tgt); + } + + // Determine if this is a followup or response activity $this->parent_id = $this->get_property_obj('inReplyTo'); - if (!$this->parent_id && is_array($this->obj) && isset($this->obj['inReplyTo'])) { - $this->parent_id = $this->obj['inReplyTo']; + if (!$this->parent_id && isset($this->obj['inReplyTo'])) { + $this->parent_id = ((is_array($this->obj['inReplyTo'])) ? $this->obj['inReplyTo']['id'] : $this->obj['inReplyTo']); } - if (!$this->parent_id && is_array($this->obj) && isset($this->obj['id'])) { + if (!$this->parent_id && isset($this->obj['id'])) { $this->parent_id = $this->obj['id']; } diff --git a/Zotlabs/Module/Contactedit.php b/Zotlabs/Module/Contactedit.php index 58c3380a1..e20e90872 100644 --- a/Zotlabs/Module/Contactedit.php +++ b/Zotlabs/Module/Contactedit.php @@ -494,28 +494,32 @@ class Contactedit extends Controller { 'message' => '' ]; - if ($cmd === 'resetphoto') { - q("update xchan set xchan_photo_date = '2001-01-01 00:00:00' where xchan_hash = '%s'", + if ($cmd === 'refresh') { + q("update xchan set xchan_photo_date = '0001-01-01 00:00:00', xchan_name_date = '0001-01-01 00:00:00' where xchan_hash = '%s'", dbesc($contact['xchan_hash']) ); - $cmd = 'refresh'; - } - if ($cmd === 'refresh') { if ($contact['xchan_network'] === 'zot6') { if (Libzot::refresh($contact, App::get_channel())) { $ret['success'] = true; $ret['message'] = t('Refresh succeeded'); } else { - $ret['message'] = t('Refresh failed - channel is currently unavailable'); + $ret['message'] = t('Refresh failed'); } } else { // if you are on a different network we'll force a refresh of the connection basic info - Master::Summon(['Notifier', 'permission_update', $contact['abook_id']]); - $ret['success'] = true; - $ret['message'] = t('Refresh succeeded'); + $hookinfo = [ + 'contact' => $contact, + 'success' => false, + 'message' => '' + ]; + + call_hooks('actor_refetch', $hookinfo); + + $ret['success'] = $hookinfo['success']; + $ret['message'] = $hookinfo['message']; } return $ret; @@ -625,16 +629,10 @@ class Contactedit extends Controller { return [ 'refresh' => [ - 'label' => t('Refresh Permissions'), - 'title' => t('Fetch updated permissions'), + 'label' => t('Refresh'), + 'title' => t('Refetch contact info'), ], - 'rephoto' => [ - 'label' => t('Refresh Photo'), - 'title' => t('Fetch updated photo'), - ], - - 'block' => [ 'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')), 'sel' => (intval($contact['abook_blocked']) ? 'active' : ''), diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index a48c6627b..83faf85dc 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -527,6 +527,7 @@ class Setup extends \Zotlabs\Web\Controller { $this->check_add($ck_funcs, t('mb_string PHP module'), true, true); $this->check_add($ck_funcs, t('xml PHP module'), true, true); $this->check_add($ck_funcs, t('zip PHP module'), true, true); + $this->check_add($ck_funcs, t('intl PHP module'), true, true); if(function_exists('apache_get_modules')){ if(! in_array('mod_rewrite', apache_get_modules())) { @@ -583,6 +584,10 @@ class Setup extends \Zotlabs\Web\Controller { $ck_funcs[6]['status'] = false; $ck_funcs[6]['help'] = t('Error: zip PHP module required but not installed.'); } + if(! extension_loaded('intl')) { + $ck_funcs[6]['status'] = false; + $ck_funcs[6]['help'] = t('Error: intl PHP module required but not installed.'); + } $checks = array_merge($checks, $ck_funcs); } diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 439ca472b..793b8cb45 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -44,37 +44,42 @@ class HTTPSig { } } - static function find_headers($data, &$body) { + public static function find_headers($data, &$body) { // decide if $data arrived via controller submission or curl + // changes $body for the caller - if (is_array($data) && $data['header']) { - if (!$data['success']) + if (is_array($data) && array_key_exists('header', $data)) { + if (!$data['success']) { + $body = EMPTY_STR; return []; + } - $h = new HTTPHeaders($data['header']); - $headers = $h->fetcharr(); - $body = $data['body']; - $headers['(request-target)'] = $data['request_target']; - } + if (!$data['header']) { + $body = EMPTY_STR; + return []; + } - else { - $headers = []; + $h = new HTTPHeaders($data['header']); + $headers = $h->fetcharr(); + $body = $data['body']; + $headers['(request-target)'] = $data['request_target']; + } else { + $headers = []; $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; - $headers['content-type'] = $_SERVER['CONTENT_TYPE']; - $headers['content-length'] = $_SERVER['CONTENT_LENGTH']; + $headers['content-type'] = $_SERVER['CONTENT_TYPE']; + $headers['content-length'] = $_SERVER['CONTENT_LENGTH']; foreach ($_SERVER as $k => $v) { if (strpos($k, 'HTTP_') === 0) { - $field = str_replace('_', '-', strtolower(substr($k, 5))); + $field = str_replace('_', '-', strtolower(substr($k, 5))); $headers[$field] = $v; } } } //logger('SERVER: ' . print_r($_SERVER,true), LOGGER_ALL); - - //logger('headers: ' . print_r($headers,true), LOGGER_ALL); + //logger('found_headers: ' . print_r($headers,true), LOGGER_ALL); return $headers; } @@ -102,6 +107,10 @@ class HTTPSig { if (!$headers) return $result; + if (is_array($body)) { + btlogger('body is array:' . print_r($body, true)); + } + $sig_block = null; if (array_key_exists('signature', $headers)) { @@ -217,8 +226,10 @@ class HTTPSig { $result['content_signed'] = true; $digest = explode('=', $headers['digest'], 2); $digest[0] = strtoupper($digest[0]); + if ($digest[0] === 'SHA-256') $hashalg = 'sha256'; + if ($digest[0] === 'SHA-512') $hashalg = 'sha512'; diff --git a/composer.json b/composer.json index e3c109c0e..06765eba9 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "php": ">=8.0.2", "ext-curl": "*", "ext-iconv": "*", + "ext-intl": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-openssl": "*", diff --git a/view/tpl/contact_edit_tools.tpl b/view/tpl/contact_edit_tools.tpl index 565b9df86..2d0b8a8cf 100644 --- a/view/tpl/contact_edit_tools.tpl +++ b/view/tpl/contact_edit_tools.tpl @@ -3,7 +3,6 @@ </button> <div class="dropdown-menu"> <a class="dropdown-item contact-tool" href="#" title="{{$tools.refresh.title}}" data-cmd="refresh">{{$tools.refresh.label}}</a> - <a class="dropdown-item contact-tool" href="#" title="{{$tools.rephoto.title}}" data-cmd="resetphoto">{{$tools.rephoto.label}}</a> <div class="dropdown-divider"></div> <a class="dropdown-item contact-tool" href="#" title="{{$tools.block.title}}" data-cmd="block">{{$tools.block.label}}</a> <a class="dropdown-item contact-tool" href="#" title="{{$tools.ignore.title}}" data-cmd="ignore">{{$tools.ignore.label}}</a> |