diff --git a/RestControllers/commentsController.php b/RestControllers/commentsController.php index bf19027..0b724cc 100644 --- a/RestControllers/commentsController.php +++ b/RestControllers/commentsController.php @@ -55,8 +55,8 @@ class commentsController { $notification->set_type(Notification::COMMENT_CREATED); components()->notifications->push($notification); - //Delete any other notification targeting this user about this post - delete_user_notifications_other_post(userID, $postID); + //Delete any other notification targeting this user about the post + delete_user_notifications_over_post(userID, $postID); //Success return array( diff --git a/RestControllers/likesController.php b/RestControllers/likesController.php index 6e1079e..686185c 100644 --- a/RestControllers/likesController.php +++ b/RestControllers/likesController.php @@ -51,6 +51,9 @@ class likesController { $id = getPostPostIDWithAccess("id"); $componentType = Likes::LIKE_POST; + //Delete any notification targeting this user about the post + delete_user_notifications_over_post(userID, $id); + break; diff --git a/RestControllers/postsController.php b/RestControllers/postsController.php index 0e0dbd6..04764a0 100644 --- a/RestControllers/postsController.php +++ b/RestControllers/postsController.php @@ -404,6 +404,9 @@ class postsController { if(!components()->posts->update_content($postID, $new_content)) Rest_fatal_error(500, "An error occured while trying to update post content !"); + //Delete any notification targeting this user about the post + delete_user_notifications_over_post(userID, $postID); + //Success return array("success" => "The post content has been updated !"); } diff --git a/helpers/notifications.php b/helpers/notifications.php index 4adacb8..467620f 100644 --- a/helpers/notifications.php +++ b/helpers/notifications.php @@ -12,7 +12,9 @@ * @param int $postID Target post * @return bool TRUE in case of success / FALSE else */ -function delete_user_notifications_other_post(int $userID, int $postID) : bool { +function delete_user_notifications_over_post(int $userID, int $postID) : bool { + + user_login_required(); $notification = new Notification(); $notification->set_on_elem_type(Notification::POST);