aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/diaspora.php62
-rw-r--r--mod/contacts.php22
2 files changed, 67 insertions, 17 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 78a642048..4420129b0 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -771,19 +771,32 @@ function diaspora_retraction($importer,$xml) {
$guid = notags(unxmlify($xml->guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+ $type = notags(unxmlify($xml->type));
$contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle);
if(! $contact)
return;
-// if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
-// logger('diaspora_retraction: Ignoring this author.');
-// http_status_exit(202);
-// // NOTREACHED
-// }
-
-
+ if($type === 'Person') {
+ contact_remove($contact['id']);
+ }
+ elseif($type === 'Post') {
+ $r = q("select * from item where guid = '%s' and uid = %d limit 1",
+ dbesc('guid'),
+ intval($importer['uid'])
+ );
+ if(count($r)) {
+ if(link_compare($r[0]['author-link'],$contact['url'])) {
+ q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d limit 1",
+ dbesc(datetime_convert()),
+ intval($r[0]['id'])
+ );
+ }
+ }
+ }
+ http_exit_status(202);
+ // NOTREACHED
}
function diaspora_share($me,$contact) {
@@ -805,6 +818,28 @@ function diaspora_share($me,$contact) {
return $return_code;
}
+function diaspora_unshare($me,$contact) {
+
+ $a = get_app();
+ $myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+ $tpl = get_markup_template('diaspora_retract.tpl');
+ $msg = replace_macros($tpl, array(
+ '$guid' => $me['guid'],
+ '$type' => 'Person',
+ '$handle' => $myaddr
+ ));
+
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey'])));
+
+ post_url($contact['notify'] . '/',$slap);
+ $return_code = $a->get_curl_code();
+ logger('diaspora_send_unshare: returns: ' . $return_code);
+ return $return_code;
+}
+
+
+
function diaspora_send_status($item,$owner,$contact) {
$a = get_app();
@@ -975,8 +1010,21 @@ function diaspora_send_relay($item,$owner,$contact) {
function diaspora_send_retraction($item,$owner,$contact) {
+ $a = get_app();
+ $myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $tpl = get_markup_template('diaspora_retract.tpl');
+ $msg = replace_macros($tpl, array(
+ '$guid' => $item['guid'],
+ '$type' => 'Post',
+ '$handle' => $myaddr
+ ));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ post_url($contact['notify'] . '/',$slap);
+ $return_code = $a->get_curl_code();
+ logger('diaspora_send_retraction: returns: ' . $return_code);
+ return $return_code;
} \ No newline at end of file
diff --git a/mod/contacts.php b/mod/contacts.php
index efb0dc75b..4d9385026 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -163,9 +163,9 @@ function contacts_content(&$a) {
if($cmd === 'block') {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
$r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($blocked),
- intval($contact_id),
- intval(local_user())
+ intval($blocked),
+ intval($contact_id),
+ intval(local_user())
);
if($r) {
//notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL );
@@ -178,9 +178,9 @@ function contacts_content(&$a) {
if($cmd === 'ignore') {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
$r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($readonly),
- intval($contact_id),
- intval(local_user())
+ intval($readonly),
+ intval($contact_id),
+ intval(local_user())
);
if($r) {
info( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL );
@@ -193,7 +193,7 @@ function contacts_content(&$a) {
// create an unfollow slap
- if($orig_record[0]['network'] === 'stat') {
+ if($orig_record[0]['network'] === NETWORK_OSTATUS) {
$tpl = get_markup_template('follow_slap.tpl');
$slap = replace_macros($tpl, array(
'$name' => $a->user['username'],
@@ -215,13 +215,15 @@ function contacts_content(&$a) {
slapper($a->user,$orig_record[0]['notify'],$slap);
}
}
-
- if($orig_record[0]['network'] === 'dfrn') {
+ elseif($orig_record[0]['network'] === NETWORK_DIASPORA) {
+ require_once('include/diaspora.php');
+ diaspora_unshare($a->user,$orig_record[0]);
+ }
+ elseif($orig_record[0]['network'] === NETWORK_DFRN) {
require_once('include/items.php');
dfrn_deliver($a->user,$orig_record[0],'placeholder', 1);
}
-
contact_remove($orig_record[0]['id']);
info( t('Contact has been removed.') . EOL );
goaway($a->get_baseurl() . '/contacts');