Merge pull request #12465 from annando/issue-12185
Issue 12185: Problems adding contacts
This commit is contained in:
commit
e28be36086
1 changed files with 9 additions and 10 deletions
|
@ -2923,15 +2923,8 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we already have a contact
|
// check if we already have a contact
|
||||||
// the poll url is more reliable than the profile url, as we may have
|
$condition = ['uid' => $uid, 'nurl' => Strings::normaliseLink($ret['url'])];
|
||||||
// indirect links or webfinger links
|
$contact = DBA::selectFirst('contact', ['id', 'rel', 'url', 'pending', 'hub-verify'], $condition);
|
||||||
|
|
||||||
$condition = ['uid' => $uid, 'poll' => [$ret['poll'], Strings::normaliseLink($ret['poll'])], 'network' => $ret['network'], 'pending' => false];
|
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
|
|
||||||
if (!DBA::isResult($contact)) {
|
|
||||||
$condition = ['uid' => $uid, 'nurl' => Strings::normaliseLink($ret['url']), 'network' => $ret['network'], 'pending' => false];
|
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocol = self::getProtocol($ret['url'], $ret['network']);
|
$protocol = self::getProtocol($ret['url'], $ret['network']);
|
||||||
|
|
||||||
|
@ -2987,7 +2980,13 @@ class Contact
|
||||||
// update contact
|
// update contact
|
||||||
$new_relation = (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) ? self::FRIEND : self::SHARING);
|
$new_relation = (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) ? self::FRIEND : self::SHARING);
|
||||||
|
|
||||||
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
|
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false, 'network' => $ret['network']];
|
||||||
|
|
||||||
|
if ($contact['pending'] && !empty($contact['hub-verify'])) {
|
||||||
|
ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
|
||||||
|
$fields['pending'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
self::update($fields, ['id' => $contact['id']]);
|
self::update($fields, ['id' => $contact['id']]);
|
||||||
} else {
|
} else {
|
||||||
$new_relation = (in_array($protocol, [Protocol::MAIL]) ? self::FRIEND : self::SHARING);
|
$new_relation = (in_array($protocol, [Protocol::MAIL]) ? self::FRIEND : self::SHARING);
|
||||||
|
|
Loading…
Reference in a new issue