diff options
author | Joas Schilling <coding@schilljs.com> | 2021-01-15 12:41:54 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-02-02 15:52:25 +0300 |
commit | a7e30320cebb20c5d4c495648a8157928d6737ce (patch) | |
tree | 96420510d878ae5b68f29c5897d918e5d0248b0c /lib/Controller/ChatController.php | |
parent | 77f6a4ead3891de17295e74acaa976299fa2c616 (diff) |
Check max age on deleting
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/ChatController.php')
-rw-r--r-- | lib/Controller/ChatController.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index c8c0e3e24..cbdd754b7 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -490,6 +490,13 @@ class ChatController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_FORBIDDEN); } + $maxDeleteAge = $this->timeFactory->getDateTime(); + $maxDeleteAge->sub(new \DateInterval('PT6H')); + if ($message->getCreationDateTime() < $maxDeleteAge) { + // Message is too old + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + $systemMessageComment = $this->chatManager->deleteMessage( $this->room, $messageId, |