<?php
/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
* Friendica implementation of statusnet/twitter API
*
* @file include/api.php
use Friendica\App;
use Friendica\Content\ContactSelector;
-use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Hook;
use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo;
-use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Model\UserItem;
use Friendica\Network\FKOAuth1;
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
try {
- $notification = DI::notify()->getByID($id);
- $notification->setSeen();
+ $notify = DI::notify()->getByID($id, api_user());
+ DI::notify()->setSeen(true, $notify);
- if ($notification->otype === Notify::OTYPE_ITEM) {
- $item = Item::selectFirstForUser(api_user(), [], ['id' => $notification->iid, 'uid' => api_user()]);
+ if ($notify->otype === Notify\ObjectType::ITEM) {
+ $item = Item::selectFirstForUser(api_user(), [], ['id' => $notify->iid, 'uid' => api_user()]);
if (DBA::isResult($item)) {
// we found the item, return it to the user
$ret = api_format_items([$item], $user_info, false, $type);
}
return api_format_data('result', $type, ['result' => "success"]);
} catch (NotFoundException $e) {
- throw new BadRequestException('Invalid argument');
+ throw new BadRequestException('Invalid argument', $e);
+ } catch (Exception $e) {
+ throw new InternalServerErrorException('Internal Server exception', $e);
}
}