$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s' OR `thr-parent` = '%s') limit 1",
// splitted into two queries for performance issues
$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1",
intval($datarray['uid']),
intval($datarray['contact-id']),
dbesc($datarray['verb']),
dbesc($parent_uri)
);
if($r&&count($r))
continue;
$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1",
intval($datarray['uid']),
intval($datarray['contact-id']),
dbesc($datarray['verb']),
dbesc($parent_uri),
dbesc($parent_uri)
);
if($r&&count($r))
@ -3009,11 +3018,21 @@ function local_delivery($importer,$data) {
$datarray['gravity']=GRAVITY_LIKE;
$datarray['last-child']=0;
// only one like or dislike per person
$r=q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr-parent` = '%s' or `parent-uri` = '%s') and deleted = 0 limit 1",
// splitted into two queries for performance issues
$r=q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`parent-uri` = '%s') and deleted = 0 limit 1",
intval($datarray['uid']),
intval($datarray['contact-id']),
dbesc($datarray['verb']),
dbesc($datarray['parent-uri'])
);
if($r&&count($r))
continue;
$r=q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr-parent` = '%s') and deleted = 0 limit 1",
intval($datarray['uid']),
intval($datarray['contact-id']),
dbesc($datarray['verb']),
dbesc($datarray['parent-uri']),
dbesc($datarray['parent-uri'])
);
@ -3181,11 +3200,20 @@ function local_delivery($importer,$data) {
$datarray['type']='activity';
$datarray['gravity']=GRAVITY_LIKE;
// only one like or dislike per person
$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s' OR `thr-parent` = '%s') limit 1",
// splitted into two queries for performance issues
$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1",
intval($datarray['uid']),
intval($datarray['contact-id']),
dbesc($datarray['verb']),
dbesc($parent_uri)
);
if($r&&count($r))
continue;
$r=q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1",