Browse Source

Diaspora comments/likes: The contact id and the network is now taken from the contact

tags/3.4.3
Michael Vogel 3 years ago
parent
commit
107204f405
1 changed files with 26 additions and 9 deletions
  1. 26
    9
      include/diaspora.php

+ 26
- 9
include/diaspora.php View File

@@ -1386,11 +1386,6 @@ function diaspora_asphoto($importer,$xml,$msg) {
1386 1386
 
1387 1387
 }
1388 1388
 
1389
-
1390
-
1391
-
1392
-
1393
-
1394 1389
 function diaspora_comment($importer,$xml,$msg) {
1395 1390
 
1396 1391
 	$a = get_app();
@@ -1510,16 +1505,27 @@ function diaspora_comment($importer,$xml,$msg) {
1510 1505
 		}
1511 1506
 	}
1512 1507
 
1508
+	// Fetch the contact id - if we know this contact
1509
+	$r = q("SELECT `id`, `network` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
1510
+		dbesc(normalise_link($person['url'])), intval($importer['uid']));
1511
+	if ($r) {
1512
+		$cid = $r[0]['id'];
1513
+		$network = $r[0]['network'];
1514
+	} else {
1515
+		$cid = $contact['id'];
1516
+		$network = NETWORK_DIASPORA;
1517
+	}
1518
+
1513 1519
 	$body = diaspora2bb($text);
1514 1520
 	$message_id = $diaspora_handle . ':' . $guid;
1515 1521
 
1516 1522
 	$datarray = array();
1517 1523
 
1518 1524
 	$datarray['uid'] = $importer['uid'];
1519
-	$datarray['contact-id'] = $contact['id'];
1525
+	$datarray['contact-id'] = $cid;
1520 1526
 	$datarray['type'] = 'remote-comment';
1521 1527
 	$datarray['wall'] = $parent_item['wall'];
1522
-	$datarray['network']  = NETWORK_DIASPORA;
1528
+	$datarray['network']  = $network;
1523 1529
 	$datarray['verb'] = ACTIVITY_POST;
1524 1530
 	$datarray['gravity'] = GRAVITY_COMMENT;
1525 1531
 	$datarray['guid'] = $guid;
@@ -2155,13 +2161,24 @@ function diaspora_like($importer,$xml,$msg) {
2155 2161
 EOT;
2156 2162
 	$bodyverb = t('%1$s likes %2$s\'s %3$s');
2157 2163
 
2164
+	// Fetch the contact id - if we know this contact
2165
+	$r = q("SELECT `id`, `network` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
2166
+		dbesc(normalise_link($person['url'])), intval($importer['uid']));
2167
+	if ($r) {
2168
+		$cid = $r[0]['id'];
2169
+		$network = $r[0]['network'];
2170
+	} else {
2171
+		$cid = $contact['id'];
2172
+		$network = NETWORK_DIASPORA;
2173
+	}
2174
+
2158 2175
 	$arr = array();
2159 2176
 
2160 2177
 	$arr['uri'] = $uri;
2161 2178
 	$arr['uid'] = $importer['uid'];
2162 2179
 	$arr['guid'] = $guid;
2163
-	$arr['network']  = NETWORK_DIASPORA;
2164
-	$arr['contact-id'] = $contact['id'];
2180
+	$arr['network']  = $network;
2181
+	$arr['contact-id'] = $cid;
2165 2182
 	$arr['type'] = 'activity';
2166 2183
 	$arr['wall'] = $parent_item['wall'];
2167 2184
 	$arr['gravity'] = GRAVITY_LIKE;

Loading…
Cancel
Save