Skip to content

Commit

Permalink
feat(chat): Add capability for editing messages
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 19, 2024
1 parent 3fc00f1 commit 54b5928
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@
* `config => call => sip-enabled` - Whether SIP is configured on the server allowing for SIP dial-in
* `config => call => sip-dialout-enabled` - Whether SIP dial-out is configured on the server, additionally requires `config => call => sip-enabled`
* `config => call => can-enable-sip` - Whether the current user is a member of the groups that are allowed to enable SIP dial-in on a conversation or use SIP dial-out

## 19
* `delete-messages-unlimited` - Whether messages can be deleted at any time (used to be restricted to 6 hours after posting)
* `edit-messages` - Whether messages can be edited (restricted to 24 hours after posting)
2 changes: 2 additions & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public function getCapabilities(): array {
'note-to-self',
'recording-consent',
'sip-support-dialout',
'delete-messages-unlimited',
'edit-messages',
],
'config' => [
'attachments' => [
Expand Down
7 changes: 0 additions & 7 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,6 @@ public function deleteMessage(int $messageId): DataResponse {
return new DataResponse([], Http::STATUS_METHOD_NOT_ALLOWED);
}

$maxDeleteAge = $this->timeFactory->getDateTime();
$maxDeleteAge->sub(new \DateInterval('PT6H'));
if ($message->getCreationDateTime() < $maxDeleteAge) {
// Message is too old
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

try {
$systemMessageComment = $this->chatManager->deleteMessage(
$this->room,
Expand Down
2 changes: 2 additions & 0 deletions tests/php/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public function setUp(): void {
'note-to-self',
'recording-consent',
'sip-support-dialout',
'delete-messages-unlimited',
'edit-messages',
'message-expiration',
'reactions',
];
Expand Down

0 comments on commit 54b5928

Please sign in to comment.