<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseApi;
+use Friendica\Network\HTTPException\ForbiddenException;
/**
* @see https://docs.joinmastodon.org/methods/notifications/
*/
class Dismiss extends BaseApi
{
- public static function post(array $parameters = [])
+ protected function post(array $request = [])
{
- self::checkAllowedScope(self::SCOPE_WRITE);
+ $this->checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
- if (empty($parameters['id'])) {
- DI::mstdnError()->UnprocessableEntity();
+ if (empty($this->parameters['id'])) {
+ $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
}
- DBA::update('notification', ['seen' => true], ['uid' => $uid, 'id' => $parameters['id']]);
+ $condition = ['id' => $this->parameters['id']];
+ $Notification = DI::notification()->selectOneForUser($uid, $condition);
+ $Notification->setDismissed();
+ DI::notification()->save($Notification);
- System::jsonExit([]);
+ $this->jsonExit([]);
}
}