Merge branch 'dev' of ../p3 into dev

This commit is contained in:
nobody 2021-04-12 18:23:45 -07:00
commit 0c9b9191d1
6 changed files with 41 additions and 14 deletions

View file

@ -1854,7 +1854,7 @@ class Activity {
if ($abconfig) { if ($abconfig) {
$clone['abconfig'] = $abconfig; $clone['abconfig'] = $abconfig;
} }
Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => array($clone) ] ); Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => [ $clone ] ] );
} }
} }

View file

@ -341,7 +341,7 @@ class ActivityStreams {
function get_actor($property,$base='',$namespace = '') { function get_actor($property,$base='',$namespace = '') {
$x = $this->get_property_obj($property, $base, $namespace); $x = $this->get_property_obj($property, $base, $namespace);
if ($this->is_url($x)) { if (self::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 // from cached data - don't refetch it from the network
@ -380,7 +380,7 @@ class ActivityStreams {
function get_compound_property($property, $base = '', $namespace = '', $first = false) { function get_compound_property($property, $base = '', $namespace = '', $first = false) {
$x = $this->get_property_obj($property, $base, $namespace); $x = $this->get_property_obj($property, $base, $namespace);
if ($this->is_url($x)) { if (self::is_url($x)) {
$y = $this->fetch_property($x); $y = $this->fetch_property($x);
if (is_array($y)) { if (is_array($y)) {
$x = $y; $x = $y;
@ -420,7 +420,7 @@ class ActivityStreams {
* @return boolean * @return boolean
*/ */
function is_url($url) { static public function is_url($url) {
if (($url) && (! is_array($url)) && ((strpos($url, 'http') === 0) || (strpos($url,'x-zot') === 0) || (strpos($url,'bear') === 0))) { if (($url) && (! is_array($url)) && ((strpos($url, 'http') === 0) || (strpos($url,'x-zot') === 0) || (strpos($url,'bear') === 0))) {
return true; return true;
} }

View file

@ -481,6 +481,13 @@ class Libsync {
foreach ($arr['abook'] as $abook) { foreach ($arr['abook'] as $abook) {
// this is here for debugging so we can find the issue source
if (! is_array($abook)) {
btlogger('abook is not an array');
continue;
}
$abconfig = null; $abconfig = null;
if (array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig'])) { if (array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig'])) {

View file

@ -513,11 +513,11 @@ class Libzot {
unset($new_connection[0]['abook_id']); unset($new_connection[0]['abook_id']);
unset($new_connection[0]['abook_account']); unset($new_connection[0]['abook_account']);
unset($new_connection[0]['abook_channel']); unset($new_connection[0]['abook_channel']);
$abconfig = load_abconfig($channel['channel_id'],$new_connection['abook_xchan']); $abconfig = load_abconfig($channel['channel_id'],$new_connection[0]['abook_xchan']);
if ($abconfig) { if ($abconfig) {
$new_connection['abconfig'] = $abconfig; $new_connection[0]['abconfig'] = $abconfig;
} }
Libsync::build_sync_packet($channel['channel_id'], array('abook' => $new_connection)); Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => $new_connection ]);
} }
} }

View file

@ -106,12 +106,16 @@ class Queue {
static function insert($arr) { static function insert($arr) {
logger('insert: ' . print_r($arr,true), LOGGER_DATA);
// do not queue anything with no destination // do not queue anything with no destination
if(! (array_key_exists('posturl',$arr) && trim($arr['posturl']))) { if (! (array_key_exists('posturl',$arr) && trim($arr['posturl']))) {
logger('no destination');
return false; return false;
} }
$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority, $x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority,
outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg ) outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )
values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )", values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )",
@ -235,7 +239,13 @@ class Queue {
logger('missing channel: ' . $outq['outq_channel']); logger('missing channel: ' . $outq['outq_channel']);
return; return;
} }
if (! ActivityStreams::is_url($outq['outq_posturl'])) {
logger('fetch item is not url: ' . $outq['outq_posturl']);
self::remove($outq['outq_hash']);
return;
}
$j = Activity::fetch($outq['outq_posturl'],$channel); $j = Activity::fetch($outq['outq_posturl'],$channel);
if ($j) { if ($j) {
$AS = new ActivityStreams($j, null, true); $AS = new ActivityStreams($j, null, true);
@ -243,7 +253,8 @@ class Queue {
if (ActivityStreams::is_an_actor($AS->data['type'])) { if (ActivityStreams::is_an_actor($AS->data['type'])) {
Activity::actor_store($AS->data['id'],$AS->data); Activity::actor_store($AS->data['id'],$AS->data);
} }
if (strpos($AS->data['type'],'Collection')) { if (strpos($AS->data['type'],'Collection') !== false) {
// we are probably fetching a collection already - and do not support collection recursion at this time
self::remove($outq['outq_hash']); self::remove($outq['outq_hash']);
return; return;
} }

View file

@ -6,6 +6,7 @@ use Zotlabs\Web\Controller;
use Zotlabs\Lib\Activity; use Zotlabs\Lib\Activity;
use Zotlabs\Lib\ActivityStreams; use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\ASCollection; use Zotlabs\Lib\ASCollection;
use Zotlabs\Lib\Queue;
use Zotlabs\Daemon\Run; use Zotlabs\Daemon\Run;
require_once("include/bbcode.php"); require_once("include/bbcode.php");
@ -66,7 +67,8 @@ class Search extends Controller {
// ActivityStreams object fetches from the navbar // ActivityStreams object fetches from the navbar
if (local_channel() && strpos($search,'https://') === 0) { if (local_channel() && strpos($search,'https://') === 0 && (! $update) && (! $load)) {
logger('searching for ActivityPub');
$channel = App::get_channel(); $channel = App::get_channel();
$hash = EMPTY_STR; $hash = EMPTY_STR;
$j = Activity::fetch($search,$channel); $j = Activity::fetch($search,$channel);
@ -79,8 +81,8 @@ class Search extends Controller {
if ($AS->is_valid() && isset($AS->data['type'])) { if ($AS->is_valid() && isset($AS->data['type'])) {
if (is_array($AS->obj)) { if (is_array($AS->obj)) {
// matches Collection and orderedCollection // matches Collection and orderedCollection
if (isset($AS->obj['type']) && strpos($AS->obj['type'],'Collection')) { if (isset($AS->obj['type']) && strpos($AS->obj['type'],'Collection') !== false) {
// Collections are awkward to process because they can be huge. // Collections are awkward to process because they can be huge.
// Our strategy is to limit a navbar search to 100 Collection items // Our strategy is to limit a navbar search to 100 Collection items
// and only fetch the first 10 conversations in the foreground. // and only fetch the first 10 conversations in the foreground.
@ -90,22 +92,28 @@ class Search extends Controller {
// are fetched in the background while you're looking at the first ones. // are fetched in the background while you're looking at the first ones.
$max = intval(get_config('system','max_imported_search_collection',100)); $max = intval(get_config('system','max_imported_search_collection',100));
if (intval($max)) { if (intval($max)) {
$obj = new ASCollection($search, $channel, 0, $max); $obj = new ASCollection($search, $channel, 0, $max);
$messages = $obj->get(); $messages = $obj->get();
// logger('received: ' . print_r($messages,true));
$author = null; $author = null;
if ($messages) { if ($messages) {
logger('received ' . count($messages) . ' items from collection.', LOGGER_DEBUG);
$processed = 0; $processed = 0;
foreach ($messages as $message) { foreach ($messages as $message) {
$processed ++; $processed ++;
// only process the first several items in the foreground and // only process the first several items in the foreground and
// queue the remainder. // queue the remainder.
if ($processed > 10) { if ($processed > 10) {
$fetch_url = ((is_string($message)) ? $message : EMPTY_STR); $fetch_url = ((is_string($message)) ? $message : EMPTY_STR);
$fetch_url = ((is_array($message) && array_key_exists('id',$message)) ? $message_id : $fetch_url); $fetch_url = ((is_array($message) && array_key_exists('id',$message)) ? $message['id'] : $fetch_url);
if (! $fetch_url) { if (! $fetch_url) {
continue; continue;
} }
$hash = new_uuid(); $hash = new_uuid();
Queue::insert( Queue::insert(
[ [
@ -120,6 +128,7 @@ class Search extends Controller {
); );
continue; continue;
} }
if (is_string($message)) { if (is_string($message)) {
$message = Activity::fetch($message,App::get_channel()); $message = Activity::fetch($message,App::get_channel());
} }