diff options
author | marijus <mario@mariovavti.com> | 2015-01-24 01:13:02 +0100 |
---|---|---|
committer | marijus <mario@mariovavti.com> | 2015-01-24 01:13:02 +0100 |
commit | 0cbe64c3606312302ad5d3ef56df5d152983ee4e (patch) | |
tree | 3f9fae671f62ca736426cb9339fdc6aa144dffcc /include/attach.php | |
parent | ea209a84ab946ee320c1f1cc39b667e9da23abe6 (diff) | |
download | volse-hubzilla-0cbe64c3606312302ad5d3ef56df5d152983ee4e.tar.gz volse-hubzilla-0cbe64c3606312302ad5d3ef56df5d152983ee4e.tar.bz2 volse-hubzilla-0cbe64c3606312302ad5d3ef56df5d152983ee4e.zip |
some more kiss
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 116 |
1 files changed, 51 insertions, 65 deletions
diff --git a/include/attach.php b/include/attach.php index db42cd2a3..153186312 100644 --- a/include/attach.php +++ b/include/attach.php @@ -968,18 +968,6 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, require_once('include/items.php'); - switch($verb) { - case 'post': - $activity = ACTIVITY_POST; - break; - case 'update': - $activity = ACTIVITY_UPDATE; - break; - default: - return; - break; - } - $poster = get_app()->get_observer(); $mid = item_message_id(); @@ -988,65 +976,63 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + $private = (($allow_cid || $allow_gid || $deny_cid || $deny_gid) ? 1 : 0); + $jsonobject = json_encode($object); - $private = (($allow_cid || $allow_gid || $deny_cid || $deny_gid) ? 1 : 0); + //check if item for this object exists + $y = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND object = '%s' LIMIT 1", + dbesc(ACTIVITY_POST), + dbesc($objtype), + dbesc($jsonobject) + ); - if($verb == 'post') { - //check if activity item exists - //if yes send update (drop) activity and create a new one - $y = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND object = '%s' LIMIT 1", - dbesc(ACTIVITY_POST), - dbesc($objtype), - dbesc($jsonobject) - ); - if($y) { + if($y) { + $update = true; + $object['d_mid'] = $y[0]['mid']; //attach mid of the old object + $u_jsonobject = json_encode($object); + } - $dmid = item_message_id(); - - $object['mid'] = $mid; //attach mid for update object - - $ujsonobject = json_encode($object); - - $arr = array(); - - $arr['aid'] = get_account_id(); - $arr['uid'] = $channel_id; - $arr['mid'] = $dmid; - $arr['parent_mid'] = $dmid; - $arr['item_flags'] = $item_flags; - $arr['author_xchan'] = $poster['xchan_hash']; - $arr['owner_xchan'] = $poster['xchan_hash']; - $arr['title'] = ''; - //updates must be visible to everybody -> perms may have changed - $arr['allow_cid'] = ''; - $arr['allow_gid'] = ''; - $arr['deny_cid'] = ''; - $arr['deny_gid'] = ''; - $arr['item_restrict'] = ITEM_HIDDEN; - $arr['item_private'] = 0; - $arr['verb'] = ACTIVITY_UPDATE; - $arr['obj_type'] = $objtype; - $arr['object'] = $ujsonobject; - $arr['body'] = ''; - - $post = item_store($arr); - $item_id = $post['item_id']; - - if($item_id) { - proc_run('php',"include/notifier.php","activity",$item_id); - } + if($update && $verb == 'post' ) { + //send update activity and create a new one + + $u_mid = item_message_id(); + + $arr = array(); + + $arr['aid'] = get_account_id(); + $arr['uid'] = $channel_id; + $arr['mid'] = $u_mid; + $arr['parent_mid'] = $u_mid; + $arr['item_flags'] = $item_flags; + $arr['author_xchan'] = $poster['xchan_hash']; + $arr['owner_xchan'] = $poster['xchan_hash']; + $arr['title'] = ''; + //updates should be visible to everybody -> perms may have changed + $arr['allow_cid'] = ''; + $arr['allow_gid'] = ''; + $arr['deny_cid'] = ''; + $arr['deny_gid'] = ''; + $arr['item_restrict'] = ITEM_HIDDEN; + $arr['item_private'] = 0; + $arr['verb'] = ACTIVITY_UPDATE; + $arr['obj_type'] = $objtype; + $arr['object'] = $u_jsonobject; + $arr['body'] = ''; + + $post = item_store($arr); + $item_id = $post['item_id']; + if($item_id) { + proc_run('php',"include/notifier.php","activity",$item_id); + } - call_hooks('post_local_end', $arr); + call_hooks('post_local_end', $arr); - //notice( t('File activity updated') . EOL); + $update = false; - if($no_activity) { - return; - } + notice( t('File activity updated') . EOL); - } } if($no_activity) { @@ -1069,9 +1055,9 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $arr['deny_gid'] = $deny_gid; $arr['item_restrict'] = ITEM_HIDDEN; $arr['item_private'] = $private; - $arr['verb'] = $activity; + $arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST); $arr['obj_type'] = $objtype; - $arr['object'] = $jsonobject; + $arr['object'] = (($update) ? $u_jsonobject : $jsonobject); $arr['body'] = ''; $post = item_store($arr); @@ -1083,7 +1069,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, call_hooks('post_local_end', $arr); - //(($verb === 'post') ? notice( t('File activity posted') . EOL) : notice( t('File activity dropped') . EOL)); + (($verb === 'post') ? notice( t('File activity posted') . EOL) : notice( t('File activity dropped') . EOL)); return; |