diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-02-29 14:22:35 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-02-29 14:22:35 +0100 |
commit | f2d3be2e67745a28f866f793393e1fb499a7f0fb (patch) | |
tree | 542b768ee553b1cf60ce08f328a0245fdd414142 /include/attach.php | |
parent | 60b818eb24475e43b2cfab86b73d43538cf2d41b (diff) | |
download | volse-hubzilla-f2d3be2e67745a28f866f793393e1fb499a7f0fb.tar.gz volse-hubzilla-f2d3be2e67745a28f866f793393e1fb499a7f0fb.tar.bz2 volse-hubzilla-f2d3be2e67745a28f866f793393e1fb499a7f0fb.zip |
do not process update activity if there is no item to update and simplify code a little
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/include/attach.php b/include/attach.php index 78114b415..530bd694b 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1471,7 +1471,7 @@ function pipe_streams($in, $out) { * @param string $deny_cid * @param string $deny_gid * @param string $verb - * @param boolean $no_activity + * @param boolean $notify */ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) { @@ -1517,13 +1517,21 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $mid = item_message_id(); - $arr = array(); + $objtype = ACTIVITY_OBJ_FILE; + $arr = array(); + $arr['aid'] = get_account_id(); + $arr['uid'] = $channel_id; $arr['item_wall'] = 1; $arr['item_origin'] = 1; $arr['item_unseen'] = 1; - - $objtype = ACTIVITY_OBJ_FILE; + $arr['author_xchan'] = $poster['xchan_hash']; + $arr['owner_xchan'] = $poster['xchan_hash']; + $arr['title'] = ''; + $arr['item_hidden'] = 1; + $arr['obj_type'] = $objtype; + $arr['resource_id'] = $object['hash']; + $arr['resource_type'] = 'attach'; $private = (($arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0]) ? 1 : 0); @@ -1551,9 +1559,8 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, } + //send update activity and create a new one if($update && $verb == 'post' ) { - //send update activity and create a new one - //updates should be sent to everybody with recursive perms and all eventual former allowed members ($object['allow_cid'] etc.). $u_arr_allow_cid = array_unique(array_merge($arr_allow_cid, expand_acl($object['allow_cid']))); $u_arr_allow_gid = array_unique(array_merge($arr_allow_gid, expand_acl($object['allow_gid']))); @@ -1564,24 +1571,15 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $u_mid = item_message_id(); - $arr['aid'] = get_account_id(); - $arr['uid'] = $channel_id; $arr['mid'] = $u_mid; $arr['parent_mid'] = $u_mid; - $arr['author_xchan'] = $poster['xchan_hash']; - $arr['owner_xchan'] = $poster['xchan_hash']; - $arr['title'] = ''; $arr['allow_cid'] = perms2str($u_arr_allow_cid); $arr['allow_gid'] = perms2str($u_arr_allow_gid); $arr['deny_cid'] = perms2str($u_arr_deny_cid); $arr['deny_gid'] = perms2str($u_arr_deny_gid); - $arr['item_hidden'] = 1; $arr['item_private'] = $private; $arr['verb'] = ACTIVITY_UPDATE; - $arr['obj_type'] = $objtype; $arr['object'] = $u_jsonobject; - $arr['resource_id'] = $object['hash']; - $arr['resource_type'] = 'attach'; $arr['body'] = ''; $post = item_store($arr); @@ -1597,32 +1595,25 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, //notice( t('File activity updated') . EOL); } + //don't create new activity if notify was not enabled if(! $notify) { return; } - $arr = array(); + //don't create new activity if we have an update request but there is no item to update + //this can e.g. happen when deleting images + if(! $y && $verb == 'update') { + return; + } - $arr['aid'] = get_account_id(); - $arr['uid'] = $channel_id; $arr['mid'] = $mid; $arr['parent_mid'] = $mid; - $arr['item_wall'] = 1; - $arr['item_origin'] = 1; - $arr['item_unseen'] = 1; - $arr['author_xchan'] = $poster['xchan_hash']; - $arr['owner_xchan'] = $poster['xchan_hash']; - $arr['title'] = ''; $arr['allow_cid'] = perms2str($arr_allow_cid); $arr['allow_gid'] = perms2str($arr_allow_gid); $arr['deny_cid'] = perms2str($arr_deny_cid); $arr['deny_gid'] = perms2str($arr_deny_gid); - $arr['item_hidden'] = 1; $arr['item_private'] = $private; $arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST); - $arr['obj_type'] = $objtype; - $arr['resource_id'] = $object['hash']; - $arr['resource_type'] = 'attach'; $arr['object'] = (($update) ? $u_jsonobject : $jsonobject); $arr['body'] = ''; |