]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Merge pull request #8211 from nupplaphil/task/mod_crepair
[friendica.git] / include / api.php
index b602dcd6879624ee9fdaa495f7e86d0898d71316..6f5120691cffe56f9e9ea9de52c763635d40b2cc 100644 (file)
@@ -5903,11 +5903,11 @@ function api_friendica_notification_seen($type)
        $id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
 
        try {
-               $notification = DI::notify()->getByID($id);
-               $notification->setSeen();
+               $notify = DI::notify()->getByID($id);
+               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::OTYPE_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);
@@ -5918,7 +5918,9 @@ function api_friendica_notification_seen($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);
        }
 }