Skip to content

Commit

Permalink
Merge pull request #3 from pmmaga/patch-1
Browse files Browse the repository at this point in the history
fix(MessageRepository): Check user for deletion
  • Loading branch information
akazorg committed Oct 19, 2018
2 parents a42c861 + a6e3c6c commit 54ca5f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Repositories/MessageRepository.php
Expand Up @@ -54,6 +54,10 @@ public function send(int $senderId, int $receiverId, string $message)
public function delete($msg, $user)
{
try {
if (!in_array($user, [$msg->sender_id, $msg->receiver_id])) {
return ['status' => false, 'message' => 'Unauthorized'];
}

// Set message 'deleted' for the current user only
if ($msg->sender_id == $user) {
$msg->deleted_by_sender = true;
Expand Down

0 comments on commit 54ca5f6

Please sign in to comment.