+ // perhaps we were already sharing with this person. Now they're sharing with us.
+ // That makes us friends.
+ if ($contact) {
+ if ($following AND $sharing) {
+ logger("Author ".$author." (Contact ".$contact["id"].") wants to have a bidirectional conection.", LOGGER_DEBUG);
+ self::receive_request_make_friend($importer, $contact);
+
+ // refetch the contact array
+ $contact = self::contact_by_handle($importer["uid"],$author);
+
+ // If we are now friends, we are sending a share message.
+ // Normally we needn't to do so, but the first message could have been vanished.
+ if (in_array($contact["rel"], array(CONTACT_IS_FRIEND, CONTACT_IS_FOLLOWER))) {
+ $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
+ if($u) {
+ logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
+ $ret = self::send_share($u[0], $contact);
+ }
+ }
+ return true;
+ } else { /// @todo Handle all possible variations of adding and retracting of permissions
+ logger("Author ".$author." (Contact ".$contact["id"].") wants to change the relationship: Following: ".$following." - sharing: ".$sharing. "(By now unsupported)", LOGGER_DEBUG);
+ 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;
+ } elseif (!$following AND $sharing) {
+ logger("Author ".$author." wants to share with us.", LOGGER_DEBUG);
+ } elseif ($following AND $sharing) {
+ logger("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG);
+ } elseif ($following AND !$sharing) {
+ logger("Author ".$author." wants to listen to us.", LOGGER_DEBUG);