Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8307 remove support for legacy mailfolders non static mail listids #8474

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions schemas/tutanota.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,21 @@
"info": "AddValue ImportMailState/totalMails/1600."
}
]
},
{
"version": 83,
"changes": [
{
"name": "RemoveAssociation",
"sourceType": "MailFolder",
"info": "RemoveAssociation MailFolder/mails."
},
{
"name": "RemoveValue",
"sourceType": "MailFolder",
"info": "RemoveValue MailFolder/isMailSet/1458."
}
]
}
]
}
28 changes: 7 additions & 21 deletions src/common/api/common/mail/FolderSystem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { groupBy, isNotEmpty, partition } from "@tutao/tutanota-utils"
import { groupBy, partition } from "@tutao/tutanota-utils"
import { Mail, MailFolder } from "../../entities/tutanota/TypeRefs.js"
import { isFolder, MailSetKind } from "../TutanotaConstants.js"
import { elementIdPart, getElementId, getListId, isSameId } from "../utils/EntityUtils.js"
import { elementIdPart, getElementId, isSameId } from "../utils/EntityUtils.js"

export interface IndentedFolder {
level: number
Expand Down Expand Up @@ -42,23 +42,13 @@ export class FolderSystem {

getFolderByMail(mail: Mail): MailFolder | null {
const sets = mail.sets
if (isNotEmpty(sets)) {
for (const setId of sets) {
const folder = this.getFolderById(elementIdPart(setId))
if (folder != null) {
return folder
}
for (const setId of sets) {
const folder = this.getFolderById(elementIdPart(setId))
if (folder != null) {
return folder
}
return null
} else {
return this.getFolderByMailListIdLegacy(getListId(mail))
}
}

private getFolderByMailListIdLegacy(mailListId: Id): MailFolder | null {
const subtree =
this.getFolderByMailListIdInSubtrees(this.systemSubtrees, mailListId) ?? this.getFolderByMailListIdInSubtrees(this.customSubtrees, mailListId)
return subtree?.folder ?? null
return null
}

/**
Expand Down Expand Up @@ -121,10 +111,6 @@ export class FolderSystem {
return this.getFolderBy(systems, (system) => isSameId(getElementId(system.folder), folderId))
}

private getFolderByMailListIdInSubtrees(systems: ReadonlyArray<FolderSubtree>, mailListId: Id): FolderSubtree | null {
return this.getFolderBy(systems, (subtree) => isSameId(subtree.folder.mails, mailListId))
}

private getFolderBy(systems: ReadonlyArray<FolderSubtree>, predicate: (subtree: FolderSubtree) => boolean): FolderSubtree | null {
const topLevel = systems.find(predicate)
if (topLevel) {
Expand Down
10 changes: 5 additions & 5 deletions src/common/api/common/utils/EntityUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import {
} from "@tutao/tutanota-utils"
import { Cardinality, ValueType } from "../EntityConstants.js"
import type { ElementEntity, Entity, ModelValue, SomeEntity, TypeModel } from "../EntityTypes"
import { ensureBase64Ext } from "../../worker/offline/OfflineStorage"

/**
* the maximum ID for elements stored on the server (number with the length of 10 bytes) => 2^80 - 1
*/
export const GENERATED_MAX_ID = "zzzzzzzzzzzz"
/**
* we support creation of customIds for mailset entries until around this date.
*
* we support creation of customIds for MailSetEntries until around this date.
* this is intended to be after any reasonable real custom id we generate for mail set entries.
*
* current mailSetEntry maximum date is: 2019-05-15 -ish ( see MailFolderHelper.java: makeMailSetEntryCustomId )
* current mailSetEntry maximum date is: 2109-05-15 -ish (see MailFolderHelper.java: makeMailSetEntryCustomId)
* we are setting it to 2100-01-01T00:00Z to make sure it does not overflow!
*/
export const DEFAULT_MAILSET_ENTRY_CUSTOM_CUTOFF_TIMESTAMP = new Date("2109-05-16T15:00Z").getTime()
export const DEFAULT_MAILSET_ENTRY_CUSTOM_CUTOFF_TIMESTAMP = new Date("2100-01-01T00:00Z").getTime()

/**
* The minimum ID for elements with generated id stored on the server
Expand Down
4 changes: 2 additions & 2 deletions src/common/api/entities/tutanota/ModelInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const modelInfo = {
version: 82,
compatibleSince: 80,
version: 83,
compatibleSince: 83,
}

export default modelInfo
Loading
Loading