diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 3 | ||||
-rw-r--r-- | Zotlabs/Daemon/Onepoll.php | 8 | ||||
-rw-r--r-- | Zotlabs/Lib/Activity.php | 38 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 13 | ||||
-rw-r--r-- | Zotlabs/Module/Uexport.php | 7 |
5 files changed, 56 insertions, 13 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 78e116d68..02a0e155f 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -347,7 +347,6 @@ class Notifier { return; } - if ($target_item['mid'] === $target_item['parent_mid']) { $parent_item = $target_item; $top_level_post = true; @@ -381,7 +380,7 @@ class Notifier { $encoded_item = encode_item($target_item); // Re-use existing signature unless the activity type changed to a Tombstone, which won't verify. - $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item, 'activitystreams', 'signed_data')); + $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item, 'activitypub', 'signed_data')); if ($m) { $activity = json_decode($m, true); diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index 85394c8d0..598cf28e4 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -23,9 +23,15 @@ class Onepoll { return; } + $sql_extra = ''; + $allow_feeds = get_config('system', 'feed_contacts'); + if(!$allow_feeds) { + $sql_extra = ' and abook_feed = 0 '; + } + $contacts = q("SELECT abook.*, xchan.*, account.* FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan - where abook_id = %d + where abook_id = %d $sql_extra and abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0 AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d0799bb66..5fefb2979 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -434,7 +434,7 @@ class Activity { $ret['published'] = datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME); if ($i['created'] !== $i['edited']) $ret['updated'] = datetime_convert('UTC', 'UTC', $i['edited'], ATOM_TIME); - if ($i['expires'] <= NULL_DATE) { + if ($i['expires'] > NULL_DATE) { $ret['expires'] = datetime_convert('UTC', 'UTC', $i['expires'], ATOM_TIME); } @@ -461,7 +461,7 @@ class Activity { $ret['directMessage'] = true; } - if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] !== NULL_DATE) { + if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] > NULL_DATE) { if ($ret['commentPolicy']) { $ret['commentPolicy'] .= ' '; } @@ -1120,6 +1120,34 @@ class Activity { return $ret; } + static function encode_item_object($item, $elm = 'obj') { + $ret = []; + + if ($item[$elm]) { + if (! is_array($item[$elm])) { + $item[$elm] = json_decode($item[$elm],true); + } + if ($item[$elm]['type'] === ACTIVITY_OBJ_PHOTO) { + $item[$elm]['id'] = $item['mid']; + } + + $obj = self::encode_object($item[$elm]); + if ($obj) + return $obj; + else + return []; + } + else { + $obj = self::encode_item($item); + if ($obj) + return $obj; + else + return []; + } + + } + + static function activity_mapper($verb) { if (strpos($verb, '/') === false) { @@ -3303,17 +3331,17 @@ class Activity { $ret = false; foreach ($attach as $a) { - if (strpos($a['type'], 'image') !== false) { + if (array_key_exists('type',$a) && stripos($a['type'], 'image') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[img]' . $a['href'] . '[/img]'; } } - if (array_key_exists('type', $a) && strpos($a['type'], 'video') === 0) { + if (array_key_exists('type', $a) && stripos($a['type'], 'video') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[video]' . $a['href'] . '[/video]'; } } - if (array_key_exists('type', $a) && strpos($a['type'], 'audio') === 0) { + if (array_key_exists('type', $a) && stripos($a['type'], 'audio') !== false) { if (self::media_not_in_body($a['href'], $body)) { $ret .= "\n\n" . '[audio]' . $a['href'] . '[/audio]'; } diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 45d536638..6aa49c5a7 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1268,8 +1268,13 @@ class Libzot { } } } + if ($AS->data['signed_data']) { - IConfig::Set($arr, 'activitystreams', 'signed_data', $AS->data['signed_data'], false); + IConfig::Set($arr, 'activitypub', 'signed_data', $AS->data['signed_data'], false); + $j = json_decode($AS->data['signed_data'], true); + if ($j) { + IConfig::Set($arr, 'activitypub', 'rawmsg', json_encode(JSalmon::unpack($j['data'])), true); + } } logger('Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); @@ -1953,7 +1958,11 @@ class Libzot { } if ($AS->data['signed_data']) { - IConfig::Set($arr, 'activitystreams', 'signed_data', $AS->data['signed_data'], false); + IConfig::Set($arr, 'activitypub', 'signed_data', $AS->data['signed_data'], false); + $j = json_decode($AS->data['signed_data'], true); + if ($j) { + IConfig::Set($arr, 'activitypub', 'rawmsg', json_encode(JSalmon::unpack($j['data'])), true); + } } logger('FOF Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); diff --git a/Zotlabs/Module/Uexport.php b/Zotlabs/Module/Uexport.php index 3d1587b87..55c316317 100644 --- a/Zotlabs/Module/Uexport.php +++ b/Zotlabs/Module/Uexport.php @@ -17,6 +17,7 @@ class Uexport extends Controller { if(argc() > 1) { $sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : ''); + $zap_compat = (($_REQUEST['zap_compat']) ? intval($_REQUEST['zap_compat']) : false); $channel = App::get_channel(); @@ -32,12 +33,12 @@ class Uexport extends Controller { header('content-disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . (($month) ? '-' . $month : '') . (($_REQUEST['sections']) ? '-' . $_REQUEST['sections'] : '') . '.json"' ); if($year) { - echo json_encode(identity_export_year(local_channel(),$year,$month)); + echo json_encode(identity_export_year(local_channel(),$year,$month, $zap_compat)); killme(); } if(argc() > 1 && argv(1) === 'basic') { - echo json_encode(identity_basic_export(local_channel(),$sections)); + echo json_encode(identity_basic_export(local_channel(),$sections, $zap_compat)); killme(); } @@ -46,7 +47,7 @@ class Uexport extends Controller { if(argc() > 1 && argv(1) === 'complete') { $sections = get_default_export_sections(); $sections[] = 'items'; - echo json_encode(identity_basic_export(local_channel(),$sections)); + echo json_encode(identity_basic_export(local_channel(),$sections, $zap_compat)); killme(); } } |