mirror of
https://github.com/friendica/friendica
synced 2024-11-10 09:02:53 +00:00
Support for the new contact request data type
This commit is contained in:
parent
7e7cac19f6
commit
16ef9f4940
1 changed files with 38 additions and 12 deletions
|
@ -339,6 +339,9 @@ class diaspora {
|
|||
case "comment":
|
||||
return self::receive_comment($importer, $sender, $fields, $msg["message"]);
|
||||
|
||||
case "contact":
|
||||
return self::receive_contact_request($importer, $fields);
|
||||
|
||||
case "conversation":
|
||||
return self::receive_conversation($importer, $msg, $fields);
|
||||
|
||||
|
@ -360,9 +363,6 @@ class diaspora {
|
|||
case "profile":
|
||||
return self::receive_profile($importer, $fields);
|
||||
|
||||
case "request":
|
||||
return self::receive_request($importer, $fields);
|
||||
|
||||
case "reshare":
|
||||
return self::receive_reshare($importer, $fields, $msg["message"]);
|
||||
|
||||
|
@ -418,6 +418,9 @@ class diaspora {
|
|||
if (in_array($type, array("signed_retraction", "relayable_retraction")))
|
||||
$type = "retraction";
|
||||
|
||||
if ($type == "request")
|
||||
$type = "contact";
|
||||
|
||||
$fields = new SimpleXMLElement("<".$type."/>");
|
||||
|
||||
$signed_data = "";
|
||||
|
@ -1377,7 +1380,7 @@ class diaspora {
|
|||
|
||||
// "positive" = "false" would be a Dislike - wich isn't currently supported by Diaspora
|
||||
// We would accept this anyhow.
|
||||
if ($positive === "true")
|
||||
if ($positive == "true")
|
||||
$verb = ACTIVITY_LIKE;
|
||||
else
|
||||
$verb = ACTIVITY_DISLIKE;
|
||||
|
@ -1738,22 +1741,43 @@ class diaspora {
|
|||
*
|
||||
* @return bool Success
|
||||
*/
|
||||
private function receive_request($importer, $data) {
|
||||
private function receive_contact_request($importer, $data) {
|
||||
$author = unxmlify($data->author);
|
||||
$recipient = unxmlify($data->recipient);
|
||||
|
||||
if (!$author || !$recipient)
|
||||
return false;
|
||||
|
||||
$contact = self::contact_by_handle($importer["uid"],$author);
|
||||
// the current protocol version doesn't know these fields
|
||||
// That means that we will assume their existance
|
||||
if (isset($data->following))
|
||||
$following = (unxmlify($data->following) == "true");
|
||||
else
|
||||
$following = true;
|
||||
|
||||
if($contact) {
|
||||
if (isset($data->sharing))
|
||||
$sharing = (unxmlify($data->sharing) == "true");
|
||||
else
|
||||
$sharing = true;
|
||||
|
||||
$contact = self::contact_by_handle($importer["uid"],$author);
|
||||
|
||||
// perhaps we were already sharing with this person. Now they're sharing with us.
|
||||
// That makes us friends.
|
||||
|
||||
if ($contact) {
|
||||
if ($following AND $sharing) {
|
||||
self::receive_request_make_friend($importer, $contact);
|
||||
return true;
|
||||
} else /// @todo Handle all possible variations of adding and retracting of permissions
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$following AND $sharing AND in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
|
||||
logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG);
|
||||
return false;
|
||||
} elseif (!$following AND !$sharing) {
|
||||
logger("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = self::person_by_handle($author);
|
||||
|
@ -1824,8 +1848,10 @@ class diaspora {
|
|||
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
|
||||
// we are going to change the relationship and make them a follower.
|
||||
|
||||
if($importer["page-flags"] == PAGE_FREELOVE)
|
||||
if (($importer["page-flags"] == PAGE_FREELOVE) AND $sharing AND $following)
|
||||
$new_relation = CONTACT_IS_FRIEND;
|
||||
elseif (($importer["page-flags"] == PAGE_FREELOVE) AND $sharing)
|
||||
$new_relation = CONTACT_IS_SHARING;
|
||||
else
|
||||
$new_relation = CONTACT_IS_FOLLOWER;
|
||||
|
||||
|
|
Loading…
Reference in a new issue