4 use Friendica\Core\System;
5 use Friendica\Database\DBA;
6 use Friendica\Model\Item;
8 function ignored_init(App $a)
15 $message_id = intval($a->argv[1]);
22 $thread = Item::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $message_id]);
23 if (!DBA::isResult($thread)) {
27 // Numeric values are needed for the json output further below
28 $ignored = ($thread['ignored'] ? 0 : 1);
30 if ($thread['uid'] != 0) {
31 DBA::update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
33 DBA::update('user-item', ['ignored' => $ignored], ['iid' => $message_id, 'uid' => local_user()], true);
36 // See if we've been passed a return path to redirect to
37 $return_path = defaults($_REQUEST, 'return', '');
39 $rand = '_=' . time();
40 if (strpos($return_path, '?')) {
46 $a->internalRedirect($return_path . $rand);
49 // the json doesn't really matter, it will either be 0 or 1
51 echo json_encode($ignored);