From b4f079c4b51d4b4918b1901ee351bc40aeb343da Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 27 Feb 2024 10:31:27 +0000 Subject: For now we will use standard Create verb for emoji reactions --- Zotlabs/Module/React.php | 103 +++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 53 deletions(-) (limited to 'Zotlabs/Module/React.php') diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php index f80b04a3f..6a3b525b2 100644 --- a/Zotlabs/Module/React.php +++ b/Zotlabs/Module/React.php @@ -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 (!$emoji) { + return; + } - 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(local_channel()) + intval($sys['channel_id']) ); - 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 ($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]); + } } -} \ No newline at end of file +} -- cgit v1.2.3 From 46fa26502b285213f3438abb1e3bd1482eb55bf5 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Mar 2024 20:53:18 +0000 Subject: more work on emojis --- Zotlabs/Module/React.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/React.php') diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php index 6a3b525b2..e04b9b257 100644 --- a/Zotlabs/Module/React.php +++ b/Zotlabs/Module/React.php @@ -24,7 +24,15 @@ class React extends Controller { return; } - $emoji = $_REQUEST['emoji']; + $shortname = $_REQUEST['emoji']; + + $emojis = get_emojis(); + + if (!isset($emojis[$shortname])) { + return; + } + + $emoji = $emojis[$shortname]; if (!$emoji) { return; @@ -62,10 +70,19 @@ class React extends Controller { $n['uuid'] = $uuid; $n['mid'] = z_root() . '/item/' . $uuid; $n['verb'] = 'Create'; - $n['body'] = '[zmg=32x32]' . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]'; + $n['body'] = $emoji['shortname']; //'[img class="emoji single-emoji"]' . z_root() . '/' . $emoji['filepath'] . '[/img]'; $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); + // $n['obj'] = Activity::fetch_item(['id' => $i[0]['mid']]); + // $n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR); + + $n['term'][] = [ + 'uid' => $channel['channel_id'], + 'ttype' => TERM_EMOJI, + 'otype' => TERM_OBJ_POST, + 'term' => $emoji['shortname'], + 'url' => z_root() . '/emoji/' . $shortname, + 'imgurl' => z_root() . '/' . $emoji['filepath'] + ]; $x = item_store($n); -- cgit v1.2.3