Skip to content

Commit

Permalink
Don't use baseUrl for requesting blob access tokens for files
Browse files Browse the repository at this point in the history
Co-authored-by: paw <[email protected]>
  • Loading branch information
charlag and paw-hub committed Dec 20, 2024
1 parent 46c805b commit b326849
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/common/api/worker/facades/lazy/MailExportFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ export class MailExportFacade {
return this.mailExportTokenFacade.loadWithToken((token) => this.bulkMailLoader.loadAttachments(mails, { baseUrl, ...this.options(token) }))
}

async loadAttachmentData(mail: Mail, attachments: readonly TutanotaFile[], baseUrl: string): Promise<DataFile[]> {
async loadAttachmentData(mail: Mail, attachments: readonly TutanotaFile[]): Promise<DataFile[]> {
const attachmentsWithKeys = await this.cryptoFacade.enforceSessionKeyUpdateIfNeeded(mail, attachments)

const downloads = await this.mailExportTokenFacade.loadWithToken((token) => {
const referencingInstances = attachmentsWithKeys.map(createReferencingInstance)
return this.blobFacade.downloadAndDecryptBlobsOfMultipleInstances(ArchiveDataType.Attachments, referencingInstances, {
baseUrl,
...this.options(token),
})
})
Expand Down
12 changes: 6 additions & 6 deletions src/mail-app/native/main/MailExportController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class MailExportController {
private _state: Stream<MailExportState> = stream({ type: "idle" })
private _lastExport: Date | null = null
private servers?: BlobServerUrl[]
private serverCount: number = 0
private serverIndex: number = 0

get lastExport(): Date | null {
return this._lastExport
Expand Down Expand Up @@ -181,7 +181,7 @@ export class MailExportController {
const mailAttachmentInfo = mail.attachments
.map((attachmentId) => attachmentInfo.find((attachment) => isSameId(attachment._id, attachmentId)))
.filter(isNotNull)
const attachments = await this.mailExportFacade.loadAttachmentData(mail, mailAttachmentInfo, this.getServerUrl())
const attachments = await this.mailExportFacade.loadAttachmentData(mail, mailAttachmentInfo)
const { makeMailBundle } = await import("../../mail/export/Bundler.js")
const mailBundle = makeMailBundle(this.sanitizer, mail, mailDetails, attachments)

Expand Down Expand Up @@ -228,11 +228,11 @@ export class MailExportController {

private getServerUrl(): string {
if (this.servers) {
this.serverCount += 1
if (this.serverCount >= this.servers.length) {
this.serverCount = 0
this.serverIndex += 1
if (this.serverIndex >= this.servers.length) {
this.serverIndex = 0
}
return this.servers[this.serverCount].url
return this.servers[this.serverIndex].url
}
throw new Error("No servers")
}
Expand Down

0 comments on commit b326849

Please sign in to comment.