$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) {
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();
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
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 );
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 );
// 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'],
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');