Skip to content

Commit

Permalink
Merge pull request #361 from internxt/fix/sharing-type-error-fixed-an…
Browse files Browse the repository at this point in the history
…d-log-name-file

[_] fix: fixed error when fetching the sharing type
  • Loading branch information
apsantiso authored Jul 12, 2024
2 parents b415e51 + 25372bb commit 82ac6d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/modules/file/file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ export class FileController {
const err = error as Error;
const { email, uuid } = user;
Logger.error(
`[SHARING/REPLACE] Error while replacing file. CONTEXT:${JSON.stringify(
{
user: { email, uuid },
},
)}}, STACK: ${err.stack || 'No stack trace'}`,
`[FILE/REPLACE] Error while replacing file. CONTEXT:${JSON.stringify({
user: { email, uuid },
})}}, STACK: ${err.stack || 'No stack trace'}`,
);

throw error;
Expand Down
8 changes: 6 additions & 2 deletions src/modules/sharing/sharing.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,17 @@ export class SequelizeSharingRepository implements SharingRepository {
type?: SharingType,
sharedWithType?: SharedWithType,
): Promise<Sharing> {
const optionalWhere = {
...(type ? { type } : null),
...(sharedWithType ? { sharedWithType } : null),
};

const raw = await this.sharings.findOne({
where: {
itemId,
itemType,
[Op.or]: [{ ownerId: userId }, { sharedWith: userId }],
type,
sharedWithType,
...optionalWhere,
},
});

Expand Down
1 change: 1 addition & 0 deletions src/modules/sharing/sharing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,7 @@ export class SharingService {
itemId,
itemType,
SharingType.Public,
sharedWithType,
),
this.sharingRepository.findOneByOwnerOrSharedWithItem(
user.uuid,
Expand Down

0 comments on commit 82ac6d3

Please sign in to comment.