diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 62 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/JSalmon.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 24 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzotdir.php | 9 | ||||
-rw-r--r-- | Zotlabs/Lib/QueueWorker.php | 8 | ||||
-rw-r--r-- | Zotlabs/Lib/Zotfinger.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Chat.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Rpost.php | 3 | ||||
-rw-r--r-- | Zotlabs/Storage/Browser.php | 2 | ||||
-rw-r--r-- | Zotlabs/Web/HTTPSig.php | 2 |
11 files changed, 85 insertions, 39 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 190777b5f..7089f043c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -120,6 +120,7 @@ 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]); } @@ -142,9 +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('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); } @@ -152,6 +158,8 @@ class Activity { logger('fetch failed: ' . $url); logger($x['body']); } + + return null; } @@ -544,7 +552,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($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'])); @@ -1370,7 +1378,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 +1609,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 +1619,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 +1647,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 +2301,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']; @@ -2344,7 +2345,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; } @@ -2386,7 +2387,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']); @@ -2899,6 +2900,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 +3262,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 @@ -3378,7 +3388,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; @@ -4045,6 +4055,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) 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; } 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..e812dbd92 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,19 @@ class Libzot { return; } - $r = Activity::get_actor_hublocs($AS->actor['id']); + $author_url = $AS->actor['id']; + + if ($AS->type === 'Announce') { + $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); } } @@ -1448,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' @@ -1829,6 +1836,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'])) { @@ -2013,7 +2025,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/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 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. diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php index fa57ab56d..ccf64d6d1 100644 --- a/Zotlabs/Lib/Zotfinger.php +++ b/Zotlabs/Lib/Zotfinger.php @@ -35,9 +35,13 @@ 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)); + logger('fetch: ' . print_r($x,true), LOGGER_DATA); if (in_array(intval($x['return_code']), [ 404, 410 ]) && $recurse) { @@ -74,7 +78,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; } 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'); 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 = ''; 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, 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) { |