aboutsummaryrefslogtreecommitdiffstats
path: root/mod/like.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/like.php')
-rwxr-xr-xmod/like.php53
1 files changed, 35 insertions, 18 deletions
diff --git a/mod/like.php b/mod/like.php
index 7c3df98ba..a76867422 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -48,11 +48,20 @@ function like_content(&$a) {
$item = $r[0];
+ $sys = get_sys_channel();
+
$owner_uid = $item['uid'];
+ $owner_aid = $item['aid'];
- if(! perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_comments')) {
- notice( t('Permission denied') . EOL);
- killme();
+ // if this is a "discover" item, (item['uid'] is the sys channel),
+ // fallback to the item comment policy, which should've been
+ // respected when generating the conversation thread.
+ // Even if the activity is rejected by the item owner, it should still get attached
+ // to the local discover conversation on this site.
+
+ if(($owner_uid != $sys['channel_id']) && (! perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_comments'))) {
+ notice( t('Permission denied') . EOL);
+ killme();
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
@@ -78,7 +87,7 @@ function like_content(&$a) {
dbesc($activity),
dbesc($observer['xchan_hash']),
intval($item_id),
- dbesc($item['uri'])
+ dbesc($item['mid'])
);
if($r) {
$like_item = $r[0];
@@ -97,22 +106,24 @@ function like_content(&$a) {
- $uri = item_message_id();
+ $mid = item_message_id();
- $post_type = (($item['resource_type'] === 'photo') ? $t('photo') : t('status'));
+ $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status'));
- $links = array(array('rel' => 'alternate','type' => 'text/html',
- 'href' => z_root() . '/display/' . $item['uri']));
+ $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink']));
$objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
$body = $item['body'];
$obj = json_encode(array(
'type' => $objtype,
- 'id' => $item['uri'],
+ 'id' => $item['mid'],
+ 'parent' => (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']),
'link' => $links,
'title' => $item['title'],
'content' => $item['body'],
+ 'created' => $item['created'],
+ 'edited' => $item['edited'],
'author' => array(
'name' => $item_author['xchan_name'],
'address' => $item_author['xchan_addr'],
@@ -124,6 +135,9 @@ function like_content(&$a) {
),
));
+ if(! ($item['item_flags'] & ITEM_THREAD_TOP))
+ $post_type = 'comment';
+
if($verb === 'like')
$bodyverb = t('%1$s likes %2$s\'s %3$s');
if($verb === 'dislike')
@@ -132,28 +146,29 @@ function like_content(&$a) {
if(! isset($bodyverb))
return;
- $item_flags = ITEM_ORIGIN;
+ $item_flags = ITEM_ORIGIN | ITEM_NOTSHOWN;
if($item['item_flags'] & ITEM_WALL)
$item_flags |= ITEM_WALL;
$arr = array();
- $arr['uri'] = $uri;
+ $arr['mid'] = $mid;
+ $arr['aid'] = $owner_aid;
$arr['uid'] = $owner_uid;
$arr['item_flags'] = $item_flags;
$arr['parent'] = $item['id'];
- $arr['parent_uri'] = $item['uri'];
- $arr['thr_parent'] = $item['uri'];
+ $arr['parent_mid'] = $item['mid'];
+ $arr['thr_parent'] = $item['mid'];
$arr['owner_xchan'] = $thread_owner['xchan_hash'];
$arr['author_xchan'] = $observer['xchan_hash'];
- $ulink = '[url=' . $item_owner['xchan_url'] . ']' . $item_owner['xchan_name'] . '[/url]';
- $alink = '[url=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/url]';
- $plink = '[url=' . $a->get_baseurl() . '/display/' . $item['uri'] . ']' . $post_type . '[/url]';
+ $ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]';
+ $alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]';
+ $plink = '[zrl=' . $a->get_baseurl() . '/display/' . $item['mid'] . ']' . $post_type . '[/zrl]';
- $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
+ $arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
$arr['verb'] = $activity;
$arr['obj_type'] = $objtype;
@@ -164,7 +179,9 @@ function like_content(&$a) {
$arr['deny_cid'] = $item['deny_cid'];
$arr['deny_gid'] = $item['deny_gid'];
- $post_id = item_store($arr);
+
+ $post = item_store($arr);
+ $post_id = $post['item_id'];
$arr['id'] = $post_id;