mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:35:19 +00:00
attempt to fix poll updates on contained items
This commit is contained in:
parent
817b60270b
commit
d63a02dbf6
2 changed files with 44 additions and 1 deletions
|
@ -2891,6 +2891,10 @@ class Activity
|
|||
intval($item['id'])
|
||||
);
|
||||
Run::Summon(['Notifier', 'edit_post', $item['id']]);
|
||||
$related = find_related($item);
|
||||
if ($related) {
|
||||
Run::Summon(['Notifier', 'edit_post', $related['id']]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
logger('update poll was not stored');
|
||||
|
|
|
@ -3691,7 +3691,7 @@ function drop_related($item, $stage = DROPITEM_NORMAL, $force = false, $uid = 0,
|
|||
{
|
||||
$allRelated = q("select * from item where parent_mid = '%s' and uid = %d",
|
||||
dbesc($item['parent_mid']),
|
||||
intval($item['id'])
|
||||
intval($item['uid'])
|
||||
);
|
||||
if (! $allRelated) {
|
||||
return;
|
||||
|
@ -3723,6 +3723,45 @@ function drop_related($item, $stage = DROPITEM_NORMAL, $force = false, $uid = 0,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function find_related($item)
|
||||
{
|
||||
$allRelated = q("select * from item where parent_mid = '%s' and uid = %d",
|
||||
dbesc($item['parent_mid']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
if (! $allRelated) {
|
||||
return false;
|
||||
}
|
||||
if ($item['verb'] === 'Add' && $item['tgt_type'] === 'Collection') {
|
||||
$thisItem = json_decode($item['obj'],true);
|
||||
if (is_array($thisItem)) {
|
||||
$targetMid = $thisItem['object']['id'];
|
||||
}
|
||||
if (!$targetMid) {
|
||||
return false;
|
||||
}
|
||||
foreach ($allRelated as $related) {
|
||||
if ($related['mid'] === $targetMid) {
|
||||
return $related;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($allRelated as $related) {
|
||||
if ($related['verb'] === 'Add' && str_contains($related['tgt_type'], 'Collection')) {
|
||||
$thisItem = json_decode($related['obj'], true);
|
||||
if (is_array($thisItem) && $thisItem['object']['id'] === $item['mid']) {
|
||||
return $related;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @warning This function does not check for permission and does not send
|
||||
* notifications and does not check recursion.
|
||||
|
|
Loading…
Reference in a new issue