aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-11-09 19:32:29 +0000
committerMario <mario@mariovavti.com>2023-11-09 19:32:29 +0000
commit85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6 (patch)
treef4138164362d501f2713fd9a83d7d52e38c0e2ab
parent547e6542ba7d396cc1c349577e2078fda098bee6 (diff)
downloadvolse-hubzilla-85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6.tar.gz
volse-hubzilla-85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6.tar.bz2
volse-hubzilla-85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6.zip
some low level work on native repeats
-rw-r--r--Zotlabs/Daemon/Notifier.php7
-rw-r--r--Zotlabs/Lib/DReport.php3
-rw-r--r--Zotlabs/Lib/Libzot.php42
-rw-r--r--Zotlabs/Module/Share.php64
-rw-r--r--include/items.php3
5 files changed, 69 insertions, 50 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 592dd2c38..4b74a7ba9 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -300,6 +300,11 @@ class Notifier {
return;
}
+ if ($target_item['verb'] === ACTIVITY_SHARE) {
+ // Provide correct representation across the wire. Internally this is treated as a comment.
+ $target_item['parent_mid'] = $target_item['thr_parent'] = $target_item['mid'];
+ }
+
if ($target_item['mid'] === $target_item['parent_mid']) {
$parent_item = $target_item;
$top_level_post = true;
@@ -377,7 +382,7 @@ class Notifier {
if (($relay_to_owner || $uplink) && ($cmd !== 'relay')) {
logger('notifier: followup relay', LOGGER_DEBUG);
- $sendto = (($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']);
+ $sendto = (($uplink) ? $parent_item['source_xchan'] : (($parent_item['verb'] === ACTIVITY_SHARE) ? $parent_item['author_xchan'] : $parent_item['owner_xchan']));
self::$recipients = [$sendto];
self::$private = true;
$upstream = true;
diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php
index e22ed65be..c5c2eb088 100644
--- a/Zotlabs/Lib/DReport.php
+++ b/Zotlabs/Lib/DReport.php
@@ -119,8 +119,9 @@ class DReport {
if((! $r) && ($dr['status'] === 'recipient_not_found'))
return false;
- $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ $r = q("select abook_id from abook where (abook_xchan = '%s' OR abook_xchan = '%s') and abook_channel = %d limit 1",
dbesc($dr['recipient']),
+ dbesc($dr['sender']),
intval($c[0]['channel_id'])
);
if($r)
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index e812dbd92..e9cb2c35c 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1516,11 +1516,9 @@ class Libzot {
*/
static function process_delivery($sender, $act, $arr, $deliveries, $relay, $public = false, $request = false, $force = false) {
-
$result = [];
// We've validated the sender. Now make sure that the sender is the owner or author
-
if (!$public) {
if ($sender != $arr['owner_xchan'] && $sender != $arr['author_xchan']) {
logger("Sender $sender is not owner {$arr['owner_xchan']} or author {$arr['author_xchan']} - mid {$arr['mid']}");
@@ -1641,6 +1639,13 @@ class Libzot {
if (!$allowed && $permit_mentions) {
$allowed = true;
}
+
+ if (!$allowed) {
+ if (PConfig::Get($channel['channel_id'], 'system', 'moderate_unsolicited_comments') && $arr['obj_type'] !== 'Answer') {
+ $arr['item_blocked'] = ITEM_MODERATED;
+ $allowed = true;
+ }
+ }
}
} elseif ($permit_mentions) {
@@ -1649,7 +1654,6 @@ class Libzot {
}
if ($request) {
-
// Conversation fetches (e.g. $request == true) take place for
// a) new comments on expired posts
// b) hyperdrive (friend-of-friend) conversations
@@ -1838,7 +1842,9 @@ class Libzot {
// We already have this post.
// Dismiss its announce
if ($act->type === 'Announce') {
- return;
+ $DR->update('update ignored');
+ $result[] = $DR->get();
+ continue;
}
$item_id = $r[0]['id'];
@@ -1847,7 +1853,6 @@ class Libzot {
// It was deleted locally.
$DR->update('update ignored');
$result[] = $DR->get();
-
continue;
}
// Maybe it has been edited?
@@ -1855,17 +1860,17 @@ class Libzot {
$arr['id'] = $r[0]['id'];
$arr['uid'] = $channel['channel_id'];
- if (post_is_importable($channel['channel_id'], $arr, $abook)) {
- $item_result = self::update_imported_item($sender, $arr, $r[0], $channel['channel_id'], $tag_delivery);
- $DR->update('updated');
- $result[] = $DR->get();
- if (!$relay) {
- add_source_route($item_id, $sender);
- }
- } else {
- $DR->update('update ignored');
- $result[] = $DR->get();
- }
+ if (post_is_importable($channel['channel_id'], $arr, $abook)) {
+ $item_result = self::update_imported_item($sender, $arr, $r[0], $channel['channel_id'], $tag_delivery);
+ $DR->update('updated');
+ $result[] = $DR->get();
+ if (!$relay) {
+ add_source_route($item_id, $sender);
+ }
+ } else {
+ $DR->update('update ignored');
+ $result[] = $DR->get();
+ }
}
else {
$DR->update('update ignored');
@@ -1940,7 +1945,8 @@ class Libzot {
add_source_route($item_id, $sender);
}
}
- $DR->update(($item_id) ? 'posted' : 'storage failed: ' . $item_result['message']);
+
+ $DR->update(($item_id) ? (($item_result['item']['item_blocked'] === ITEM_MODERATED) ? 'accepted for moderation' : 'posted') : 'storage failed: ' . $item_result['message']);
$result[] = $DR->get();
} else {
$DR->update('post ignored');
@@ -1957,7 +1963,7 @@ class Libzot {
retain_item($stored['item']['parent']);
}
- if ($relay && $item_id) {
+ if ($relay && $item_id && $stored['item_blocked'] !== ITEM_MODERATED) {
logger('Invoking relay');
Master::Summon(['Notifier', 'relay', intval($item_id)]);
$DR->addto_update('relayed');
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index c0db9978e..716f7229b 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -14,47 +14,53 @@ require_once('include/bbcode.php');
class Share extends \Zotlabs\Web\Controller {
function init() {
-
- $post_id = ((argc() > 1) ? intval(argv(1)) : 0);
-
- if(! $post_id)
- killme();
-
- if(! local_channel()) {
+
+ if (!intval(argv(1))) {
killme();
}
- $observer = App::get_observer();
+ if (! local_channel()) {
+ killme();
+ }
+ $observer = App::get_observer();
$channel = App::get_channel();
+ $sys_channel = get_sys_channel();
$r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1",
- intval($post_id)
+ intval(argv(1))
);
- if(! $r)
- killme();
-
+ if ($r[0]['uid'] === $sys_channel['channel_id']) {
+ $r = [copy_of_pubitem($channel, $r[0]['mid'])];
+ }
+
+ if(! $r) {
+ killme();
+ }
+ $item_id = $r[0]['id'];
- if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss'))
+ if ($r[0]['item_private']) {
killme();
-
+ }
+
$sql_extra = item_permissions_sql($r[0]['uid']);
-
+
$r = q("select * from item where id = %d $sql_extra",
- intval($post_id)
+ intval($item_id)
);
+
if(! $r)
killme();
-
+
/** @FIXME we only share bbcode */
-
+
if($r[0]['mimetype'] !== 'text/bbcode')
killme();
-
- xchan_query($r);
-
+
+ xchan_query($r,true);
+
$arr = [];
$item = $r[0];
@@ -81,7 +87,7 @@ class Share extends \Zotlabs\Web\Controller {
$thread_owner = $r[0];
else
killme();
-
+
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($item['author_xchan'])
);
@@ -89,7 +95,7 @@ class Share extends \Zotlabs\Web\Controller {
$item_author = $r[0];
else
killme();
-
+
$arr['aid'] = $owner_aid;
$arr['uid'] = $owner_uid;
@@ -109,12 +115,12 @@ class Share extends \Zotlabs\Web\Controller {
$arr['obj_type'] = $item['obj_type'];
$arr['verb'] = ACTIVITY_SHARE;
- $post = item_store($arr);
+ $post = item_store($arr);
$post_id = $post['item_id'];
$arr['id'] = $post_id;
-
+
call_hooks('post_local_end', $arr);
info( t('Post repeated') . EOL);
@@ -128,10 +134,10 @@ class Share extends \Zotlabs\Web\Controller {
Libsync::build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
}
- Master::Summon([ 'Notifier','like',$post_id ]);
-
+ Master::Summon([ 'Notifier', 'like', $post_id ]);
+
killme();
-
+
}
-
+
}
diff --git a/include/items.php b/include/items.php
index 57e5dbb96..6cef3d2cd 100644
--- a/include/items.php
+++ b/include/items.php
@@ -353,12 +353,13 @@ function can_comment_on_post($observer_xchan, $item) {
case 'specific':
case 'contacts':
case '':
- if(local_channel() && get_abconfig(local_channel(),$item['owner_xchan'],'their_perms','post_comments')) {
+ if(local_channel() && get_abconfig(local_channel(), (($item['verb'] === ACTIVITY_SHARE) ? $item['author_xchan'] : $item['owner_xchan']), 'their_perms', 'post_comments')) {
return true;
}
if(intval($item['item_wall']) && perm_is_allowed($item['uid'],$observer_xchan,'post_comments')) {
return true;
}
+
break;
default: