For now we will use standard Create verb for emoji reactions

This commit is contained in:
Mario
2024-02-27 10:31:27 +00:00
parent c639704f3c
commit b4f079c4b5
3 changed files with 63 additions and 70 deletions

View File

@@ -1227,11 +1227,6 @@ class Activity {
return $acts[$verb];
}
// Reactions will just map to normal activities
if (strpos($verb, ACTIVITY_REACT) !== false)
return 'Create';
if (strpos($verb, ACTIVITY_MOOD) !== false)
return 'Create';
@@ -2178,6 +2173,7 @@ class Activity {
$content['content'] = sprintf(t('🔁 Repeated %1$s\'s %2$s'), $mention, $act->obj['type']);
}
// TODO: Deprecated
if ($act->type === 'emojiReaction') {
$content['content'] = (($act->tgt && $act->tgt['type'] === 'Image') ? '[img=32x32]' . $act->tgt['url'] . '[/img]' : '&#x' . $act->tgt['name'] . ';');
}

View File

@@ -2,82 +2,79 @@
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Activity;
use Zotlabs\Daemon\Master;
class React extends \Zotlabs\Web\Controller {
class React extends Controller {
function get() {
if(! local_channel())
if (!local_channel()) {
return;
}
$sys = get_sys_channel();
$channel = \App::get_channel();
$channel = App::get_channel();
$postid = $_REQUEST['postid'];
if(! $postid)
if (!$postid) {
return;
}
$emoji = $_REQUEST['emoji'];
if($_REQUEST['emoji']) {
$i = q("select * from item where id = %d and uid = %d",
intval($postid),
intval(local_channel())
);
if(! $i) {
$i = q("select * from item where id = %d and uid = %d",
intval($postid),
intval($sys['channel_id'])
);
if($i) {
$i = [ copy_of_pubitem($channel, $i[0]['mid']) ];
$postid = (($i) ? $i[0]['id'] : 0);
}
}
if(! $i) {
return;
}
$uuid = item_message_id();
$n = array();
$n['aid'] = $channel['channel_account_id'];
$n['uid'] = $channel['channel_id'];
$n['item_origin'] = true;
$n['item_type'] = $i[0]['item_type'];
$n['parent'] = $postid;
$n['parent_mid'] = $i[0]['mid'];
$n['uuid'] = $uuid;
$n['mid'] = z_root() . '/item/' . $uuid;
$n['verb'] = ACTIVITY_REACT . '#' . $emoji;
$n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n";
$n['author_xchan'] = $channel['channel_hash'];
$n['tgt_type'] = 'Image';
$n['target'] = [
'type' => 'Image',
'name' => $emoji,
'url' => z_root() . '/images/emoji/' . $emoji . '.png'
];
$x = item_store($n);
retain_item($postid);
if($x['success']) {
$nid = $x['item_id'];
\Zotlabs\Daemon\Master::Summon(array('Notifier','like',$nid));
}
if (!$emoji) {
return;
}
$i = q("select * from item where id = %d and uid = %d",
intval($postid),
intval(local_channel())
);
if (!$i) {
$i = q("select * from item where id = %d and uid = %d",
intval($postid),
intval($sys['channel_id'])
);
if ($i) {
$i = [ copy_of_pubitem($channel, $i[0]['mid']) ];
$postid = (($i) ? $i[0]['id'] : 0);
}
}
if (!$i) {
return;
}
$uuid = item_message_id();
$n['aid'] = $channel['channel_account_id'];
$n['uid'] = $channel['channel_id'];
$n['item_origin'] = true;
$n['item_type'] = $i[0]['item_type'];
$n['parent'] = $postid;
$n['parent_mid'] = $i[0]['mid'];
$n['uuid'] = $uuid;
$n['mid'] = z_root() . '/item/' . $uuid;
$n['verb'] = 'Create';
$n['body'] = '[zmg=32x32]' . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]';
$n['author_xchan'] = $channel['channel_hash'];
$n['obj'] = Activity::fetch_item(['id' => $item['mid']]);
$n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR);
$x = item_store($n);
retain_item($postid);
if ($x['success']) {
$nid = $x['item_id'];
Master::Summon(['Notifier', 'like', $nid]);
}
}
}
}

View File

@@ -494,7 +494,7 @@ define('ZOT_APSCHEMA_REV', '/apschema/v1.11');
define('ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public');
define('ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react');
define('ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react'); // deprecated
define('ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like'); // AS2 Like
define('ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike'); // AS2 Dislike
@@ -521,12 +521,12 @@ define('ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag'); // unused
define('ACTIVITY_SHARE', 'Announce');
define('ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create'); // unused
define('ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create'); // deprecated
define('ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete'); // AS2 Delete
define('ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke');
define('ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood');
define('ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke'); // TODO: deprecate
define('ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood'); // TODO: deprecate
define('ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment'); // AS2 Note
define('ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note'); // AS2 Note