/**
  * @NoAdminRequired
  *
  * @param array $parameters
  * @return \OC_OCS_Result
  */
 public function deleteNotification(array $parameters)
 {
     if (!isset($parameters['id'])) {
         return new \OC_OCS_Result(null, HTTP::STATUS_NOT_FOUND);
     }
     $id = (int) $parameters['id'];
     $this->handler->deleteById($id, $this->getCurrentUser());
     return new \OC_OCS_Result();
 }
예제 #2
0
 public function testDeleteById()
 {
     $notification = $this->getNotification(['getApp' => 'testing_notifications', 'getUser' => 'test_user1', 'getTimestamp' => time(), 'getObjectType' => 'notification', 'getObjectId' => 1337, 'getSubject' => 'subject', 'getSubjectParameters' => [], 'getMessage' => 'message', 'getMessageParameters' => [], 'getLink' => 'link', 'getIcon' => 'icon', 'getActions' => [['getLabel' => 'action_label', 'getIcon' => 'action_icon', 'getLink' => 'action_link', 'getRequestType' => 'GET']]]);
     $limitedNotification = $this->getNotification(['getApp' => 'testing_notifications', 'getUser' => 'test_user1']);
     // Make sure there is no notification
     $this->assertSame(0, $this->handler->count($limitedNotification));
     $notifications = $this->handler->get($limitedNotification);
     $this->assertCount(0, $notifications);
     // Add and count
     $this->handler->add($notification);
     $this->assertSame(1, $this->handler->count($limitedNotification));
     // Get and count
     $notifications = $this->handler->get($limitedNotification);
     $this->assertCount(1, $notifications);
     reset($notifications);
     $notificationId = key($notifications);
     // Delete with wrong user
     $this->handler->deleteById($notificationId, 'test_user2');
     $this->assertSame(1, $this->handler->count($limitedNotification), 'Wrong notification count for user1 after trying to delete for user2');
     // Delete and count
     $this->handler->deleteById($notificationId, 'test_user1');
     $this->assertSame(0, $this->handler->count($limitedNotification), 'Wrong notification count for user1 after deleting');
 }
 /**
  * @NoAdminRequired
  *
  * @param int $id
  * @return Response
  */
 public function delete($id)
 {
     $this->handler->deleteById($id, $this->user);
     return new Response();
 }