refactor(core): Move more typeorm operators to repositories (no-changelog) (#8143)

Follow-up to #8139
This commit is contained in:
Iván Ovejero
2023-12-22 16:20:30 +01:00
committed by GitHub
parent 4007163651
commit a59d78de18
11 changed files with 81 additions and 55 deletions

View File

@@ -14,6 +14,7 @@ import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { UnauthorizedError } from '@/errors/response-errors/unauthorized.error';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
export const EECredentialsController = express.Router();
@@ -155,10 +156,11 @@ EECredentialsController.put(
let newShareeIds: string[] = [];
await Db.transaction(async (trx) => {
// remove all sharings that are not supposed to exist anymore
const { affected } = await EECredentials.pruneSharings(trx, credentialId, [
...ownerIds,
...shareWithIds,
]);
const { affected } = await Container.get(CredentialsRepository).pruneSharings(
trx,
credentialId,
[...ownerIds, ...shareWithIds],
);
if (affected) amountRemoved = affected;
const sharings = await EECredentials.getSharings(trx, credentialId);