-
Notifications
You must be signed in to change notification settings - Fork 510
Implement time to live #7327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Implement time to live #7327
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
a8b9a87
Documentation
vitormattos 1df40ae
Add mocked endpoints
vitormattos 465bbf0
Add field to room table
vitormattos 5bdaa16
Implement logic in controller to change the ttl
vitormattos b74d06b
Bump app version to run migration
vitormattos 87fd76e
Add integration tests
vitormattos 03fb81d
Add job to apply ttl
vitormattos 3ab61a3
Only set ttl capability if systemcron is enabled
vitormattos fa3f98e
Enable to run in drone
vitormattos d0cc257
Delete messages when ttl expire and send system message
vitormattos 05b0808
Method moved and change argument
vitormattos 2680803
Remove expire job from background job list
vitormattos 751d18f
Rename ttl to message expire
vitormattos ddf59cf
Convert string to ::class
vitormattos 467cd71
Change default value of backgroundjobs_mode to ajax
vitormattos afb8d07
Move deleteExpiredTtl method to ChatManager
vitormattos 67f49f1
File moved to maintain the pattern "message expire"
vitormattos 5b6dc78
Use DataResponse and returning 404
vitormattos 84bdaaf
Replace count by !empty
vitormattos e216553
Priorize to run job than send system message
vitormattos 7a31b9d
Fix tests
vitormattos 3145bac
Rename time to live to message expire
vitormattos 22a0a7f
Changed to use Nextcloud wrapper to this class
vitormattos b39f9ae
use DI in the constructor
vitormattos 0c5b047
Set expire time
vitormattos eb91f78
Removed the system message to sinalize when the message was expired.
vitormattos 7fe6f4a
Moved integration tests to folder of chat tests
vitormattos 6c7d0d3
Rename more ttl to message-expire
vitormattos 7915753
Remove unused namespace
vitormattos 9a5cee6
Add typed argument
vitormattos 0cdf6c0
Fix tests
vitormattos 31c6495
Add method to get message expire time
vitormattos fac67ee
Parse system message
vitormattos 1f808eb
Expire message using attribute from message
vitormattos bd9913e
Rename message expire to expire date
vitormattos 68e19e5
Make the error message more clear
vitormattos 545914a
Bump psalm dependencies
vitormattos 47ea1cc
Rename to follow the pattern "-"
vitormattos 7b42dfb
solve conflict
vitormattos 26cb438
Fix date
vitormattos 05e830f
Add system message in chat.md
vitormattos 21134fc
Remove no more used method
vitormattos 5a9ca1b
Replace _ by -
vitormattos af34125
Rename text
vitormattos d184f0b
Adjust language handling in the system message
nickvergessen 3c16d95
Rename integration test
nickvergessen 82a0613
Fix event name
nickvergessen 30cd60e
Only remove the job when expiration is "done"
nickvergessen b89a064
Remove unused property
vitormattos 86080fa
Revert the wrong previous argument rename
vitormattos 9bd7b56
Remove unecessary method
vitormattos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2022 Vitor Mattos <[email protected]> | ||
| * | ||
| * @author Vitor Mattos <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Talk\BackgroundJob; | ||
|
|
||
| use OCA\Talk\Chat\ChatManager; | ||
| use OCP\AppFramework\Utility\ITimeFactory; | ||
| use OCP\BackgroundJob\IJob; | ||
| use OCP\BackgroundJob\TimedJob; | ||
|
|
||
| class ApplyExpireDate extends TimedJob { | ||
| private ChatManager $chatManager; | ||
|
|
||
| public function __construct(ITimeFactory $timeFactory, | ||
| ChatManager $chatManager) { | ||
| parent::__construct($timeFactory); | ||
| $this->chatManager = $chatManager; | ||
|
|
||
| // Every 5 minutes | ||
| $this->setInterval(5 * 60); | ||
| $this->setTimeSensitivity(IJob::TIME_SENSITIVE); | ||
| } | ||
|
|
||
| /** | ||
| * @param array $argument | ||
| */ | ||
| protected function run($argument): void { | ||
| $this->chatManager->deleteExpiredMessages($argument['room_id']); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2022 Vitor Mattos <[email protected]> | ||
| * | ||
| * @author Vitor Mattos <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Events; | ||
|
|
||
| use OCA\Talk\Room; | ||
|
|
||
| class ChangeExpireDateEvent extends RoomEvent { | ||
vitormattos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private int $seconds; | ||
| public function __construct(Room $room, | ||
| int $seconds | ||
| ) { | ||
| parent::__construct($room); | ||
| $this->seconds = $seconds; | ||
| } | ||
|
|
||
| public function getExpireDateSeconds(): int { | ||
| return $this->seconds; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2022 Vitor Mattos <[email protected]> | ||
| * | ||
| * @author Vitor Mattos <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| class Version15000Date20220506005058 extends SimpleMigrationStep { | ||
|
|
||
| /** | ||
| * @param IOutput $output | ||
| * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
| * @param array $options | ||
| * @return null|ISchemaWrapper | ||
| */ | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $table = $schema->getTable('talk_rooms'); | ||
| if (!$table->hasColumn('message_expire')) { | ||
| $table->addColumn('message_expire', Types::INTEGER, [ | ||
| 'default' => 0, | ||
| ]); | ||
| return $schema; | ||
| } | ||
| return null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.