delete credential notifications on credential delete

This commit is contained in:
binsky 2024-04-05 03:32:55 +02:00
parent 594583bd00
commit a31dee3343
No known key found for this signature in database
GPG key ID: B438F7FA2E3AC98F
2 changed files with 11 additions and 0 deletions

View file

@ -48,6 +48,7 @@ class CredentialService {
private CredentialRevisionService $credentialRevisionService,
private IURLGenerator $urlGenerator,
private VaultService $vaultService,
private NotificationService $notificationService,
IConfig $config,
) {
$this->server_key = $config->getSystemValue('passwordsalt', '');
@ -120,6 +121,7 @@ class CredentialService {
$this->credentialRevisionService->deleteRevision($id, $userId);
}
}
$this->notificationService->deleteNotificationsOfCredential($credential);
}
/**

View file

@ -111,4 +111,13 @@ class NotificationService {
->andWhere($qb->expr()->eq('subject', $qb->createNamedParameter('credential_expired', IQueryBuilder::PARAM_STR)));
return $qb->execute()->rowCount() !== 0;
}
function deleteNotificationsOfCredential($credential) {
$qb = $this->db->getQueryBuilder();
$qb->delete()
->from('notifications')
->where($qb->expr()->eq('object_id', $qb->createNamedParameter($credential->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('object_type', 'credential'));
return $qb->execute();
}
}