Issue 5733: Removing contacts does work now on the same machine as well

This commit is contained in:
Michael 2018-09-12 06:05:14 +00:00
parent dcb9bf4136
commit 96d10c25e3
4 changed files with 17 additions and 13 deletions

View file

@ -47,6 +47,11 @@ function contacts_init(App $a)
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]);
} }
// Don't display contacts that are about to be deleted
if (($contact['network'] == Protocol::PHANTOM)) {
$contact = false;
}
} }
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
@ -719,6 +724,8 @@ function contacts_content(App $a, $update = 0)
$sql_extra = " AND `blocked` = 0 "; $sql_extra = " AND `blocked` = 0 ";
} }
$sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
$nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : ''; $nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : '';

View file

@ -79,13 +79,13 @@ function dfrn_notify_post(App $a) {
$condition = []; $condition = [];
switch ($direction) { switch ($direction) {
case (-1): case (-1):
$condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
break; break;
case 0: case 0:
$condition = ['issued-id' => $dfrn_id, 'duplex' => true]; $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break; break;
case 1: case 1:
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break; break;
default: default:
System::xmlExit(3, 'Invalid direction'); System::xmlExit(3, 'Invalid direction');
@ -287,15 +287,15 @@ function dfrn_notify_content(App $a) {
$condition = []; $condition = [];
switch ($direction) { switch ($direction) {
case (-1): case (-1):
$condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$condition = ['issued-id' => $dfrn_id, 'duplex' => true]; $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:
@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) {
$pub_key = trim($importer['cpubkey']); $pub_key = trim($importer['cpubkey']);
$dplx = intval($importer['duplex']); $dplx = intval($importer['duplex']);
if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { if (!empty($prv_key) && empty($pub_key)) {
openssl_private_encrypt($hash, $challenge, $prv_key); openssl_private_encrypt($hash, $challenge, $prv_key);
openssl_private_encrypt($id_str, $encrypted_id, $prv_key); openssl_private_encrypt($id_str, $encrypted_id, $prv_key);
} elseif (strlen($pub_key)) { } elseif (strlen($pub_key)) {

View file

@ -1280,10 +1280,7 @@ class DFRN
} }
} }
if (($contact['duplex'] && strlen($contact['pubkey'])) if (empty($contact['prvkey']) && !empty($contact['pubkey'])) {
|| ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']);
} else { } else {

View file

@ -13,8 +13,8 @@ require_once 'include/dba.php';
class RemoveContact { class RemoveContact {
public static function execute($id) { public static function execute($id) {
// Only delete if the contact is archived // Only delete if the contact is to be deleted
$condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id]; $condition = ['network' => Protocol::PHANTOM, 'id' => $id];
$r = DBA::exists('contact', $condition); $r = DBA::exists('contact', $condition);
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
return; return;