4 use Friendica\Database\DBA;
5 use Friendica\Model\Item;
7 function ignored_init(App $a)
14 $message_id = intval($a->argv[1]);
17 if (empty($message_id)) {
21 $thread = Item::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $message_id]);
22 if (!DBA::isResult($thread)) {
26 // Numeric values are needed for the json output further below
27 $ignored = ($thread['ignored'] ? 0 : 1);
29 if ($thread['uid'] != 0) {
30 DBA::update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
32 DBA::update('user-item', ['ignored' => $ignored], ['iid' => $message_id, 'uid' => local_user()], true);
35 // See if we've been passed a return path to redirect to
36 $return_path = defaults($_REQUEST, 'return', '');
38 $rand = '_=' . time();
39 if (strpos($return_path, '?')) {
45 $a->internalRedirect($return_path . $rand);
48 // the json doesn't really matter, it will either be 0 or 1
50 echo json_encode($ignored);