Skip to content

Commit

Permalink
refactor RecipientsNotFoundError with recipients as array, #2975
Browse files Browse the repository at this point in the history
  • Loading branch information
vaf-hub committed May 10, 2021
1 parent cb910da commit d684a64
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/api/common/error/RecipientsNotFoundError.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import {TutanotaError} from "./TutanotaError"

export class RecipientsNotFoundError extends TutanotaError {
constructor(m: string) {
super("RecipientsNotFoundError", m)

+recipients: Array<string>

constructor(recipients: Array<string>) {
super("RecipientsNotFoundError", recipients.join("\n"))
this.recipients = recipients
}

}
2 changes: 1 addition & 1 deletion src/api/main/WorkerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export class WorkerClient implements EntityRestInterface {
return this._leaderStatus.leaderStatus
}

createTemplateGroup(name: string):Promise<Id> {
createTemplateGroup(name: string): Promise<Id> {
return this._postRequest(new Request('createTemplateGroup', arguments))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/worker/facades/MailFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export class MailFacade {
}

_addRecipientKeyData(bucketKey: Aes128Key, service: SendDraftData, recipientInfos: RecipientInfo[], senderMailGroupId: Id): Promise<void> {
let notFoundRecipients = []
let notFoundRecipients: Array<string> = []
return Promise.all(recipientInfos.map(recipientInfo => {
if (recipientInfo.mailAddress === "system@tutanota.de" || !recipientInfo) {
notFoundRecipients.push(recipientInfo.mailAddress)
Expand Down Expand Up @@ -438,7 +438,7 @@ export class MailFacade {
}
})
).then(() => {
if (notFoundRecipients.length > 0) throw new RecipientsNotFoundError(notFoundRecipients.join("\n"))
if (notFoundRecipients.length > 0) throw new RecipientsNotFoundError(notFoundRecipients)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/worker/facades/ShareFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ShareFacade {
}
})
}).then(() => {
if (notFoundRecipients.length > 0) throw new RecipientsNotFoundError(notFoundRecipients.join("\n"))
if (notFoundRecipients.length > 0) throw new RecipientsNotFoundError(notFoundRecipients)
return serviceRequest(TutanotaService.GroupInvitationService, HttpMethod.POST, invitationData, GroupInvitationPostReturnTypeRef)
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/CalendarUpdateDistributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class CalendarMailDistributor implements CalendarUpdateDistributor {
}).catch(RecipientsNotFoundError, e => {
// we want to delete the event even if the recipient is not an existing tutanota address
// and just exclude them from sending out updates but leave the event untouched for other recipients
const invalidRecipients = e.message.split("\n")
const invalidRecipients = e.recipients
let hasRemovedRecipient = false
invalidRecipients.forEach(invalidRecipient => {
const recipientInfo = sendMailModel.bccRecipients().find(r => r.mailAddress === invalidRecipient)
Expand Down
2 changes: 1 addition & 1 deletion src/mail/editor/SendMailModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ export class SendMailModel {
.catch(RecipientNotResolvedError, () => {throw new UserError("tooManyAttempts_msg")})
.catch(RecipientsNotFoundError, (e) => {
if (mailMethod === MailMethod.ICAL_CANCEL) {
//in case of calendar event cancellation we willremove invalid recipients and then delete the event without sending updates
//in case of calendar event cancellation we will remove invalid recipients and then delete the event without sending updates
throw e
} else {
let invalidRecipients = e.message
Expand Down

0 comments on commit d684a64

Please sign in to comment.