improvements in duplicate like detection, especially w/r/t event participation

This commit is contained in:
friendica 2015-02-10 17:49:46 -08:00
parent 9a773b45e4
commit 79da33dafd
2 changed files with 29 additions and 8 deletions

View file

@ -374,7 +374,7 @@ function mark_orphan_hubsxchans() {
if($dirmode == DIRECTORY_MODE_NORMAL) if($dirmode == DIRECTORY_MODE_NORMAL)
return; return;
$r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d)>0 $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where (hubloc_status & %d) = 0
and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", and hubloc_network = 'zot' and hubloc_connected < %s - interval %s",
intval(HUBLOC_OFFLINE), intval(HUBLOC_OFFLINE),
intval(HUBLOC_OFFLINE), intval(HUBLOC_OFFLINE),

View file

@ -287,21 +287,42 @@ function like_content(&$a) {
else else
killme(); killme();
$r = q("SELECT id FROM item WHERE verb = '%s' AND item_restrict = 0
AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') LIMIT 1", $verbs = " '".dbesc($activity)."' ";
dbesc($activity), $multi_undo = 0;
// event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
$multi_undo = 1;
}
if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
$verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
$multi_undo = 1;
}
$r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
dbesc($observer['xchan_hash']), dbesc($observer['xchan_hash']),
intval($item_id), intval($item_id),
dbesc($item['mid']) dbesc($item['mid']),
intval($owner_uid)
); );
if($r) { if($r) {
// already liked it. Drop that item. // already liked it. Drop that item.
require_once('include/items.php'); require_once('include/items.php');
drop_item($r[0]['id'],false,DROPITEM_PHASE1); foreach($r as $rr) {
return; drop_item($rr['id'],false,DROPITEM_PHASE1);
}
if($interactive)
return;
if(! $multi_undo)
killme();
} }
} }
$mid = item_message_id(); $mid = item_message_id();