]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_confirm.php
Merge branch 'master' of git://github.com/friendica/friendica
[friendica.git] / mod / dfrn_confirm.php
old mode 100755 (executable)
new mode 100644 (file)
index abacd99..0bc3ea7
@@ -107,7 +107,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                 *
                 */
 
-               $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d LIMIT 1",
+               $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d AND `duplex` = 0 LIMIT 1",
                        dbesc($dfrn_id),
                        intval($cid),
                        intval($uid)
@@ -116,6 +116,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                if(! count($r)) {
                        logger('dfrn_confirm: Contact not found in DB.'); 
                        notice( t('Contact not found.') . EOL );
+                       notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
                        return;
                }
 
@@ -252,7 +253,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        $message = unxmlify($xml->message);   // human readable text of what may have gone wrong.
                        switch($status) {
                                case 0:
-                                       notice( t("Confirmation completed successfully.") . EOL);
+                                       info( t("Confirmation completed successfully.") . EOL);
                                        if(strlen($message))
                                                notice( t('Remote site reported: ') . $message . EOL);
                                        break;
@@ -631,6 +632,15 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        xml_status(3,$message);
                }
 
+               // It's possible that the other person also requested friendship.
+               // If it is a duplex relationship, ditch the issued-id if one exists. 
+
+               if($duplex) {
+                       $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1",
+                               intval($dfrn_record)
+                       );
+               }
+
                // We're good but now we have to scrape the profile photo and send notifications.