mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 02:35:12 +00:00
likes are quasi working again - at least an activity item is stored and it mostly has correct data, but displaying it needs improvement.
This commit is contained in:
parent
7d926213c6
commit
82e74e3520
3 changed files with 41 additions and 47 deletions
|
@ -61,7 +61,7 @@ function notifier_run($argv, $argc){
|
|||
require_once("datetime.php");
|
||||
require_once('include/items.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/email.php');
|
||||
|
||||
load_config('config');
|
||||
load_config('system');
|
||||
|
||||
|
@ -92,7 +92,7 @@ function notifier_run($argv, $argc){
|
|||
$top_level = false;
|
||||
$recipients = array();
|
||||
$url_recipients = array();
|
||||
|
||||
return;
|
||||
$normal_mode = true;
|
||||
|
||||
if($cmd === 'mail') {
|
||||
|
|
|
@ -223,6 +223,9 @@
|
|||
|
||||
function NavUpdate() {
|
||||
|
||||
if(liking)
|
||||
$('.like-rotator').hide();
|
||||
|
||||
if(! stopped) {
|
||||
|
||||
var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
|
||||
|
|
81
mod/like.php
81
mod/like.php
|
@ -7,13 +7,11 @@ require_once('include/items.php');
|
|||
|
||||
function like_content(&$a) {
|
||||
|
||||
if(! local_user() && ! remote_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$observer = $a->get_observer();
|
||||
|
||||
|
||||
|
||||
$verb = notags(trim($_GET['verb']));
|
||||
|
||||
if(! $verb)
|
||||
|
@ -35,17 +33,16 @@ function like_content(&$a) {
|
|||
}
|
||||
|
||||
|
||||
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
|
||||
$item_id = ((argc() > 1) ? notags(trim(argv(1))) : 0);
|
||||
|
||||
logger('like: verb ' . $verb . ' item ' . $item_id);
|
||||
logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG);
|
||||
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
|
||||
dbesc($item_id),
|
||||
$r = q("SELECT * FROM item WHERE id = %d and item_restrict = 0 LIMIT 1",
|
||||
dbesc($item_id)
|
||||
);
|
||||
|
||||
if(! $item_id || (! count($r))) {
|
||||
if(! $item_id || (! $r)) {
|
||||
logger('like: no item ' . $item_id);
|
||||
return;
|
||||
}
|
||||
|
@ -54,11 +51,14 @@ function like_content(&$a) {
|
|||
|
||||
$owner_uid = $item['uid'];
|
||||
|
||||
if(! can_write_wall($a,$owner_uid)) {
|
||||
if(! perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_comments')) {
|
||||
notice( t('Permission denied') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$remote_owner = null;
|
||||
$remote_owner = $item['owner_xchan'];
|
||||
|
||||
|
||||
|
||||
// fixme
|
||||
// if(! $item['wall']) {
|
||||
|
@ -110,25 +110,26 @@ function like_content(&$a) {
|
|||
// }
|
||||
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
|
||||
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent_uri` = '%s' OR `thr_parent` = '%s') LIMIT 1",
|
||||
$r = q("SELECT * FROM item WHERE verb = '%s' AND ( item_restrict & %d )
|
||||
AND owner_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') LIMIT 1",
|
||||
dbesc($activity),
|
||||
intval($contact['id']),
|
||||
dbesc($item_id),
|
||||
dbesc($item_id),
|
||||
intval(ITEM_DELETED),
|
||||
dbesc($remote_owner),
|
||||
intval($item_id),
|
||||
dbesc($item['uri'])
|
||||
);
|
||||
if(count($r)) {
|
||||
if($r) {
|
||||
$like_item = $r[0];
|
||||
|
||||
// Already voted, undo it
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
// Already liked/disliked it, delete it
|
||||
|
||||
$r = q("UPDATE item SET item_restrict = ( item_restrict ^ %d ), changed = '%s' WHERE id = %d LIMIT 1",
|
||||
intval(ITEM_DELETED),
|
||||
dbesc(datetime_convert()),
|
||||
intval($like_item['id'])
|
||||
);
|
||||
|
||||
$like_item_id = $like_item['id'];
|
||||
proc_run('php',"include/notifier.php","like","$like_item_id");
|
||||
proc_run('php',"include/notifier.php","like",$like_item['id']);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -160,25 +161,26 @@ function like_content(&$a) {
|
|||
if(! isset($bodyverb))
|
||||
return;
|
||||
|
||||
$item_flags = ITEM_ORIGIN;
|
||||
if($item['item_flags'] & ITEM_WALL)
|
||||
$item_flags |= ITEM_WALL;
|
||||
|
||||
|
||||
$arr = array();
|
||||
|
||||
$arr['uri'] = $uri;
|
||||
$arr['uid'] = $owner_uid;
|
||||
// $arr['contact-id'] = $contact['id'];
|
||||
$arr['type'] = 'activity';
|
||||
// $arr['wall'] = $item['wall'];
|
||||
// $arr['origin'] = 1;
|
||||
// $arr['gravity'] = GRAVITY_LIKE;
|
||||
$arr['parent'] = $item['id'];
|
||||
$arr['parent_uri'] = $item['uri'];
|
||||
$arr['thr_parent'] = $item['uri'];
|
||||
$arr['owner_xchan'] = $remote_owner['xchan_hash'];
|
||||
$arr['uri'] = $uri;
|
||||
$arr['uid'] = $owner_uid;
|
||||
$arr['item_flags'] = $item_flags;
|
||||
$arr['parent'] = $item['id'];
|
||||
$arr['parent_uri'] = $item['uri'];
|
||||
$arr['thr_parent'] = $item['uri'];
|
||||
$arr['owner_xchan'] = $remote_owner;
|
||||
$arr['author_xchan'] = $observer['xchan_hash'];
|
||||
|
||||
|
||||
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
||||
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||
$plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
|
||||
$ulink = '[url=' . $remote_owner['xchan_url'] . ']' . $remote_owner['xchan_name'] . '[/url]';
|
||||
$alink = '[url=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/url]';
|
||||
$plink = '[url=' . $a->get_baseurl() . '/display/' . $item['uri'] . ']' . $post_type . '[/url]';
|
||||
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
|
||||
|
||||
$arr['verb'] = $activity;
|
||||
|
@ -191,19 +193,8 @@ function like_content(&$a) {
|
|||
$arr['deny_gid'] = $item['deny_gid'];
|
||||
|
||||
|
||||
// $arr['visible'] = 1;
|
||||
// $arr['unseen'] = 1;
|
||||
|
||||
$post_id = item_store($arr);
|
||||
|
||||
// if(! $item['visible']) {
|
||||
// $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
// intval($item['id']),
|
||||
// intval($owner_uid)
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
|
|
Loading…
Reference in a new issue