-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: File reminders backend #39651
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
feat: File reminders backend #39651
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e16001b
feat: init files_reminders migration
Pytal 59a2ef4
feat(files_reminders): add Application
Pytal b75fac3
feat(files_reminders): add info xml
Pytal a3ac1b8
feat(files_reminders): add background jobs
Pytal ea5e128
feat(files_reminders): add service and notifier
Pytal c8a32a7
feat(files_reminders): add list command
Pytal 163b059
enh: use datetime
Pytal 4fabd77
enh: add created at
Pytal 774e3e6
enh: implement JsonSerializable
Pytal a7892fb
feat(files_reminders): add api controller
Pytal cfbac9b
fix: add composer autoload
Pytal beb8a27
enh: add to shipped
Pytal fa77564
enh: rename to due date
Pytal 7637bf2
fix: catch Throwable
Pytal 5ff178a
enh: add updated at
Pytal 8870585
feat(files_reminders): create or update
Pytal 05e454e
fix: update find due query
Pytal 777a791
feat(files_reminders): add remove endpoint
Pytal d31302e
fix: create only if file exists
Pytal bdf0741
enh: return created status code
Pytal b04d1a7
enh: comment interval
Pytal db7f5a2
enh: serialize path
Pytal 9bd7ddd
enh: does not exist return null
Pytal 3ade06c
fix: return ocs data
Pytal 7daf11f
fix: remove throwable handling
Pytal 7617519
fix: construct background jobs
Pytal f865c3a
enh: handle node deleted
Pytal 9e8354e
fix: exit on reminder not found
Pytal c4b7056
fix: catch NodeNotFoundException in notifier
Pytal 7beef65
enh: highlight filename
Pytal 7381c80
fix: remove unnecessary parsed subject
Pytal d619166
fix: return null if table exists
Pytal 113d061
enh: add codeowner
Pytal e320166
enh: add json output to command
Pytal 2c4b562
fix: ignore non-existing
Pytal af98c70
fix(ci): add to enabled apps
Pytal 5a11535
fix: set endpoint description
Pytal a806bd0
enh: handle user deleted
Pytal 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
Next
Next commit
feat: init files_reminders migration
Signed-off-by: Christopher Ng <[email protected]>
- Loading branch information
commit e16001b8eb6b5f87dfba57cca94adb88cf6b1d45
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright 2023 Christopher Ng <[email protected]> | ||
| * | ||
| * @author Christopher Ng <[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\FilesReminders\Db; | ||
|
|
||
| use OCP\AppFramework\Db\Entity; | ||
|
|
||
| /** | ||
| * @method void setUserId(string $userId) | ||
| * @method string getUserId() | ||
| * | ||
| * @method void setFileId(int $fileId) | ||
| * @method int getFileId() | ||
| * | ||
| * @method void setRemindAt(int $remindAt) | ||
| * @method int getRemindAt() | ||
| * | ||
| * @method void setNotified(bool $notified) | ||
| * @method bool getNotified() | ||
| */ | ||
| class Reminder extends Entity { | ||
| protected string $userId; | ||
| protected int $fileId; | ||
| protected int $remindAt; | ||
| protected bool $notified = false; | ||
|
|
||
| public function __construct() { | ||
| $this->addType('userId', 'string'); | ||
| $this->addType('fileId', 'integer'); | ||
| $this->addType('remindAt', 'integer'); | ||
| $this->addType('notified', 'boolean'); | ||
| } | ||
| } |
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,67 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright 2023 Christopher Ng <[email protected]> | ||
| * | ||
| * @author Christopher Ng <[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\FilesReminders\Db; | ||
|
|
||
| use OCP\AppFramework\Db\QBMapper; | ||
| use OCP\DB\QueryBuilder\IQueryBuilder; | ||
| use OCP\IDBConnection; | ||
|
|
||
| /** | ||
| * @template-extends QBMapper<Reminder> | ||
| */ | ||
| class ReminderMapper extends QBMapper { | ||
| public const TABLE_NAME = 'files_reminders'; | ||
|
|
||
| public function __construct(IDBConnection $db) { | ||
| parent::__construct( | ||
| $db, | ||
| static::TABLE_NAME, | ||
| Reminder::class, | ||
| ); | ||
| } | ||
|
|
||
| public function markNotified(Reminder $reminder): Reminder { | ||
| $reminderUpdate = new Reminder(); | ||
| $reminderUpdate->setId($reminder->getId()); | ||
| $reminderUpdate->setNotified(true); | ||
| return parent::update($reminderUpdate); | ||
| } | ||
|
|
||
| /** | ||
| * @return Reminder[] | ||
| */ | ||
| public function findToRemind() { | ||
| $qb = $this->db->getQueryBuilder(); | ||
|
|
||
| $qb->select('user_id', 'file_id', 'remind_at') | ||
| ->from($this->getTableName()) | ||
| ->where($qb->expr()->lt('remind_at', $qb->createFunction('NOW()'))) | ||
| ->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL))); | ||
|
|
||
| return $this->findEntities($qb); | ||
| } | ||
| } |
71 changes: 71 additions & 0 deletions
71
apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
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,71 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright 2023 Christopher Ng <[email protected]> | ||
| * | ||
| * @author Christopher Ng <[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\FilesReminders\Migration; | ||
|
|
||
| use Closure; | ||
| use OCA\FilesReminders\Db\ReminderMapper; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| class Version10000Date20230725162149 extends SimpleMigrationStep { | ||
| /** | ||
| * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
| */ | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $table = $schema->createTable(ReminderMapper::TABLE_NAME); | ||
| $table->addColumn('id', Types::BIGINT, [ | ||
| 'autoincrement' => true, | ||
| 'notnull' => true, | ||
| 'length' => 20, | ||
| 'unsigned' => true, | ||
| ]); | ||
| $table->addColumn('user_id', Types::STRING, [ | ||
| 'notnull' => true, | ||
| 'length' => 64, | ||
| ]); | ||
| $table->addColumn('file_id', Types::BIGINT, [ | ||
| 'notnull' => true, | ||
| 'length' => 20, | ||
| ]); | ||
| $table->addColumn('remind_at', Types::BIGINT, [ | ||
| 'notnull' => true, | ||
| ]); | ||
| $table->addColumn('notified', Types::BOOLEAN, [ | ||
| 'notnull' => false, | ||
| 'default' => false, | ||
| ]); | ||
| $table->setPrimaryKey(['id']); | ||
| $table->addUniqueIndex(['user_id', 'file_id', 'remind_at'], 'reminders_uniq_idx'); | ||
|
|
||
| return $schema; | ||
| } | ||
| } | ||
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.