From 2c0404fdc88081f68af18a788d2f285e5c059f47 Mon Sep 17 00:00:00 2001
From: Friendika <info@friendika.com>
Date: Tue, 16 Aug 2011 00:52:34 -0700
Subject: [PATCH] cleanup after refactor

---
 include/diaspora.php | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/include/diaspora.php b/include/diaspora.php
index 95673996fe..69d2dff195 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -257,8 +257,8 @@ function diaspora_get_contact_by_handle($uid,$handle) {
 
 function diaspora_request($importer,$xml) {
 
-	$sender_handle = $xml->sender_handle;
-	$recipient_handle = $xml->recipient_handle;
+	$sender_handle = unxmlify($xml->sender_handle);
+	$recipient_handle = unxmlify($xml->recipient_handle);
 
 	if(! $sender_handle || ! $recipient_handle)
 		return;
@@ -303,21 +303,12 @@ function diaspora_request($importer,$xml) {
 	);
 		 
 	// find the contact record we just created
-	$contact_record = null;
-	if($r) {	
-		$r = q("SELECT `id` FROM `contact` 
-				WHERE `uid` = %d AND `addr` = '%s' AND `poll` = '%s' LIMIT 1",
-				intval($importer['uid']),
-				$ret['addr'],
-				$ret['poll']
-		);
-		if(count($r)) 
-			$contact_record = $r[0];
-	}
+
+	$contact_record = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
 
 	$hash = random_string() . (string) time();   // Generate a confirm_key
 	
-	if(is_array($contact_record)) {
+	if($contact_record) {
 		$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`,`blocked`)
 			VALUES ( %d, %d, 1, %d, '%s', '%s', '%s', 0 )",
 			intval($importer['uid']),
@@ -328,10 +319,8 @@ function diaspora_request($importer,$xml) {
 			dbesc(datetime_convert())
 		);
 	}
-	
 
 	return;
-
 }
 
 function diaspora_post($importer,$xml) {
@@ -370,7 +359,6 @@ function diaspora_post($importer,$xml) {
 		);
 	}
 
-
 	$created = unxmlify($xml->created_at);
 	$private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
 
@@ -422,7 +410,6 @@ function diaspora_post($importer,$xml) {
 
 	return;
 
-
 }
 
 function diaspora_comment($importer,$xml) {
-- 
2.39.5