aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php20
-rw-r--r--Zotlabs/Lib/Connect.php6
-rw-r--r--Zotlabs/Lib/Enotify.php2
-rw-r--r--Zotlabs/Lib/Libsync.php8
-rw-r--r--Zotlabs/Lib/Libzot.php56
-rw-r--r--Zotlabs/Lib/ThreadItem.php6
6 files changed, 50 insertions, 48 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 1a34fdae6..963a8ff75 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1702,9 +1702,8 @@ class Activity {
);
// update existing xchan record
- q("update xchan set xchan_name = '%s', xchan_guid = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'",
+ q("update xchan set xchan_name = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'",
dbesc(escape_tags($name)),
- dbesc($url),
dbesc(escape_tags($pubkey)),
dbesc(escape_tags($webfinger_addr)),
dbescdate(datetime_convert()),
@@ -1712,8 +1711,7 @@ class Activity {
);
// update existing hubloc record
- q("update hubloc set hubloc_guid = '%s', hubloc_addr = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'",
- dbesc($url),
+ q("update hubloc set hubloc_addr = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'",
dbesc(escape_tags($webfinger_addr)),
dbesc($baseurl),
dbesc($hostname),
@@ -2208,6 +2206,8 @@ class Activity {
$s['owner_xchan'] = $act->actor['id'];
$s['author_xchan'] = $act->actor['id'];
+ $content = [];
+
if (is_array($act->obj)) {
$content = self::get_content($act->obj);
}
@@ -2280,10 +2280,10 @@ class Activity {
$mention = self::get_actor_bbmention($obj_actor['id']);
if ($act->type === 'Like') {
- $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'];
+ $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? '';
}
if ($act->type === 'Dislike') {
- $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'];
+ $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? '';
}
// handle event RSVPs
@@ -2791,11 +2791,7 @@ class Activity {
call_hooks('decode_note', $hookinfo);
- $s = $hookinfo['s'];
-
-
-
- return $s;
+ return $hookinfo['s'];
}
@@ -3823,7 +3819,7 @@ class Activity {
}
if (array_path_exists('source/mediaType', $act) && array_path_exists('source/content', $act)) {
- if ($act['source']['mediaType'] === 'text/bbcode') {
+ if (in_array($act['source']['mediaType'], ['text/bbcode', 'text/x-multicode'])) {
$content['bbcode'] = purify_html($act['source']['content']);
}
}
diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php
index 6f10bbbae..4570627fc 100644
--- a/Zotlabs/Lib/Connect.php
+++ b/Zotlabs/Lib/Connect.php
@@ -69,7 +69,7 @@ class Connect {
$xchan_hash = '';
$sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : '');
- $r = q("select * from xchan where ( xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s') $sql_options ",
+ $r = q("SELECT * FROM xchan LEFT JOIN hubloc ON xchan_hash = hubloc_hash WHERE ( xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s') $sql_options ORDER BY hubloc_id DESC",
dbesc($url),
dbesc($url),
dbesc($url)
@@ -80,7 +80,7 @@ class Connect {
// reset results to the best record or the first if we don't have the best
// note: this is a single record and not an array of results
- $r = Libzot::zot_record_preferred($r,'xchan_network');
+ $r = Libzot::zot_record_preferred($r, 'xchan_network');
}
@@ -120,7 +120,7 @@ class Connect {
// convert to a single record (once again preferring a zot solution in the case of multiples)
if ($r) {
- $r = Libzot::zot_record_preferred($r,'xchan_network');
+ $r = Libzot::zot_record_preferred($r, 'xchan_network');
}
}
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 67efe5e9d..2015b260d 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -869,7 +869,7 @@ class Enotify {
$x = array(
'notify_link' => $item['llink'],
'name' => $item[$who]['xchan_name'],
- 'addr' => (($item[$who]['xchan_addr']) ? $item[$who]['xchan_addr'] : $item[$who]['xchan_url']),
+ 'addr' => $item[$who]['xchan_addr'] ?? $item[$who]['xchan_url'],
'url' => $item[$who]['xchan_url'],
'photo' => $item[$who]['xchan_photo_s'],
'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])),
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index 914969d97..9851ce52a 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -202,6 +202,8 @@ class Libsync {
$channel = $r[0];
+ $mid = 'sync';
+
$DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>');
$max_friends = service_class_fetch($channel['channel_id'], 'total_channels');
@@ -293,8 +295,10 @@ class Libsync {
if (array_key_exists('event_item', $arr) && $arr['event_item'])
sync_items($channel, $arr['event_item'], ((array_key_exists('relocate', $arr)) ? $arr['relocate'] : null));
- if (array_key_exists('item', $arr) && $arr['item'])
+ if (array_key_exists('item', $arr) && $arr['item']) {
sync_items($channel, $arr['item'], ((array_key_exists('relocate', $arr)) ? $arr['relocate'] : null));
+ $mid = $arr['item']['mid'] . '#sync';
+ }
// deprecated, maintaining for a few months for upward compatibility
// this should sync webpages, but the logic is a bit subtle
@@ -740,7 +744,7 @@ class Libsync {
*/
call_hooks('process_channel_sync_delivery', $addon);
- $DR = new DReport(z_root(), $d, $d, 'sync', 'channel sync delivered');
+ $DR = new DReport(z_root(), $d, $d, $mid, 'channel sync processed');
$DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>');
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index cbb614429..b0d33e055 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1172,10 +1172,14 @@ class Libzot {
return;
}
if (is_array($AS->obj)) {
- $arr = Activity::decode_note($AS);
+ $item = Activity::decode_note($AS);
+ if (!$item) {
+ logger('Could not decode activity: ' . print_r($AS, true));
+ return;
+ }
}
else {
- $arr = [];
+ $item = [];
}
logger($AS->debug(), LOGGER_DATA);
@@ -1260,15 +1264,15 @@ class Libzot {
if ($r) {
$r = self::zot_record_preferred($r);
- $arr['author_xchan'] = $r['hubloc_hash'];
+ $item['author_xchan'] = $r['hubloc_hash'];
}
- if (! $arr['author_xchan']) {
+ if (! $item['author_xchan']) {
logger('No author!');
return;
}
- $arr['owner_xchan'] = $env['sender'];
+ $item['owner_xchan'] = $env['sender'];
if(filter_var($env['sender'], FILTER_VALIDATE_URL)) {
// in individual delivery, change owner if needed
@@ -1277,67 +1281,67 @@ class Libzot {
);
if ($s) {
- $arr['owner_xchan'] = $s[0]['hubloc_hash'];
+ $item['owner_xchan'] = $s[0]['hubloc_hash'];
}
}
- if (! $arr['owner_xchan']) {
+ if (! $item['owner_xchan']) {
logger('No owner!');
return;
}
- if ($private && (!intval($arr['item_private']))) {
- $arr['item_private'] = 1;
+ if ($private && (!intval($item['item_private']))) {
+ $item['item_private'] = 1;
}
- if ($arr['mid'] === $arr['parent_mid']) {
+ if ($item['mid'] === $item['parent_mid']) {
if (is_array($AS->obj) && array_key_exists('commentPolicy', $AS->obj)) {
$p = strstr($AS->obj['commentPolicy'], 'until=');
if ($p !== false) {
$comments_closed_at = datetime_convert('UTC', 'UTC', substr($p, 6));
- if ($comments_closed_at === $arr['created']) {
- $arr['item_nocomment'] = 1;
+ if ($comments_closed_at === $item['created']) {
+ $item['item_nocomment'] = 1;
}
else {
- $arr['comments_closed'] = $comments_closed_at;
- $arr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy']));
+ $item['comments_closed'] = $comments_closed_at;
+ $aritemr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy']));
}
}
else {
- $arr['comment_policy'] = $AS->obj['commentPolicy'];
+ $item['comment_policy'] = $AS->obj['commentPolicy'];
}
}
}
if (isset($AS->meta['hubloc']) && $AS->meta['hubloc']) {
- $arr['item_verified'] = true;
+ $item['item_verified'] = true;
}
- if (!array_key_exists('comment_policy', $arr)) {
- $arr['comment_policy'] = 'authenticated';
+ if (!array_key_exists('comment_policy', $item)) {
+ $item['comment_policy'] = 'authenticated';
}
if (isset($AS->meta['signed_data']) && $AS->meta['signed_data']) {
- IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false);
+ IConfig::Set($item, 'activitypub', 'signed_data', $AS->meta['signed_data'], false);
}
- logger('Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG);
+ logger('Activity received: ' . print_r($item, true), LOGGER_DATA, LOG_DEBUG);
logger('Activity recipients: ' . print_r($deliveries, true), LOGGER_DATA, LOG_DEBUG);
$relay = (($env['type'] === 'response') ? true : false);
- $result = self::process_delivery($env['sender'], $AS, $arr, $deliveries, $relay, false, $message_request);
+ $result = self::process_delivery($env['sender'], $AS, $item, $deliveries, $relay, false, $message_request);
}
elseif ($env['type'] === 'sync') {
- // $arr = get_channelsync_elements($data);
+ // $item = get_channelsync_elements($data);
- $arr = json_decode($data, true);
+ $item = json_decode($data, true);
- logger('Channel sync received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG);
+ logger('Channel sync received: ' . print_r($item, true), LOGGER_DATA, LOG_DEBUG);
logger('Channel sync recipients: ' . print_r($deliveries, true), LOGGER_DATA, LOG_DEBUG);
if ($env['encoding'] === 'hz') {
- $result = Libsync::process_channel_sync_delivery($env['sender'], $arr, $deliveries);
+ $result = Libsync::process_channel_sync_delivery($env['sender'], $item, $deliveries);
}
else {
logger('sync packet type not supported.');
@@ -1920,7 +1924,7 @@ class Libzot {
// preserve conversations with which you are involved from expiration
- $stored = (($item_result && $item_result['item']) ? $item_result['item'] : false);
+ $stored = ((isset($item_result['item'])) ? $item_result['item'] : false);
if ((is_array($stored)) && ($stored['id'] != $stored['parent'])
&& ($stored['author_xchan'] === $channel['channel_hash'])) {
retain_item($stored['item']['parent']);
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 472e2c6db..6ca952969 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -84,10 +84,8 @@ class ThreadItem {
public function get_template_data($conv_responses, $thread_level=1, $conv_flags = []) {
- $result = array();
-
- $item = $this->get_data();
-
+ $result = [];
+ $item = $this->get_data();
$commentww = '';
$sparkle = '';
$buttons = '';