"unfriend" protocol

This commit is contained in:
Friendika 2011-01-25 03:57:10 -08:00
parent b0ab3e468b
commit 5a7ff660c4
2 changed files with 31 additions and 10 deletions

View File

@ -756,7 +756,7 @@ function get_item_contact($item,$contacts) {
} }
function dfrn_deliver($owner,$contact,$atom) { function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app(); $a = get_app();
@ -827,6 +827,8 @@ function dfrn_deliver($owner,$contact,$atom) {
$postvars['dfrn_id'] = $idtosend; $postvars['dfrn_id'] = $idtosend;
$postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION; $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
if($dissolve)
$postvars['dissolve'] = '1';
if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) { if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) {
$postvars['data'] = $atom; $postvars['data'] = $atom;
@ -838,7 +840,7 @@ function dfrn_deliver($owner,$contact,$atom) {
$postvars['data'] = str_replace('<dfrn:comment-allow>1','<dfrn:comment-allow>0',$atom); $postvars['data'] = str_replace('<dfrn:comment-allow>1','<dfrn:comment-allow>0',$atom);
} }
if($rino && $rino_allowed) { if($rino && $rino_allowed && (! $dissolve)) {
$key = substr(random_string(),0,16); $key = substr(random_string(),0,16);
$data = bin2hex(aes_encrypt($postvars['data'],$key)); $data = bin2hex(aes_encrypt($postvars['data'],$key));
$postvars['data'] = $data; $postvars['data'] = $data;

View File

@ -11,6 +11,7 @@ function dfrn_notify_post(&$a) {
$challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : ''); $challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : '');
$data = ((x($_POST,'data')) ? $_POST['data'] : ''); $data = ((x($_POST,'data')) ? $_POST['data'] : '');
$key = ((x($_POST,'key')) ? $_POST['key'] : ''); $key = ((x($_POST,'key')) ? $_POST['key'] : '');
$dissolve = ((x($_POST,'dissolve')) ? intval($_POST['dissolve']) : 0);
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if(strpos($dfrn_id,':') == 1) {
@ -51,6 +52,8 @@ function dfrn_notify_post(&$a) {
} }
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact` `contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact`
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
@ -65,19 +68,13 @@ function dfrn_notify_post(&$a) {
//NOTREACHED //NOTREACHED
} }
// $importer in this case contains the contact record for the remote contact joined with the user record of our user.
$importer = $r[0]; $importer = $r[0];
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']); logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA); logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
if($importer['readonly']) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
logger('dfrn_notify: ignoring');
xml_status(0);
//NOTREACHED
}
if(strlen($key)) { if(strlen($key)) {
$rawkey = hex2bin(trim($key)); $rawkey = hex2bin(trim($key));
logger('rino: md5 raw key: ' . md5($rawkey)); logger('rino: md5 raw key: ' . md5($rawkey));
@ -95,6 +92,28 @@ function dfrn_notify_post(&$a) {
logger('rino: decrypted data: ' . $data, LOGGER_DATA); logger('rino: decrypted data: ' . $data, LOGGER_DATA);
} }
if($dissolve == 1) {
/**
* Relationship is dissolved permanently
*/
contact_remove($importer['id']);
logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']);
xml_status(0);
}
if($importer['readonly']) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
logger('dfrn_notify: ignoring');
xml_status(0);
//NOTREACHED
}
// Consume notification feed. This may differ from consuming a public feed in several ways // Consume notification feed. This may differ from consuming a public feed in several ways
// - might contain email // - might contain email
// - might contain remote followup to our message // - might contain remote followup to our message