aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Like.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Like.php')
-rw-r--r--Zotlabs/Module/Like.php50
1 files changed, 19 insertions, 31 deletions
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index 2fb3fab83..94cc330eb 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -22,9 +22,9 @@ class Like extends Controller {
'like' => 'Like',
'dislike' => 'Dislike',
'announce' => ACTIVITY_SHARE,
- 'attendyes' => 'Accept',
- 'attendno' => 'Reject',
- 'attendmaybe' => 'TentativeAccept'
+ 'accept' => 'Accept',
+ 'reject' => 'Reject',
+ 'tentativeaccept' => 'TentativeAccept'
];
// unlike (etc.) reactions are an undo of positive reactions, rather than a negative action.
@@ -52,43 +52,31 @@ class Like extends Controller {
profile_load($parts[0]);
}
- $item_normal = item_normal();
-
if ($page_mode === 'list') {
+ $item_normal = item_normal();
+
$items = q("SELECT item.*, item.id AS item_id FROM item
WHERE uid = %d $item_normal
AND parent = %d",
intval($arr['item']['uid']),
intval($arr['item']['parent'])
);
+
xchan_query($items, true);
$items = fetch_post_tags($items, true);
$items = conv_sort($items, 'commented');
}
else {
- $activities = q("SELECT item.*, item.id AS item_id FROM item
- WHERE uid = %d $item_normal
- AND thr_parent = '%s'
- AND verb IN ('%s', '%s', '%s', '%s', '%s', '%s', 'Accept', 'Reject', 'TentativeAccept')",
- intval($arr['item']['uid']),
- dbesc($arr['item']['mid']),
- dbesc('Like'),
- dbesc('Dislike'),
- dbesc(ACTIVITY_SHARE),
- dbesc(ACTIVITY_ATTEND),
- dbesc(ACTIVITY_ATTENDNO),
- dbesc(ACTIVITY_ATTENDMAYBE)
- );
- xchan_query($activities, true);
- $items = array_merge([$arr['item']], $activities);
- $items = fetch_post_tags($items, true);
+ $item = item_by_item_id($arr['item']['id'], $arr['item']['parent'], type: $arr['item']['item_type']);
+ xchan_query($item, true);
+ $item = fetch_post_tags($item, true);
}
$ret = [
'success' => 1,
'orig_id' => $arr['orig_item_id'], //this is required for pubstream items where $item_id != $item['id']
'id' => $arr['item']['id'],
- 'html' => conversation($items, $conv_mode, true, $page_mode),
+ 'html' => conversation($item, $conv_mode, true, $page_mode),
];
// mod photos
@@ -139,7 +127,7 @@ class Like extends Controller {
$extended_like = false;
$object = $target = null;
$post_type = EMPTY_STR;
- $obj_type = EMPTY_STR;
+ $obj_type = EMPTY_STR;
if (argc() == 3) {
@@ -317,8 +305,6 @@ class Like extends Controller {
// parent, copy that as well.
if ($r) {
- $obj_type = $r[0]['obj_type'];
-
if ($r[0]['uid'] === $sys_channel['channel_id'] && local_channel()) {
$r = [copy_of_pubitem(App::get_channel(), $r[0]['mid'])];
}
@@ -334,6 +320,8 @@ class Like extends Controller {
$item = $r[0];
$owner_uid = $r[0]['uid'];
$owner_aid = $r[0]['aid'];
+ $obj_type = $r[0]['obj_type'];
+ $item_type = $r[0]['item_type'];
if ((array_key_exists('owner', $item)) && intval($item['owner']['abook_self']))
$can_comment = perm_is_allowed($item['uid'], $observer['xchan_hash'], 'post_comments');
@@ -374,7 +362,7 @@ class Like extends Controller {
$multi_undo = true;
}
- $item_normal = item_normal();
+ $item_normal = item_normal(type: $item_type);
$r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
AND author_xchan = '%s' AND thr_parent = '%s' and uid = %d ",
@@ -445,7 +433,7 @@ class Like extends Controller {
$arr['item_wall'] = 1;
}
else {
- switch ($item['object_type']) {
+ switch ($item['obj_type']) {
case 'Image':
$post_type = t('image');
break;
@@ -486,11 +474,11 @@ class Like extends Controller {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
if ($verb === 'dislike')
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- if ($verb === 'attendyes')
+ if ($verb === 'accept')
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
- if ($verb === 'attendno')
+ if ($verb === 'reject')
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
- if ($verb === 'attendmaybe')
+ if ($verb === 'tentativeaccept')
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
if (!isset($bodyverb))
@@ -573,7 +561,7 @@ class Like extends Controller {
call_hooks('post_local_end', $arr);
- if ($is_rsvp && in_array($verb, ['attendyes', 'attendmaybe'])) {
+ if ($is_rsvp && in_array($verb, ['accept', 'tentativeaccept'])) {
event_addtocal($item_id, local_channel());
}