-
Notifications
You must be signed in to change notification settings - Fork 262
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
Snooze mvp follow up #8754
Snooze mvp follow up #8754
Conversation
bde3b91
to
c39cc58
Compare
lib/Service/SnoozeService.php
Outdated
); | ||
} catch (\Throwable $e) { | ||
$this->unSnoozeMessageDB($message); | ||
throw new ServiceException($e->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loses all of the previous error trace. either just rethrow the original throwable or pass the original as previous of the new service exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
lib/Service/SnoozeService.php
Outdated
); | ||
} catch (\Throwable $e) { | ||
$this->unSnoozeThreadDB($selectedMessage); | ||
throw new ServiceException($e->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
$this->messageSnoozeMapper->insert($snooze); | ||
try { | ||
$this->messageSnoozeMapper->insert($snooze); | ||
} catch(Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you check the reason of the error and only handle duplicates and rethrow the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check $e->getPrevious() instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException
. Do you think this is okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently, tests fail because the UniqueConstraintViolationException is part of 3rdparty. Is there a way to use it without errors or is this not an option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\OCP\DB\Exception::getReason
and comparison with \OCP\DB\Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION
lib/Service/SnoozeService.php
Outdated
$messages = $this->threadMapper->findMessageIdsByThreadRoot( | ||
$selectedMessage->getThreadRootId() | ||
); | ||
|
||
foreach ($messages as $message) { | ||
$this->messageSnoozeMapper->deleteByMessageId($message['messageId']); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf: would be faster and atomic if this is done in one query by the db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed deleteByMessageId()
to take array of ids and query db by where->in
481fb2d
to
bb369ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
lib/Service/SnoozeService.php
Outdated
@@ -144,6 +285,7 @@ private function wakeMessagesByAccount(Account $account): void { | |||
|
|||
$client = $this->clientFactory->getClient($account); | |||
try { | |||
$messageIdsToDelete = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$messageIdsToDelete = array(); | |
$messageIdsToDelete = []; |
Signed-off-by: Johannes Merkel <[email protected]>
bb369ef
to
326d48f
Compare
Fix: #8747
This follow up is fixing some minor things: