aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/React.php
blob: 85a1e2350ead43d6bbb34cd6abf9ec196e390fcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

namespace Zotlabs\Module;


class React extends \Zotlabs\Web\Controller {

	function get() {
		if(! local_channel())
			return;

		$postid = $_REQUEST['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)
				return;

			$channel = \App::get_channel();

			$n = array();
			$n['aid'] = $channel['channel_account_id'];
			$n['uid'] = $channel['channel_id'];
			$n['parent'] = $postid;
			$n['parent_mid'] = $i[0]['mid'];
			$n['mid'] = item_message_id();
			$n['verb'] = ACTIVITY_REACT . '#' . $emoji;
			$n['body'] = "\n\n[zmg]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n";
			$n['author_xchan'] = $channel['channel_hash'];

			$x = item_store($n); 
			if($x['success']) {
				$nid = $x['item_id'];
				 \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$nid));
			}

		}

	}

}