Contact reject does work now as well
This commit is contained in:
parent
e45206ae5d
commit
2eabe45a8e
3 changed files with 38 additions and 9 deletions
|
@ -356,7 +356,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
||||||
$new_relation = $contact['rel'];
|
$new_relation = $contact['rel'];
|
||||||
$writable = $contact['writable'];
|
$writable = $contact['writable'];
|
||||||
|
|
||||||
if ($network === Protocol::DIASPORA) {
|
if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
|
||||||
if ($duplex) {
|
if ($duplex) {
|
||||||
$new_relation = Contact::FRIEND;
|
$new_relation = Contact::FRIEND;
|
||||||
} else {
|
} else {
|
||||||
|
@ -393,6 +393,10 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
||||||
|
|
||||||
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
|
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
|
||||||
|
|
||||||
|
if ($network == Protocol::ACTIVITYPUB && $duplex) {
|
||||||
|
ActivityPub::transmitActivity('Follow', $contact['url'], $uid);
|
||||||
|
}
|
||||||
|
|
||||||
// Let's send our user to the contact editor in case they want to
|
// Let's send our user to the contact editor in case they want to
|
||||||
// do anything special with this new friend.
|
// do anything special with this new friend.
|
||||||
if ($handsfree === null) {
|
if ($handsfree === null) {
|
||||||
|
|
|
@ -557,7 +557,11 @@ class Contact extends BaseObject
|
||||||
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||||
Diaspora::sendUnshare($user, $contact);
|
Diaspora::sendUnshare($user, $contact);
|
||||||
} elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
|
} elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
|
||||||
ActivityPub::transmitContactUndo($contact['url'], '', $user['uid']);
|
ActivityPub::transmitContactUndo($contact['url'], $user['uid']);
|
||||||
|
|
||||||
|
if ($dissolve) {
|
||||||
|
ActivityPub::transmitContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,17 +230,32 @@ class ActivityPub
|
||||||
return self::transmit($data, $profile['notify'], $uid);
|
return self::transmit($data, $profile['notify'], $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function transmitContactUndo($target, $id, $uid)
|
public static function transmitContactReject($target, $id, $uid)
|
||||||
{
|
{
|
||||||
$profile = Probe::uri($target, Protocol::ACTIVITYPUB);
|
$profile = Probe::uri($target, Protocol::ACTIVITYPUB);
|
||||||
|
|
||||||
if (empty($id)) {
|
|
||||||
$id = System::baseUrl() . '/activity/' . System::createGUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
$data = ['@context' => 'https://www.w3.org/ns/activitystreams',
|
$data = ['@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
|
'id' => System::baseUrl() . '/activity/' . System::createGUID(),
|
||||||
|
'type' => 'Reject',
|
||||||
|
'actor' => $owner['url'],
|
||||||
|
'object' => ['id' => $id, 'type' => 'Follow',
|
||||||
|
'actor' => $profile['url'],
|
||||||
|
'object' => $owner['url']]];
|
||||||
|
|
||||||
|
logger('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
|
||||||
|
return self::transmit($data, $profile['notify'], $uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function transmitContactUndo($target, $uid)
|
||||||
|
{
|
||||||
|
$profile = Probe::uri($target, Protocol::ACTIVITYPUB);
|
||||||
|
|
||||||
|
$id = System::baseUrl() . '/activity/' . System::createGUID();
|
||||||
|
|
||||||
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
$data = ['@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
|
'id' => $id,
|
||||||
'type' => 'Undo',
|
'type' => 'Undo',
|
||||||
'actor' => $owner['url'],
|
'actor' => $owner['url'],
|
||||||
'object' => ['id' => $id, 'type' => 'Follow',
|
'object' => ['id' => $id, 'type' => 'Follow',
|
||||||
|
@ -1150,8 +1165,14 @@ class ActivityPub
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['pending' => false];
|
$fields = ['pending' => false];
|
||||||
$condition = ['id' => $cid, 'pending' => true];
|
|
||||||
DBA::update('comtact', $fields, $condition);
|
$contact = DBA::selectFirst('contact', ['rel'], ['id' => $cid]);
|
||||||
|
if ($contact['rel'] == Contact::FOLLOWER) {
|
||||||
|
$fields['rel'] = Contact::FRIEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = ['id' => $cid];
|
||||||
|
DBA::update('contact', $fields, $condition);
|
||||||
logger('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
|
logger('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue