aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-10 18:05:26 +0000
committerMario <mario@mariovavti.com>2022-10-10 18:05:26 +0000
commitef2448e17e742e7dcef458993bce1e0a29756aa7 (patch)
treed23c62753abbb42e7bb742f2d44d09321b6f2eee /Zotlabs/Lib
parent6ab65519a0fc3e55ad5f32ce1641190ef609a4e2 (diff)
parent99a5cf1ad4660a31af6c03e5a1abc3d374f82c78 (diff)
downloadvolse-hubzilla-ef2448e17e742e7dcef458993bce1e0a29756aa7.tar.gz
volse-hubzilla-ef2448e17e742e7dcef458993bce1e0a29756aa7.tar.bz2
volse-hubzilla-ef2448e17e742e7dcef458993bce1e0a29756aa7.zip
Merge branch '7.8RC'7.8
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php142
-rw-r--r--Zotlabs/Lib/ActivityStreams.php17
-rw-r--r--Zotlabs/Lib/Apps.php7
-rw-r--r--Zotlabs/Lib/Enotify.php4
-rw-r--r--Zotlabs/Lib/Libzot.php57
-rw-r--r--Zotlabs/Lib/Queue.php25
-rw-r--r--Zotlabs/Lib/System.php16
-rw-r--r--Zotlabs/Lib/ThreadItem.php62
-rw-r--r--Zotlabs/Lib/Webfinger.php4
9 files changed, 201 insertions, 133 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 7840e9999..4ff13bc04 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -646,15 +646,15 @@ class Activity {
$ret = [];
- if (is_array($item['attachment']) && $item['attachment']) {
+ if (isset($item['attachment'])) {
$ptr = $item['attachment'];
if (!array_key_exists(0, $ptr)) {
$ptr = [$ptr];
}
foreach ($ptr as $att) {
$entry = [];
- if ($att['type'] === 'PropertyValue') {
- if (array_key_exists('name', $att) && $att['name']) {
+ if (isset($att['type']) && $att['type'] === 'PropertyValue') {
+ if (isset($att['name'])) {
$key = explode('.', $att['name']);
if (count($key) === 3 && $key[0] === 'zot') {
$entry['cat'] = $key[1];
@@ -674,7 +674,7 @@ class Activity {
$ret = [];
- if (array_key_exists('attachment', $item) && is_array($item['attachment'])) {
+ if (isset($item['attachment'])) {
$ptr = $item['attachment'];
if (!array_key_exists(0, $ptr)) {
$ptr = [$ptr];
@@ -1523,22 +1523,31 @@ class Activity {
}
- static function actor_store($url, $person_obj, $force = false) {
+ 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;
+ }
if (!is_array($person_obj)) {
return;
}
/* not implemented
- 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);
- ActivityPub::move($person_obj['id'],$tgt);
- }
- return;
- }
+ 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);
+ ActivityPub::move($person_obj['id'],$tgt);
+ }
+ return;
+ }
*/
+
$ap_hubloc = null;
$hublocs = self::get_actor_hublocs($url);
@@ -1600,7 +1609,7 @@ class Activity {
$m = parse_url($url);
if ($m) {
$hostname = $m['host'];
- $baseurl = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
+ $baseurl = $m['scheme'] . '://' . $m['host'] . ((isset($m['port'])) ? ':' . $m['port'] : '');
$site_url = $m['scheme'] . '://' . $m['host'];
}
@@ -1609,7 +1618,7 @@ class Activity {
}
$icon = z_root() . '/' . get_default_profile_photo(300);
- if ($person_obj['icon']) {
+ if (isset($person_obj['icon'])) {
if (is_array($person_obj['icon'])) {
if (array_key_exists('url', $person_obj['icon'])) {
$icon = $person_obj['icon']['url'];
@@ -1715,7 +1724,7 @@ class Activity {
'xchan_guid' => $url,
'xchan_pubkey' => escape_tags($pubkey),
'xchan_addr' => $webfinger_addr,
- 'xchan_url' => escape_tags($profile),
+ 'xchan_url' => $profile,
'xchan_name' => escape_tags($name),
'xchan_name_date' => datetime_convert(),
'xchan_network' => 'activitypub'
@@ -1791,9 +1800,13 @@ class Activity {
// sort function width decreasing
static function vid_sort($a, $b) {
- if ($a['width'] === $b['width'])
+ $a_width = $a['width'] ?? 0;
+ $b_width = $b['width'] ?? 0;
+
+ if ($a_width === $b_width)
return 0;
- return (($a['width'] > $b['width']) ? -1 : 1);
+
+ return (($a_width > $b_width) ? -1 : 1);
}
static function create_note($channel, $observer_hash, $act) {
@@ -2239,11 +2252,11 @@ class Activity {
// over-ride the object timestamp with the activity
- if ($act->data['published']) {
+ if (isset($act->data['published'])) {
$s['created'] = datetime_convert('UTC', 'UTC', $act->data['published']);
}
- if ($act->data['updated']) {
+ if (isset($act->data['updated'])) {
$s['edited'] = datetime_convert('UTC', 'UTC', $act->data['updated']);
}
@@ -2277,12 +2290,6 @@ class Activity {
}
}
- if ($act->type === 'Announce') {
- $s['author_xchan'] = $obj_actor['id'];
- $s['mid'] = $act->obj['id'];
- $s['parent_mid'] = $act->obj['id'];
- }
-
if ($act->type === 'emojiReaction') {
$content['content'] = (($act->tgt && $act->tgt['type'] === 'Image') ? '[img=32x32]' . $act->tgt['url'] . '[/img]' : '&#x' . $act->tgt['name'] . ';');
}
@@ -2461,12 +2468,17 @@ class Activity {
$s['comments_closed'] = datetime_convert('UTC', 'UTC', $act->obj['closed']);
}
+ if (!$response_activity) {
+ if ($act->type === 'Announce') {
+ $s['author_xchan'] = self::get_attributed_to_actor_url($act);
+ $s['mid'] = $act->obj['id'];
+ $s['parent_mid'] = $act->obj['id'];
+ }
- // 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
- // standard content region
+ // 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
+ // standard content region
- if (!$response_activity) {
if ($act->obj['type'] === 'Video') {
$vtypes = [
@@ -2673,15 +2685,14 @@ class Activity {
}
}
- if (!$s['plink']) {
+ if (!(isset($s['plink']) && $s['plink'])) {
$s['plink'] = $s['mid'];
}
// assume this is private unless specifically told otherwise.
$s['item_private'] = 1;
-
- if ($act->recips && in_array(ACTIVITY_PUBLIC_INBOX, $act->recips)) {
+ if ($act->recips && (in_array(ACTIVITY_PUBLIC_INBOX, $act->recips) || in_array('Public', $act->recips) || in_array('as:Public', $act->recips))) {
$s['item_private'] = 0;
}
@@ -2699,7 +2710,7 @@ class Activity {
// This is a zot6 packet and the raw activitypub or diaspora message json
// is possibly available in the attachement.
- if (array_key_exists('signed', $raw_arr) && is_array($act->data['attachment'])) {
+ if (array_key_exists('signed', $raw_arr) && isset($act->data['attachment']) && is_array($act->data['attachment'])) {
foreach($act->data['attachment'] as $a) {
if (
isset($a['type']) && $a['type'] === 'PropertyValue' &&
@@ -2719,7 +2730,7 @@ class Activity {
}
// old style: can be removed after most hubs are on 7.0.2
- elseif (array_key_exists('signed', $raw_arr) && is_array($act->obj) && is_array($act->obj['attachment'])) {
+ elseif (array_key_exists('signed', $raw_arr) && is_array($act->obj) && isset($act->data['attachment']) && is_array($act->obj['attachment'])) {
foreach($act->obj['attachment'] as $a) {
if (
isset($a['type']) && $a['type'] === 'PropertyValue' &&
@@ -2763,6 +2774,7 @@ class Activity {
set_iconfig($s, 'activitypub', 'recips', $act->raw_recips);
+
$hookinfo = [
'act' => $act,
's' => $s
@@ -2772,6 +2784,8 @@ class Activity {
$s = $hookinfo['s'];
+
+
return $s;
}
@@ -2866,7 +2880,7 @@ class Activity {
// The $item['item_fetched'] flag is set in fetch_and_store_parents().
// In this case we should check against author permissions because sender is not owner.
- if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) {
+ if (perm_is_allowed($channel['channel_id'], ((isset($item['item_fetched']) && $item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) {
$allowed = true;
}
// TODO: not implemented
@@ -3005,30 +3019,34 @@ class Activity {
dbesc($item['parent_mid']),
intval($item['uid'])
);
+
if (!$parent) {
if (!plugin_is_installed('pubcrawl')) {
return;
}
else {
$fetch = false;
+
// TODO: debug
// if (perm_is_allowed($channel['channel_id'],$observer_hash,'send_stream') && (PConfig::Get($channel['channel_id'],'system','hyperdrive',true) || $act->type === 'Announce')) {
if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || $is_sys_channel) {
$fetch = (($fetch_parents) ? self::fetch_and_store_parents($channel, $observer_hash, $item, $force) : false);
}
+
if ($fetch) {
$parent = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($item['parent_mid']),
intval($item['uid'])
);
}
- else {
- logger('no parent');
- return;
- }
}
}
+ if (!$parent) {
+ logger('no parent');
+ return;
+ }
+
if ($parent[0]['parent_mid'] !== $item['parent_mid']) {
$item['thr_parent'] = $item['parent_mid'];
}
@@ -3875,6 +3893,19 @@ class Activity {
return $hookdata['actor'];
}
+ static function get_unknown_actor($act) {
+
+ // try other get_actor providers (e.g. diaspora)
+ $hookdata = [
+ 'activity' => $act,
+ 'actor' => null
+ ];
+
+ call_hooks('get_actor_provider', $hookdata);
+
+ return $hookdata['actor'];
+ }
+
static function get_actor_hublocs($url, $options = 'all') {
switch ($options) {
@@ -3966,4 +3997,35 @@ class Activity {
return $ret;
}
+ static function get_attributed_to_actor_url($act) {
+
+ $url = '';
+
+ if (!isset($act->obj['attributedTo'])) {
+ return $url;
+ }
+
+ if (is_string($act->obj['attributedTo'])) {
+ $url = $act->obj['attributedTo'];
+ }
+
+ if (is_array($act->obj['attributedTo'])) {
+ foreach($act->obj['attributedTo'] as $a) {
+ if (is_array($a) && isset($a['type']) && $a['type'] === 'Person') {
+ if (isset($a['id'])) {
+ $url = $a['id'];
+ break;
+ }
+ }
+ elseif (is_string($a)) {
+ $url = $a;
+ break;
+ }
+ }
+ }
+
+ return $url;
+
+ }
+
}
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index e77b501b3..a07fdacb7 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -116,17 +116,17 @@ class ActivityStreams {
$this->obj['object'] = $this->get_compound_property($this->obj['object']);
}
- if ($this->obj && is_array($this->obj) && $this->obj['actor'])
+ 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) && $this->tgt['actor'])
+ if ($this->tgt && is_array($this->tgt) && isset($this->tgt['actor']))
$this->tgt['actor'] = $this->get_actor('actor', $this->tgt);
$this->parent_id = $this->get_property_obj('inReplyTo');
- if ((!$this->parent_id) && is_array($this->obj)) {
+ if ((!$this->parent_id) && is_array($this->obj) && isset($this->obj['inReplyTo'])) {
$this->parent_id = $this->obj['inReplyTo'];
}
- if ((!$this->parent_id) && is_array($this->obj)) {
+ if ((!$this->parent_id) && is_array($this->obj) && isset($this->obj['id'])) {
$this->parent_id = $this->obj['id'];
}
}
@@ -294,7 +294,7 @@ class ActivityStreams {
if (!$s) {
return false;
}
- return (in_array($s, ['Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject', 'emojiReaction', 'EmojiReaction', 'EmojiReact']));
+ return (in_array($s, ['Like', 'Dislike', 'Flag', 'Block', 'Accept', 'Reject', 'TentativeAccept', 'TentativeReject', 'emojiReaction', 'EmojiReaction', 'EmojiReact']));
}
/**
@@ -308,20 +308,25 @@ class ActivityStreams {
function get_actor($property, $base = '', $namespace = '') {
$x = $this->get_property_obj($property, $base, $namespace);
+
if ($this->is_url($x)) {
$y = Activity::get_cached_actor($x);
if ($y) {
return $y;
}
}
+
$actor = $this->get_compound_property($property, $base, $namespace, true);
+
if (is_array($actor) && self::is_an_actor($actor['type'])) {
if (array_key_exists('id', $actor) && (!array_key_exists('inbox', $actor))) {
$actor = $this->fetch_property($actor['id']);
}
return $actor;
}
- return null;
+
+ return Activity::get_unknown_actor($this->data);
+
}
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 98ebc546a..a29992bbc 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -521,8 +521,13 @@ class Apps {
$hosturl = '';
if(local_channel()) {
- if(self::app_installed(local_channel(),$papp) && !$papp['deleted'])
+ if(self::app_installed(local_channel(),$papp)) {
$installed = true;
+ }
+
+ if ($installed && isset($papp['deleted']) && $papp['deleted']) {
+ $installed = false;
+ }
$hosturl = z_root() . '/';
}
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 07c426960..5a09ade90 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -815,10 +815,10 @@ class Enotify {
localize_item($item);
- if($item['shortlocalize']) {
+ if(isset($item['shortlocalize'])) {
$itemem_text = $item['shortlocalize'];
}
- elseif($item['localize']) {
+ elseif(isset($item['localize'])) {
$itemem_text = $item['localize'];
}
else {
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index ba3c642cf..6f7d74606 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -251,7 +251,7 @@ class Libzot {
$url = null;
- if ($them['hubloc_id_url']) {
+ if (isset($them['hubloc_id_url']) && $them['hubloc_id_url']) {
$url = $them['hubloc_id_url'];
}
else {
@@ -304,8 +304,14 @@ class Libzot {
$record = Zotfinger::exec($url, $channel);
+ if (!$record) {
+ return false;
+ }
+
// Check the HTTP signature
$hsig = $record['signature'];
+ $hsig_valid = false;
+
if ($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
$hsig_valid = true;
}
@@ -898,11 +904,11 @@ class Libzot {
$s = Libsync::sync_locations($arr, $arr);
if ($s) {
- if ($s['change_message'])
+ if (isset($s['change_message']))
$what .= $s['change_message'];
- if ($s['changed'])
+ if (isset($s['changed']))
$changed = $s['changed'];
- if ($s['message'])
+ if (isset($s['message']))
$ret['message'] .= $s['message'];
}
@@ -1227,7 +1233,7 @@ class Libzot {
return;
}
- $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'",
+ $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc",
dbesc($AS->actor['id'])
);
@@ -1235,7 +1241,7 @@ class Libzot {
// Author is unknown to this site. Perform channel discovery and try again.
$z = discover_by_webbie($AS->actor['id']);
if ($z) {
- $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'",
+ $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc",
dbesc($AS->actor['id'])
);
}
@@ -1255,7 +1261,7 @@ class Libzot {
if(filter_var($env['sender'], FILTER_VALIDATE_URL)) {
// in individual delivery, change owner if needed
- $s = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
+ $s = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1",
dbesc($env['sender'])
);
@@ -1738,7 +1744,7 @@ class Libzot {
if (in_array('undefined', $existing_route) || $last_hop == 'undefined' || $sender == 'undefined')
$last_hop = '';
- $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender;
+ $current_route = ((isset($arr['route']) && $arr['route']) ? $arr['route'] . ',' : '') . $sender;
if ($last_hop && $last_hop != $sender) {
logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG);
@@ -1763,7 +1769,7 @@ class Libzot {
dbesc($arr['author_xchan'])
);
- if (intval($arr['item_deleted'])) {
+ if (isset($arr['item_deleted']) && $arr['item_deleted']) {
// remove_community_tag is a no-op if this isn't a community tag activity
self::remove_community_tag($sender, $arr, $channel['channel_id']);
@@ -2014,11 +2020,11 @@ class Libzot {
$arr['owner_xchan'] = $a['signature']['signer'];
}
- if ($AS->meta['hubloc'] || $arr['author_xchan'] === $arr['owner_xchan']) {
+ if (isset($AS->meta['hubloc']) || $arr['author_xchan'] === $arr['owner_xchan']) {
$arr['item_verified'] = true;
}
- if ($AS->meta['signed_data']) {
+ if (isset($AS->meta['signed_data'])) {
IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false);
$j = json_decode($AS->meta['signed_data'], true);
if ($j) {
@@ -2512,14 +2518,14 @@ class Libzot {
$access_policy = ACCESS_PRIVATE;
}
- $directory_url = htmlspecialchars((string)$arr['directory_url'], ENT_COMPAT, 'UTF-8', false);
- $url = htmlspecialchars((string)strtolower($arr['url']), ENT_COMPAT, 'UTF-8', false);
- $sellpage = htmlspecialchars((string)$arr['sellpage'], ENT_COMPAT, 'UTF-8', false);
- $site_location = htmlspecialchars((string)$arr['location'], ENT_COMPAT, 'UTF-8', false);
- $site_realm = htmlspecialchars((string)$arr['realm'], ENT_COMPAT, 'UTF-8', false);
- $site_project = htmlspecialchars((string)$arr['project'], ENT_COMPAT, 'UTF-8', false);
- $site_crypto = ((array_key_exists('encryption', $arr) && is_array($arr['encryption'])) ? htmlspecialchars((string)implode(',', $arr['encryption']), ENT_COMPAT, 'UTF-8', false) : '');
- $site_version = ((array_key_exists('version', $arr)) ? htmlspecialchars((string)$arr['version'], ENT_COMPAT, 'UTF-8', false) : '');
+ $directory_url = ((isset($arr['directory_url'])) ? htmlspecialchars($arr['directory_url'], ENT_COMPAT, 'UTF-8', false) : '');
+ $url = ((isset($arr['url'])) ? htmlspecialchars(strtolower($arr['url']), ENT_COMPAT, 'UTF-8', false) : '');
+ $sellpage = ((isset($arr['sellpage'])) ? htmlspecialchars($arr['sellpage'], ENT_COMPAT, 'UTF-8', false) : '');
+ $site_location = ((isset($arr['location'])) ? htmlspecialchars($arr['location'], ENT_COMPAT, 'UTF-8', false) : '');
+ $site_realm = ((isset($arr['realm'])) ? htmlspecialchars($arr['realm'], ENT_COMPAT, 'UTF-8', false) : '');
+ $site_project = ((isset($arr['project'])) ? htmlspecialchars($arr['project'], ENT_COMPAT, 'UTF-8', false) : '');
+ $site_crypto = ((isset($arr['encryption']) && is_array($arr['encryption'])) ? htmlspecialchars(implode(',', $arr['encryption']), ENT_COMPAT, 'UTF-8', false) : '');
+ $site_version = ((isset($arr['version'])) ? htmlspecialchars($arr['version'], ENT_COMPAT, 'UTF-8', false) : '');
// You can have one and only one primary directory per realm.
// Downgrade any others claiming to be primary. As they have
@@ -2729,14 +2735,15 @@ class Libzot {
$token = ((x($arr, 'token')) ? $arr['token'] : '');
$feed = ((x($arr, 'feed')) ? intval($arr['feed']) : 0);
+ $ztarget_hash = EMPTY_STR;
+
if ($ztarget) {
- $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
+ $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1",
dbesc($ztarget)
);
if ($t) {
$ztarget_hash = $t[0]['hubloc_hash'];
-
}
else {
@@ -2744,7 +2751,6 @@ class Libzot {
// permissions we would know about them and we only want to know who they are to
// enumerate their specific permissions
- $ztarget_hash = EMPTY_STR;
}
}
@@ -2920,12 +2926,11 @@ class Libzot {
// This is a template - %s will be replaced with the follow_url we discover for the return channel.
if ($special_channel) {
- $ret['connect_url'] = (($e['xchan_connpage']) ? $e['xchan_connpage'] : z_root() . '/connect/' . $e['channel_address']);
+ $ret['connect_url'] = $e['xchan_connpage'] ?? z_root() . '/connect/' . $e['channel_address'];
}
// This is a template for our follow url, %s will be replaced with a webbie
- if (!$ret['follow_url'])
- $ret['follow_url'] = z_root() . '/follow?f=&url=%s';
+ $ret['follow_url'] = $ret['follow_url'] ?? z_root() . '/follow?f=&url=%s';
$permissions = get_all_perms($e['channel_id'], $ztarget_hash, false, false);
@@ -3194,7 +3199,7 @@ class Libzot {
}
foreach ($arr as $v) {
- if ($v[$check] === 'zot6') {
+ if (isset($v[$check]) && $v[$check] === 'zot6') {
return $v;
}
}
diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php
index 246b42667..c3f9cda20 100644
--- a/Zotlabs/Lib/Queue.php
+++ b/Zotlabs/Lib/Queue.php
@@ -110,21 +110,30 @@ class Queue {
return false;
}
+ $hash = $arr['hash'] ?? '';
+ $account_id = $arr['account_id'] ?? 0;
+ $channel_id = $arr['channel_id'] ?? 0;
+ $driver = $arr['driver'] ?? 'zot6';
+ $posturl = $arr['posturl'] ?? '';
+ $priority = $arr['priority'] ?? 0;
+ $notify = $arr['notify'] ?? '';
+ $msg = $arr['msg'] ?? '';
+
$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 )
values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )",
- dbesc($arr['hash']),
- intval($arr['account_id']),
- intval($arr['channel_id']),
- dbesc(($arr['driver']) ? $arr['driver'] : 'zot6'),
- dbesc($arr['posturl']),
+ dbesc($hash),
+ intval($account_id),
+ intval($channel_id),
+ dbesc($driver),
+ dbesc($posturl),
intval(1),
- intval(isset($arr['priority']) ? $arr['priority'] : 0),
+ intval($priority),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- dbesc($arr['notify']),
- dbesc(($arr['msg']) ? $arr['msg'] : '')
+ dbesc($notify),
+ dbesc($msg)
);
return $x;
diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php
index 3cc46fbda..087378f16 100644
--- a/Zotlabs/Lib/System.php
+++ b/Zotlabs/Lib/System.php
@@ -16,13 +16,13 @@ class System {
}
static public function get_site_name() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['sitename'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['sitename']))
return \App::$config['system']['sitename'];
return '';
}
static public function get_project_version() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['hide_version']))
return '';
if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('std_version',\App::$config['system']))
return \App::$config['system']['std_version'];
@@ -31,33 +31,33 @@ class System {
}
static public function get_update_version() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['hide_version']))
return '';
return DB_UPDATE_VERSION;
}
static public function get_notify_icon() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['email_notify_icon_url'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['email_notify_icon_url']))
return \App::$config['system']['email_notify_icon_url'];
return z_root() . DEFAULT_NOTIFY_ICON;
}
static public function get_site_icon() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['site_icon_url'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['site_icon_url']))
return \App::$config['system']['site_icon_url'];
return z_root() . DEFAULT_PLATFORM_ICON ;
}
static public function get_project_link() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_link'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['project_link']))
return \App::$config['system']['project_link'];
return 'https://hubzilla.org';
}
static public function get_project_srclink() {
- if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_srclink'])
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['project_srclink']))
return \App::$config['system']['project_srclink'];
return 'https://framagit.org/hubzilla/core.git';
}
@@ -68,7 +68,7 @@ class System {
static public function get_zot_revision() {
- $x = [ 'revision' => ZOT_REVISION ];
+ $x = [ 'revision' => ZOT_REVISION ];
call_hooks('zot_revision',$x);
return $x['revision'];
}
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index a02c1415e..8cc0f6aa5 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -98,7 +98,7 @@ class ThreadItem {
$is_item = false;
$osparkle = '';
$total_children = $this->count_descendants();
- $unseen_comments = (($item['real_uid']) ? 0 : $this->count_unseen_descendants());
+ $unseen_comments = ((isset($item['real_uid']) && $item['real_uid']) ? 0 : $this->count_unseen_descendants());
$conv = $this->get_conversation();
$observer = $conv->get_observer();
@@ -148,7 +148,7 @@ class ThreadItem {
}
if ($lock) {
- if (($item['mid'] == $item['parent_mid']) && count(get_terms_oftype($item['term'],TERM_FORUM))) {
+ if (($item['mid'] == $item['parent_mid']) && isset($item['term']) && count(get_terms_oftype($item['term'], TERM_FORUM))) {
$privacy_warning = true;
$conv_flags['parent_privacy_warning'] = true;
}
@@ -180,7 +180,7 @@ class ThreadItem {
$dropping = false;
}
-
+ $drop = [];
if($dropping) {
$drop = array(
'dropping' => $dropping,
@@ -191,13 +191,6 @@ class ThreadItem {
$drop = [ 'dropping' => true, 'delete' => t('Admin Delete') ];
}
-// FIXME
- if($observer_is_pageowner) {
- $multidrop = array(
- 'select' => t('Select'),
- );
- }
-
$filer = ((($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) ? t("Save to Folder") : false);
$profile_avatar = $item['author']['xchan_photo_m'];
@@ -207,7 +200,6 @@ class ThreadItem {
$location = format_location($item);
$isevent = false;
$attend = null;
- $canvote = false;
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
@@ -227,17 +219,6 @@ class ThreadItem {
$response_verbs[] = 'answer';
}
- $consensus = (intval($item['item_consensus']) ? true : false);
- if($consensus) {
- $response_verbs[] = 'agree';
- $response_verbs[] = 'disagree';
- $response_verbs[] = 'abstain';
- if($this->is_commentable() && $observer) {
- $conlabels = array( t('I agree'), t('I disagree'), t('I abstain'));
- $canvote = true;
- }
- }
-
if(! feature_enabled($conv->get_profile_owner(),'dislike'))
unset($conv_responses['dislike']);
@@ -245,7 +226,8 @@ class ThreadItem {
$my_responses = [];
foreach($response_verbs as $v) {
- $my_responses[$v] = (($conv_responses[$v][$item['mid'] . '-m']) ? 1 : 0);
+
+ $my_responses[$v] = ((isset($conv_responses[$v][$item['mid'] . '-m'])) ? 1 : 0);
}
$like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : '');
@@ -283,14 +265,11 @@ class ThreadItem {
$this->check_wall_to_wall();
if($this->is_toplevel()) {
- // FIXME check this permission
- if($conv->get_profile_owner() === local_channel() || intval($item['item_private']) === 0) {
-
- $star = array(
+ if((local_channel() && $conv->get_profile_owner() === local_channel()) || (local_channel() && App::$module === 'pubstream')) {
+ $star = [
'toggle' => t("Toggle Star Status"),
'isstarred' => ((intval($item['item_starred'])) ? true : false),
- );
-
+ ];
}
}
else {
@@ -307,7 +286,7 @@ class ThreadItem {
$tagger = [];
// FIXME - check this permission
- if($conv->get_profile_owner() == local_channel()) {
+ if(local_channel() && $conv->get_profile_owner() == local_channel()) {
/* disable until we agree on how to implemnt this in zot6/activitypub
$tagger = array(
'tagit' => t("Add Tag"),
@@ -330,20 +309,26 @@ class ThreadItem {
if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_channel())
$has_event = true;
+ $like = [];
+ $dislike = [];
+ $reply_to = [];
+
if($this->is_commentable() && $observer) {
$like = array( t("I like this \x28toggle\x29"), t("like"));
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
$reply_to = array( t("Reply on this comment"), t("reply"), t("Reply to"));
}
+ $share = [];
+ $embed = [];
if ($shareable) {
// This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues.
// Will allow it only for uri resolvable sources.
if(strpos($item['mid'],'http') === 0) {
- $share = []; //Not yet ready for primetime
+ //Not yet ready for primetime
//$share = array( t('Repeat This'), t('repeat'));
}
- $embed = array( t('Share This'), t('share'));
+ $embed = [t('Share This'), t('share')];
}
$dreport = '';
@@ -352,11 +337,13 @@ class ThreadItem {
if($keep_reports === 0)
$keep_reports = 10;
- if((! get_config('system','disable_dreport')) && strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC',"now - $keep_reports days")) > 0) {
+ $dreport_link = '';
+ if((intval($item['item_type']) == ITEM_TYPE_POST) && (! get_config('system','disable_dreport')) && strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC',"now - $keep_reports days")) > 0) {
$dreport = t('Delivery Report');
$dreport_link = gen_link_id($item['mid']);
}
+ $is_new = false;
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$is_new = true;
@@ -426,9 +413,6 @@ class ThreadItem {
'author_is_group_actor' => (($item['author']['xchan_pubforum']) ? t('Forum') : ''),
'isevent' => $isevent,
'attend' => $attend,
- 'consensus' => $consensus,
- 'conlabels' => $conlabels,
- 'canvote' => $canvote,
'linktitle' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']),
'olinktitle' => (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url']),
'llink' => $item['llink'],
@@ -497,7 +481,6 @@ class ThreadItem {
'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''),
'addtocal' => (($has_event) ? t('Add to Calendar') : ''),
'drop' => $drop,
- 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''),
'dropdown_extras' => $dropdown_extras,
// end toolbar buttons
'unseen_comments' => $unseen_comments,
@@ -520,7 +503,7 @@ class ThreadItem {
'modal_dismiss' => t('Close'),
'showlike' => $showlike,
'showdislike' => $showdislike,
- 'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box($indent)),
+ 'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box()),
'previewing' => ($conv->is_preview() ? true : false ),
'preview_lbl' => t('This is an unsaved preview'),
'wait' => t('Please wait'),
@@ -814,7 +797,7 @@ class ThreadItem {
* _ The comment box string (empty if no comment box)
* _ false on failure
*/
- private function get_comment_box($indent) {
+ private function get_comment_box() {
if(!$this->is_toplevel() && !get_config('system','thread_allow')) {
return '';
@@ -860,7 +843,6 @@ class ThreadItem {
'$edurl' => t('Insert Link'),
'$edvideo' => t('Video'),
'$preview' => t('Preview'), // ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
- '$indent' => $indent,
'$can_upload' => (perm_is_allowed($conv->get_profile_owner(),get_observer_hash(),'write_storage') && $conv->is_uploadable()),
'$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false),
'$encrypt' => t('Encrypt text'),
diff --git a/Zotlabs/Lib/Webfinger.php b/Zotlabs/Lib/Webfinger.php
index 611c36889..8484fb797 100644
--- a/Zotlabs/Lib/Webfinger.php
+++ b/Zotlabs/Lib/Webfinger.php
@@ -56,7 +56,7 @@ class Webfinger {
if($m['scheme'] !== 'https') {
return false;
}
- self::$server = $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
+ self::$server = $m['host'] . ((isset($m['port'])) ? ':' . $m['port'] : '');
}
else {
return false;
@@ -86,7 +86,7 @@ class Webfinger {
/**
* @brief fetch a webfinger resource and return a zot6 discovery url if present
*
- */
+ */
static function zot_url($resource) {