aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorZach Prezkuta <fermion@gmx.com>2012-05-31 19:40:12 -0600
committerZach Prezkuta <fermion@gmx.com>2012-06-03 14:53:29 -0600
commitc0af6dbb1a5507dcf0fffaf13b42cfd71b0d0c50 (patch)
tree0ed31d5a6de8c1f4abaaa509aa119a4704c955c4 /include/items.php
parent1fe1ac022f0755d73c62bac86f1b54fdbd6b50f5 (diff)
downloadvolse-hubzilla-c0af6dbb1a5507dcf0fffaf13b42cfd71b0d0c50.tar.gz
volse-hubzilla-c0af6dbb1a5507dcf0fffaf13b42cfd71b0d0c50.tar.bz2
volse-hubzilla-c0af6dbb1a5507dcf0fffaf13b42cfd71b0d0c50.zip
Implement relaying of relayable_retractions
Also: some whitespace cleanup, fix Diaspora parent DB query
Diffstat (limited to 'include/items.php')
-rw-r--r--include/items.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/include/items.php b/include/items.php
index 0ed16217f..8858ca64f 100644
--- a/include/items.php
+++ b/include/items.php
@@ -3278,7 +3278,36 @@ function drop_item($id,$interactive = true) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
intval($r[0]['id'])
);
- }
+ }
+
+ // Add a relayable_retraction signature for Diaspora. Note that we can't add a target_author_signature
+ // if the comment was deleted by a remote user. That should be ok, because if a remote user is deleting
+ // the comment, that means we're the home of the post, and Diaspora will only
+ // check the parent_author_signature of retractions that it doesn't have to relay further
+ if( strcmp($item['type'], 'activity') != 0) {
+ $signed_text = $item['guid'] . ';' . 'Comment';
+
+ if(local_user() == $item['uid']) {
+
+ $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $authorsig = base64_encode(rsa_sign($signed_text,$a->user['prvkey'],'sha256'));
+ }
+ else {
+ $r = q("SELECT `nick`, `url` FROM `contact` WHERE `id` = '%d' LIMIT 1",
+ $item['contact-id']
+ );
+ if(count($r))
+ $handle = $r['nick'] . '@' . substr($r['url'], strpos($r['url'],'://') + 3, strpos($r['url'],'/profile') - 1);
+ }
+
+ if(isset($handle)
+ q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
+ intval($item['id']),
+ dbesc($signed_text),
+ dbesc($authorsig),
+ dbesc($handle)
+ );
+ }
}
$drop_id = intval($item['id']);