aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Libzot.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib/Libzot.php')
-rw-r--r--Zotlabs/Lib/Libzot.php70
1 files changed, 24 insertions, 46 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 3d499bd08..d2d696356 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -655,6 +655,11 @@ class Libzot {
return $ret;
}
+ if (empty($arr['primary_location']['address'])) {
+ logger('Empty primary location address: ' . print_r($arr, true), LOGGER_DEBUG);
+ return $ret;
+ }
+
/**
* @hooks import_xchan
* Called when processing the result of zot_finger() to store the result
@@ -1148,7 +1153,7 @@ class Libzot {
$AS = new ActivityStreams($data);
// process add/remove from collection separately, as it requires a target.
- // use the raw object, as it will not include actor expansion
+ // use the data object, as it will not include actor expansion
if (in_array($AS->type, ['Add', 'Remove'])
&& is_array($AS->obj)
&& array_key_exists('object', $AS->obj)
@@ -1164,10 +1169,6 @@ class Libzot {
$raw_activity = $AS->data;
$AS = new ActivityStreams($raw_activity['object'], portable_id: $env['sender']);
-
- // Store the original activity id and type for later usage
- $AS->meta['original_id'] = $original_id;
- $AS->meta['original_type'] = $original_type;
}
if (is_array($AS->obj)) {
@@ -1227,7 +1228,6 @@ class Libzot {
logger('public post');
-
// Public post. look for any site members who are or may be accepting posts from this sender
// and who are allowed to see them based on the sender's permissions
// @fixme;
@@ -1294,25 +1294,6 @@ class Libzot {
$item['item_private'] = 1;
}
- 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 === $item['created']) {
- $item['item_nocomment'] = 1;
- }
- else {
- $item['comments_closed'] = $comments_closed_at;
- $aritemr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy']));
- }
- }
- else {
- $item['comment_policy'] = $AS->obj['commentPolicy'];
- }
- }
- }
-
if (!empty($AS->meta['hubloc']) || $AS->sigok) {
$item['item_verified'] = true;
}
@@ -1561,6 +1542,7 @@ class Libzot {
$local_public = $public;
$item_result = null;
+ $parent = null;
$DR = new DReport(z_root(), $sender, $d, $arr['mid'], $arr['uuid']);
@@ -1576,7 +1558,7 @@ class Libzot {
$conversation_operation = $is_collection_operation && isset($arr['target']['attributedTo']);
- if (str_contains($arr['tgt_type'], 'Collection') && !$relay && !$conversation_operation) {
+ if (isset($arr['tgt_type']) && str_contains($arr['tgt_type'], 'Collection') && !$relay && !$conversation_operation) {
$DR->update('not a collection activity');
$result[] = $DR->get();
continue;
@@ -1663,22 +1645,24 @@ class Libzot {
if (intval($channel['channel_system']) && (!$arr['item_private']) && (!$relay)) {
$local_public = true;
- $r = q("select xchan_selfcensored from xchan where xchan_hash = '%s' limit 1",
- dbesc($sender)
- );
- // don't import sys channel posts from selfcensored authors
- if ($r && (intval($r[0]['xchan_selfcensored']))) {
+ $incl = Config::Get('system','pubstream_incl');
+ $excl = Config::Get('system','pubstream_excl');
+
+ if(($incl || $excl) && !MessageFilter::evaluate($arr, $incl, $excl)) {
$local_public = false;
continue;
}
- $incl = Config::Get('system','pubstream_incl');
- $excl = Config::Get('system','pubstream_excl');
+ $r = q("select xchan_selfcensored, xchan_censored from xchan where xchan_hash = '%s'",
+ dbesc($sender)
+ );
- if(($incl || $excl) && !MessageFilter::evaluate($arr, $incl, $excl)) {
+ // don't import sys channel posts from selfcensored or censored authors
+ if ($r && ($r[0]['xchan_selfcensored'] || $r[0]['xchan_censored'])) {
$local_public = false;
continue;
}
+
}
$tag_delivery = tgroup_check($channel['channel_id'], $arr);
@@ -1740,6 +1724,7 @@ class Libzot {
// If this is a poll response, convert the obj_type to our (internal-only) "Answer" type
if (in_array($arr['obj_type'], ['Note', ACTIVITY_OBJ_COMMENT]) && $arr['title'] && (!$arr['body'])) {
$arr['obj_type'] = 'Answer';
+ $arr['item_hidden'] = 1;
}
}
@@ -1865,19 +1850,12 @@ class Libzot {
dbesc($arr['author_xchan'])
);
- // If we import an add/remove activity ($is_collection_operation) we strip off the
- // add/remove part and only process the object.
- // When looking up the item to pass it to the notifier for relay, we need to look up
- // the original (stripped off) message id which we stored in $act->meta.
-
- $sql_mid = (($is_collection_operation && $relay && $channel['channel_hash'] === $arr['owner_xchan']) ? $act->meta['original_id'] : $arr['mid']);
-
// Reactions such as like and dislike could have an mid with /activity/ in it.
// Check for both forms in order to prevent duplicates.
$r = q("select * from item where mid in ('%s', '%s') and uid = %d limit 1",
- dbesc($sql_mid),
- dbesc(reverse_activity_mid($sql_mid)),
+ dbesc($arr['mid']),
+ dbesc(reverse_activity_mid($arr['mid'])),
intval($channel['channel_id'])
);
@@ -2008,10 +1986,10 @@ class Libzot {
if ((is_array($stored)) && ($stored['id'] != $stored['parent'])
&& ($stored['author_xchan'] === $channel['channel_hash'])) {
- retain_item($stored['item']['parent']);
+ retain_item($stored['parent']);
}
- if ($relay && $item_id && $stored['item_blocked'] !== ITEM_MODERATED) {
+ if ($relay && $item_id && item_forwardable($stored)) {
logger('Invoking relay');
Master::Summon(['Notifier', 'relay', intval($item_id)]);
if (!empty($approval) && $approval['item_id']) {
@@ -2019,7 +1997,7 @@ class Libzot {
}
$DR->addto_update('relayed');
- $result[] = $DR->get();
+ $result = [$DR->get()];
}
}