aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2020-07-12 19:06:24 -0700
committerzotlabs <mike@macgirvin.com>2020-07-12 19:06:24 -0700
commitfa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078 (patch)
treeee9c436a88ad37c9cdcbb299fd68c3e3527a5147 /include/items.php
parent3f69fc70f1958d902e7209c80f661868f9d456b0 (diff)
downloadvolse-hubzilla-fa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078.tar.gz
volse-hubzilla-fa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078.tar.bz2
volse-hubzilla-fa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078.zip
zot6 group updates to support edit and delete of top-level group posts. This is supported remotely by editing or removing the post that started it all. A W2W post can only be deleted at this time.
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php74
1 files changed, 54 insertions, 20 deletions
diff --git a/include/items.php b/include/items.php
index f2db7288f..7df5e35fe 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2660,21 +2660,23 @@ function tag_deliver($uid, $item_id) {
$item = $i[0];
- if(($item['source_xchan']) && intval($item['item_uplink'])
+ if(intval($item['item_uplink']) && $item['source_xchan']
&& intval($item['item_thread_top']) && ($item['edited'] != $item['created'])) {
// this is an update (edit) to a post which was already processed by us and has a second delivery chain
// Just start the second delivery chain to deliver the updated post
// after resetting ownership and permission bits
logger('updating edited tag_deliver post for ' . $u[0]['channel_address']);
- start_delivery_chain($u[0], $item, $item_id, 0, true);
+ start_delivery_chain($u[0], $item, $item_id, 0, false, true);
return;
}
if ($is_group && intval($item['item_private']) === 2 && intval($item['item_thread_top'])) {
// group delivery via DM
- logger('group DM delivery for ' . $u[0]['channel_address']);
- start_delivery_chain($u[0], $item, $item_id, 0, false);
+ if(perm_is_allowed($uid,$item['owner_xchan'],'post_wall') || perm_is_allowed($uid,$item['owner_xchan'],'tag_deliver')) {
+ logger('group DM delivery for ' . $u[0]['channel_address']);
+ start_delivery_chain($u[0], $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
+ }
return;
}
@@ -2686,7 +2688,7 @@ function tag_deliver($uid, $item_id) {
}
// group delivery via W2W
logger('rewriting W2W post for ' . $u[0]['channel_address']);
- start_delivery_chain($u[0], $item, $item_id, 0, false);
+ start_delivery_chain($u[0], $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted']));
q("update item set item_wall = 0 where id = %d",
intval($item_id)
);
@@ -3136,7 +3138,7 @@ function tgroup_check($uid, $item) {
* @param boolean $edit (optional) default false
* @return void
*/
-function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) {
+function start_delivery_chain($channel, $item, $item_id, $parent, $group = false, $edit = false) {
$sourced = check_item_source($channel['channel_id'],$item);
@@ -3183,28 +3185,56 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false)
}
}
- // @todo handle edit and parent correctly
-
- if(! $parent) {
-
- if ($edit) {
- return;
- }
+ if ($group && (! $parent)) {
$arr = [];
+
+ if ($edit) {
+ // process edit or delete action
+ $r = q("select * from item where source_xchan = '%s' and body like '%s' and uid = %d limit 1",
+ dbesc($item['owner_xchan']),
+ dbesc("%message_id='" . $item['mid'] . "'%"),
+ intval($channel['channel_id'])
+ );
+ if ($r) {
+ if (intval($item['item_deleted'])) {
+ drop_item($r[0]['id'],false,DROPITEM_PHASE1);
+ Master::Summon([ 'Notifier','drop',$r[0]['id'] ]);
+ return;
+ }
+ $arr['id'] = intval($r[0]['id']);
+ $arr['parent'] = intval($r[0]['parent']);
+ $arr['uuid'] = $r[0]['uuid'];
+ $arr['mid'] = $r[0]['mid'];
+ $arr['parent_mid'] = $r[0]['parent_mid'];
+ $arr['edited'] = datetime_convert();
+ }
+ else {
+ logger('unable to locate original group post ' . $item['mid']);
+ return;
+ }
+ }
+ else {
+ $arr['uuid'] = item_message_id();
+ $arr['mid'] = z_root() . '/activity/' . $arr['uuid'];
+ $arr['parent_mid'] = $arr['mid'];
+ }
+
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
+ // WARNING: the presence of both source_xchan and non-zero item_uplink here will cause a delivery loop
+
+ $arr['item_uplink'] = 0;
+ $arr['source_xchan'] = $item['owner_xchan'];
+
$arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0);
$arr['item_origin'] = 1;
$arr['item_wall'] = 1;
- $arr['uuid'] = item_message_id();
- $arr['mid'] = z_root() . '/activity/' . $arr['uuid'];
- $arr['parent_mid'] = $arr['mid'];
$arr['item_thread_top'] = 1;
if (strpos($item['body'], "[/share]") !== false) {
@@ -3226,12 +3256,11 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false)
$bb .= "[/share]";
}
- $mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]';
$arr['body'] = $bb;
$arr['author_xchan'] = $channel['channel_hash'];
$arr['owner_xchan'] = $channel['channel_hash'];
- // $arr['obj'] = $item['obj'];
+
$arr['obj_type'] = $item['obj_type'];
$arr['verb'] = ACTIVITY_POST;
@@ -3241,7 +3270,12 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false)
$arr['deny_gid'] = $channel['channel_deny_gid'];
$arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments'));
- $post = item_store($arr);
+ if ($arr['id']) {
+ $post = item_store_update($arr);
+ }
+ else {
+ $post = item_store($arr);
+ }
$post_id = $post['item_id'];
@@ -3341,7 +3375,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false)
function check_item_source($uid, $item) {
logger('source: uid: ' . $uid, LOGGER_DEBUG);
- $xchan = (($item['source_xchan']) ? $item['source_xchan'] : $item['owner_xchan']);
+ $xchan = (($item['source_xchan'] && intval($item['item_uplink'])) ? $item['source_xchan'] : $item['owner_xchan']);
$r = q("select * from source where src_channel_id = %d and ( src_xchan = '%s' or src_xchan = '*' ) limit 1",
intval($uid),