aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHabeas Codice <habeascodice@federated.social>2015-01-24 21:18:27 -0800
committerHabeas Codice <habeascodice@federated.social>2015-01-24 21:18:27 -0800
commitaf7fa99e2ec819164e5800412f8bcbff44bc1c63 (patch)
treea0af925a6c521f54c09bb52a3f115852841e42c9 /include
parent1d80bcf2e722508702d21b7a6e03e4eea75137e8 (diff)
parent63f1ae5e204cdb615a0edb0d16c4c471c2f3264e (diff)
downloadvolse-hubzilla-af7fa99e2ec819164e5800412f8bcbff44bc1c63.tar.gz
volse-hubzilla-af7fa99e2ec819164e5800412f8bcbff44bc1c63.tar.bz2
volse-hubzilla-af7fa99e2ec819164e5800412f8bcbff44bc1c63.zip
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'include')
-rw-r--r--include/attach.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/attach.php b/include/attach.php
index 9c71beb23..c7216df7a 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -981,17 +981,25 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$jsonobject = json_encode($object);
//check if item for this object exists
- $y = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND object = '%s' LIMIT 1",
+ $y = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1",
dbesc(ACTIVITY_POST),
dbesc($objtype),
- dbesc($jsonobject)
+ dbesc($object['hash']),
+ intval(local_user())
);
-
if($y) {
$update = true;
$object['d_mid'] = $y[0]['mid']; //attach mid of the old object
$u_jsonobject = json_encode($object);
+
+ //we have got the relevant info - delete the old item before we create the new one
+ $z = q("DELETE FROM item WHERE obj_type = '%s' AND verb = '%s' AND mid = '%s'",
+ dbesc(ACTIVITY_OBJ_FILE),
+ dbesc(ACTIVITY_POST),
+ dbesc($y[0]['mid'])
+ );
+
}
if($update && $verb == 'post' ) {
@@ -1019,6 +1027,8 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$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);
@@ -1057,6 +1067,8 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$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'] = '';