Skip to content

Commit

Permalink
fix: fix email redirection route and remove invitation if email not sent
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Dec 6, 2023
1 parent caf73a4 commit e067b7f
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/modules/sharing/sharing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,22 +1116,31 @@ export class SharingService {

if (isUserPreCreated) {
const encodedUserEmail = encodeURIComponent(userJoining.email);

new MailerService(this.configService)
.sendInvitationToSharingGuestEmail(
try {
await new MailerService(
this.configService,
).sendInvitationToSharingGuestEmail(
user.email,
userJoining.email,
item.plainName,
{
signUpUrl: `${this.configService.get('clients.drive.web')}/new${
signUpUrl: `${this.configService.get(
'clients.drive.web',
)}/shared-guest?invitation=${
createdInvite.id
}?invitation=${createdInvite.id}&email=${encodedUserEmail}`,
}&email=${encodedUserEmail}`,
message: createInviteDto.notificationMessage || '',
},
)
.catch(() => {
// no op
});
);
} catch (error) {
Logger.error(
`[SHARING/GUESTUSEREMAIL] Error sending email pre created userId: ${
userJoining.uuid
}, error: ${JSON.stringify(error)}`,
);
await this.removeInvite(user, createdInvite.id);
throw error;
}
}

return createdInvite;
Expand Down Expand Up @@ -1191,9 +1200,8 @@ export class SharingService {
return sharing;
}

const sharingCreated = await this.sharingRepository.createSharing(
newSharing,
);
const sharingCreated =
await this.sharingRepository.createSharing(newSharing);

this.userReferralsRepository
.applyUserReferral(user.id, ReferralKey.ShareFile)
Expand Down Expand Up @@ -1428,9 +1436,8 @@ export class SharingService {
requester: User,
sharingRoleId: SharingRole['id'],
): Promise<void> {
const sharingRole = await this.sharingRepository.findSharingRole(
sharingRoleId,
);
const sharingRole =
await this.sharingRepository.findSharingRole(sharingRoleId);
if (!sharingRole) {
throw new NotFoundException('Sharing role not found');
}
Expand Down

0 comments on commit e067b7f

Please sign in to comment.