Use another uid for likes
This commit is contained in:
parent
d7039c6862
commit
1c72a71933
1 changed files with 14 additions and 13 deletions
|
@ -79,26 +79,28 @@ function do_like($item_id, $verb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = $items[0];
|
$item = $items[0];
|
||||||
|
$uid = $item['uid'];
|
||||||
|
|
||||||
if (!can_write_wall($a, $item['uid']) && ($item['uid'] != 0)) {
|
if (!can_write_wall($a, $uid) && (($uid != 0) || !local_user())) {
|
||||||
logger('like: unable to write on wall ' . $item['uid']);
|
logger('like: unable to write on wall ' . $uid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves the local post owner
|
// Retrieves the local post owner
|
||||||
if ($item['uid'] != 0) {
|
if ($uid != 0) {
|
||||||
$owners = q("SELECT `contact`.* FROM `contact`
|
$owners = q("SELECT `contact`.* FROM `contact`
|
||||||
WHERE `contact`.`self`
|
WHERE `contact`.`self`
|
||||||
AND `contact`.`uid` = %d",
|
AND `contact`.`uid` = %d",
|
||||||
intval($item['uid'])
|
intval($uid)
|
||||||
);
|
);
|
||||||
if (DBM::is_result($owners)) {
|
if (DBM::is_result($owners)) {
|
||||||
$owner_self_contact = $owners[0];
|
$owner_self_contact = $owners[0];
|
||||||
} else {
|
} else {
|
||||||
logger('like: unknown owner ' . $item['uid']);
|
logger('like: unknown owner ' . $uid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$uid = local_user();
|
||||||
$owner_self_contact = ['uid' => 0, 'nick' => 'feed-item'];
|
$owner_self_contact = ['uid' => 0, 'nick' => 'feed-item'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +118,11 @@ function do_like($item_id, $verb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contact-id is the uid-dependant author contact
|
// Contact-id is the uid-dependant author contact
|
||||||
if (local_user() == $item['uid']) {
|
if (local_user() == $uid) {
|
||||||
$item_contact_id = $owner_self_contact['id'];
|
$item_contact_id = $owner_self_contact['id'];
|
||||||
$item_contact = $owner_self_contact;
|
$item_contact = $owner_self_contact;
|
||||||
} else {
|
} else {
|
||||||
$item_contact_id = Contact::getIdForURL($author_contact['url'], $item['uid']);
|
$item_contact_id = Contact::getIdForURL($author_contact['url'], $uid);
|
||||||
|
|
||||||
$contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
|
$contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
|
||||||
intval($item_contact_id)
|
intval($item_contact_id)
|
||||||
|
@ -150,7 +152,7 @@ function do_like($item_id, $verb) {
|
||||||
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
|
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
|
||||||
LIMIT 1",
|
LIMIT 1",
|
||||||
intval($author_contact['id']),
|
intval($author_contact['id']),
|
||||||
intval($item['uid']),
|
intval($uid),
|
||||||
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -209,8 +211,8 @@ EOT;
|
||||||
|
|
||||||
$new_item = array(
|
$new_item = array(
|
||||||
'guid' => get_guid(32),
|
'guid' => get_guid(32),
|
||||||
'uri' => item_new_uri($a->get_hostname(), $item['uid']),
|
'uri' => item_new_uri($a->get_hostname(), $uid),
|
||||||
'uid' => $item['uid'],
|
'uid' => $uid,
|
||||||
'contact-id' => $item_contact_id,
|
'contact-id' => $item_contact_id,
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'wall' => $item['wall'],
|
'wall' => $item['wall'],
|
||||||
|
@ -244,9 +246,8 @@ EOT;
|
||||||
|
|
||||||
// @todo: Explain this block
|
// @todo: Explain this block
|
||||||
if (! $item['visible']) {
|
if (! $item['visible']) {
|
||||||
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
|
q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
|
||||||
intval($item['id']),
|
intval($item['id'])
|
||||||
intval($item['uid'])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue