+ // Do we already have this item?
+ // We have to check several networks since Friendica posts could be repeated via OStatus (maybe Diasporsa as well)
+ if (in_array(trim($arr['network']), array(NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""))) {
+ $r = q("SELECT `id`, `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` IN ('%s', '%s', '%s') LIMIT 1",
+ dbesc(trim($arr['uri'])),
+ intval($uid),
+ dbesc(NETWORK_DIASPORA),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_OSTATUS)
+ );
+ if ($r) {
+ // We only log the entries with a different user id than 0. Otherwise we would have too many false positives
+ if ($uid != 0)
+ logger("Item with uri ".$arr['uri']." already existed for user ".$uid." with id ".$r[0]["id"]." target network ".$r[0]["network"]." - new network: ".$arr['network']);
+ return($r[0]["id"]);
+ }
+ }
+