mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-12-25 04:58:59 +00:00
Can delete all the notifications of a user
This commit is contained in:
parent
6d96091c3f
commit
3a3c6d9787
@ -96,6 +96,22 @@ class notificationsController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the notifications of a user
|
||||
*
|
||||
* @url POST notifications/delete_all
|
||||
*/
|
||||
public function delete_all(){
|
||||
|
||||
user_login_required();
|
||||
|
||||
//Try to delete the list of notifications of the user
|
||||
if(!components()->notifications->delete_all_user(userID))
|
||||
Rest_fatal_error(500, "Could not delete user's notifications !");
|
||||
|
||||
//Success
|
||||
return array("success" => "The notifications have been deleted !");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid notification ID in a POST request
|
||||
|
@ -274,6 +274,22 @@ class notificationComponent {
|
||||
return CS::get()->db->deleteEntry(self::NOTIFICATIONS_TABLE, $conditions, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the notifications of a user
|
||||
*
|
||||
* @param int $userID The ID of the target user
|
||||
* @return bool TRUE for a success / FALSE for a failure
|
||||
*/
|
||||
public function delete_all_user(int $userID) : bool {
|
||||
|
||||
//Perform the request
|
||||
$notif = new Notification();
|
||||
$notif->set_dest_user_id($userID);
|
||||
return $this->delete($notif);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a notification object into database array
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user