2023-06-29 18:26:45 +02:00
|
|
|
import o from "@tutao/otest"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { verify } from "@tutao/tutanota-test-utils"
|
2024-08-26 15:07:37 +02:00
|
|
|
import { customTypeEncoders, ensureBase64Ext, OfflineStorage } from "../../../../../src/common/api/worker/offline/OfflineStorage.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { instance, object, when } from "testdouble"
|
2022-04-06 16:55:16 +02:00
|
|
|
import * as cborg from "cborg"
|
2024-08-26 15:07:37 +02:00
|
|
|
import {
|
|
|
|
|
constructMailSetEntryId,
|
|
|
|
|
elementIdPart,
|
|
|
|
|
GENERATED_MAX_ID,
|
|
|
|
|
GENERATED_MIN_ID,
|
|
|
|
|
generatedIdToTimestamp,
|
|
|
|
|
getElementId,
|
|
|
|
|
listIdPart,
|
|
|
|
|
timestampToGeneratedId,
|
|
|
|
|
} from "../../../../../src/common/api/common/utils/EntityUtils.js"
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
import { getDayShifted, getFirstOrThrow, getTypeId, lastThrow, mapNullable, promiseMap, TypeRef } from "@tutao/tutanota-utils"
|
2024-07-01 17:56:41 +02:00
|
|
|
import { DateProvider } from "../../../../../src/common/api/common/DateProvider.js"
|
2022-04-20 10:39:52 +02:00
|
|
|
import {
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
BodyTypeRef,
|
2024-08-07 08:38:58 +02:00
|
|
|
createMailFolderRef,
|
2022-04-20 10:39:52 +02:00
|
|
|
FileTypeRef,
|
|
|
|
|
Mail,
|
2024-08-26 15:07:37 +02:00
|
|
|
MailBagTypeRef,
|
2024-08-07 08:38:58 +02:00
|
|
|
MailBoxTypeRef,
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
MailDetailsBlob,
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
MailDetailsBlobTypeRef,
|
|
|
|
|
MailDetailsTypeRef,
|
2022-04-20 10:39:52 +02:00
|
|
|
MailFolderTypeRef,
|
2024-08-26 15:07:37 +02:00
|
|
|
MailSetEntryTypeRef,
|
2022-12-27 15:37:40 +01:00
|
|
|
MailTypeRef,
|
2024-07-01 17:56:41 +02:00
|
|
|
} from "../../../../../src/common/api/entities/tutanota/TypeRefs.js"
|
|
|
|
|
import { OfflineStorageMigrator } from "../../../../../src/common/api/worker/offline/OfflineStorageMigrator.js"
|
|
|
|
|
import { InterWindowEventFacadeSendDispatcher } from "../../../../../src/common/native/common/generatedipc/InterWindowEventFacadeSendDispatcher.js"
|
2023-04-20 17:14:30 +02:00
|
|
|
import * as fs from "node:fs"
|
2024-07-01 17:56:41 +02:00
|
|
|
import { untagSqlObject } from "../../../../../src/common/api/worker/offline/SqlValue.js"
|
2024-08-07 08:38:58 +02:00
|
|
|
import { MailSetKind } from "../../../../../src/common/api/common/TutanotaConstants.js"
|
2024-07-01 17:56:41 +02:00
|
|
|
import { BlobElementEntity, ElementEntity, ListElementEntity, SomeEntity } from "../../../../../src/common/api/common/EntityTypes.js"
|
|
|
|
|
import { resolveTypeReference } from "../../../../../src/common/api/common/EntityFunctions.js"
|
|
|
|
|
import { Type as TypeId } from "../../../../../src/common/api/common/EntityConstants.js"
|
|
|
|
|
import { expandId } from "../../../../../src/common/api/worker/rest/DefaultEntityRestCache.js"
|
|
|
|
|
import { WorkerImpl } from "../../../../../src/common/api/worker/WorkerImpl.js"
|
|
|
|
|
import { UserTypeRef } from "../../../../../src/common/api/entities/sys/TypeRefs.js"
|
|
|
|
|
import { DesktopSqlCipher } from "../../../../../src/common/desktop/db/DesktopSqlCipher.js"
|
2023-11-09 17:04:42 +01:00
|
|
|
import { createTestEntity } from "../../../TestUtils.js"
|
2024-07-01 17:56:41 +02:00
|
|
|
import { sql } from "../../../../../src/common/api/worker/offline/Sql.js"
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
function incrementId(id: Id, ms: number) {
|
|
|
|
|
const timestamp = generatedIdToTimestamp(id)
|
|
|
|
|
return timestampToGeneratedId(timestamp + ms)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class IdGenerator {
|
2022-12-27 15:37:40 +01:00
|
|
|
constructor(private currentId: Id) {}
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
getNext(incrementByMs: number = 60000): Id {
|
|
|
|
|
this.currentId = incrementId(this.currentId, incrementByMs)
|
|
|
|
|
return this.currentId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function encode(thing) {
|
2022-12-27 15:37:40 +01:00
|
|
|
return cborg.encode(thing, { typeEncoders: customTypeEncoders })
|
2022-04-20 10:39:52 +02:00
|
|
|
}
|
2022-04-06 16:55:16 +02:00
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const nativePath = buildOptions.sqliteNativePath
|
|
|
|
|
const database = "./testdatabase.sqlite"
|
|
|
|
|
export const offlineDatabaseTestKey = Uint8Array.from([3957386659, 354339016, 3786337319, 3366334248])
|
|
|
|
|
|
2024-08-07 08:38:58 +02:00
|
|
|
o.spec("OfflineStorageDb", function () {
|
2022-04-20 10:39:52 +02:00
|
|
|
const now = new Date("2022-01-01 00:00:00 UTC")
|
|
|
|
|
const timeRangeDays = 10
|
|
|
|
|
const userId = "userId"
|
2022-07-20 15:28:38 +02:00
|
|
|
const databaseKey = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7])
|
2022-04-06 16:55:16 +02:00
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
/** get an id based on a timestamp that is {@param days} days away from the time range cutoff */
|
2022-12-27 15:37:40 +01:00
|
|
|
const offsetId = (days) => timestampToGeneratedId(getDayShifted(now, 0 - timeRangeDays + days).getTime())
|
2022-04-20 10:39:52 +02:00
|
|
|
const cutoffId = offsetId(0)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
let dbFacade: DesktopSqlCipher
|
|
|
|
|
let dateProviderMock: DateProvider
|
|
|
|
|
let storage: OfflineStorage
|
|
|
|
|
let migratorMock: OfflineStorageMigrator
|
|
|
|
|
let interWindowEventSenderMock: InterWindowEventFacadeSendDispatcher
|
2022-11-28 17:38:17 +01:00
|
|
|
let worker: WorkerImpl
|
2022-08-11 16:38:53 +02:00
|
|
|
|
|
|
|
|
o.beforeEach(async function () {
|
|
|
|
|
dbFacade = new DesktopSqlCipher(nativePath, database, false)
|
|
|
|
|
|
|
|
|
|
dateProviderMock = object<DateProvider>()
|
|
|
|
|
migratorMock = instance(OfflineStorageMigrator)
|
|
|
|
|
interWindowEventSenderMock = instance(InterWindowEventFacadeSendDispatcher)
|
|
|
|
|
when(dateProviderMock.now()).thenReturn(now.getTime())
|
2022-12-12 11:29:42 +01:00
|
|
|
storage = new OfflineStorage(dbFacade, interWindowEventSenderMock, dateProviderMock, migratorMock)
|
2022-08-11 16:38:53 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o.afterEach(async function () {
|
|
|
|
|
await dbFacade.closeDb()
|
|
|
|
|
await fs.promises.unlink(database)
|
|
|
|
|
})
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
o.spec("Unit test", function () {
|
2022-08-11 16:38:53 +02:00
|
|
|
async function insertEntity(entity: SomeEntity) {
|
|
|
|
|
const typeModel = await resolveTypeReference(entity._type)
|
|
|
|
|
const type = getTypeId(entity._type)
|
|
|
|
|
let preparedQuery
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
switch (typeModel.type) {
|
|
|
|
|
case TypeId.Element.valueOf():
|
|
|
|
|
preparedQuery = sql`insert into element_entities values (${type}, ${(entity as ElementEntity)._id}, ${entity._ownerGroup}, ${encode(
|
|
|
|
|
entity,
|
|
|
|
|
)})`
|
|
|
|
|
break
|
|
|
|
|
case TypeId.ListElement.valueOf():
|
|
|
|
|
const [listId, elementId] = (entity as ListElementEntity)._id
|
|
|
|
|
preparedQuery = sql`INSERT INTO list_entities VALUES (${type}, ${listId}, ${elementId}, ${entity._ownerGroup}, ${encode(entity)})`
|
|
|
|
|
break
|
|
|
|
|
case TypeId.BlobElement.valueOf():
|
|
|
|
|
const [archiveId, blobElementId] = (entity as BlobElementEntity)._id
|
|
|
|
|
preparedQuery = sql`INSERT INTO blob_element_entities VALUES (${type}, ${archiveId}, ${blobElementId}, ${entity._ownerGroup}, ${encode(
|
|
|
|
|
entity,
|
|
|
|
|
)})`
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
throw new Error("must be a persistent type")
|
2022-08-11 16:38:53 +02:00
|
|
|
}
|
|
|
|
|
await dbFacade.run(preparedQuery.query, preparedQuery.params)
|
|
|
|
|
}
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
async function insertRange(type: TypeRef<unknown>, listId: string, lower: string, upper: string) {
|
2022-12-27 15:37:40 +01:00
|
|
|
const { query, params } = sql`INSERT INTO ranges VALUES(${getTypeId(type)}, ${listId}, ${lower}, ${upper})`
|
2022-08-11 16:38:53 +02:00
|
|
|
await dbFacade.run(query, params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getAllIdsForType(typeRef: TypeRef<unknown>): Promise<Id[]> {
|
|
|
|
|
const typeModel = await resolveTypeReference(typeRef)
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
let preparedQuery
|
|
|
|
|
switch (typeModel.type) {
|
|
|
|
|
case TypeId.Element.valueOf():
|
|
|
|
|
preparedQuery = sql`select * from element_entities where type = ${getTypeId(typeRef)}`
|
|
|
|
|
break
|
|
|
|
|
case TypeId.ListElement.valueOf():
|
|
|
|
|
preparedQuery = sql`select * from list_entities where type = ${getTypeId(typeRef)}`
|
|
|
|
|
break
|
|
|
|
|
case TypeId.BlobElement.valueOf():
|
|
|
|
|
preparedQuery = sql`select * from blob_element_entities where type = ${getTypeId(typeRef)}`
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
throw new Error("must be a persistent type")
|
|
|
|
|
}
|
|
|
|
|
return (await dbFacade.all(preparedQuery.query, preparedQuery.params)).map((r) => r.elementId.value as Id)
|
2022-08-11 16:38:53 +02:00
|
|
|
}
|
2022-05-17 17:40:44 +02:00
|
|
|
|
|
|
|
|
o("migrations are run", async function () {
|
2022-12-27 15:37:40 +01:00
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
2022-10-21 15:53:39 +02:00
|
|
|
verify(migratorMock.migrate(storage, dbFacade))
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
o.spec("Offline storage round trip", function () {
|
2023-02-02 17:21:34 +01:00
|
|
|
o.spec("ElementType", function () {
|
|
|
|
|
o("deleteAllOfType", async function () {
|
|
|
|
|
const userId = "id1"
|
2023-11-10 16:59:39 +01:00
|
|
|
const storableUser = createTestEntity(UserTypeRef, { _id: userId })
|
2023-02-02 17:21:34 +01:00
|
|
|
|
|
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let user = await storage.get(UserTypeRef, null, userId)
|
|
|
|
|
o(user).equals(null)
|
|
|
|
|
|
|
|
|
|
await storage.put(storableUser)
|
|
|
|
|
|
|
|
|
|
user = await storage.get(UserTypeRef, null, userId)
|
|
|
|
|
o(user!._id).equals(storableUser._id)
|
|
|
|
|
|
|
|
|
|
await storage.deleteAllOfType(UserTypeRef)
|
|
|
|
|
|
|
|
|
|
user = await storage.get(UserTypeRef, null, userId)
|
|
|
|
|
o(user).equals(null)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2024-08-26 15:07:37 +02:00
|
|
|
o.spec("ListElementType generatedId", function () {
|
2023-02-02 17:21:34 +01:00
|
|
|
o("deleteAllOfType", async function () {
|
|
|
|
|
const listId = "listId1"
|
|
|
|
|
const elementId = "id1"
|
2023-11-10 16:59:39 +01:00
|
|
|
const storableMail = createTestEntity(MailTypeRef, { _id: [listId, elementId] })
|
2023-02-02 17:21:34 +01:00
|
|
|
|
|
|
|
|
await storage.init({ userId: elementId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let mail = await storage.get(MailTypeRef, listId, elementId)
|
|
|
|
|
o(mail).equals(null)
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMail)
|
2023-03-29 14:46:04 +02:00
|
|
|
await storage.setNewRangeForList(MailTypeRef, listId, elementId, elementId)
|
2023-02-02 17:21:34 +01:00
|
|
|
|
|
|
|
|
mail = await storage.get(MailTypeRef, listId, elementId)
|
|
|
|
|
o(mail!._id).deepEquals(storableMail._id)
|
2023-03-29 14:46:04 +02:00
|
|
|
const rangeBefore = await storage.getRangeForList(MailTypeRef, listId)
|
|
|
|
|
o(rangeBefore).deepEquals({ upper: elementId, lower: elementId })
|
2023-02-02 17:21:34 +01:00
|
|
|
await storage.deleteAllOfType(MailTypeRef)
|
|
|
|
|
|
|
|
|
|
mail = await storage.get(MailTypeRef, listId, elementId)
|
|
|
|
|
o(mail).equals(null)
|
2023-03-29 14:46:04 +02:00
|
|
|
const rangeAfter = await storage.getRangeForList(MailTypeRef, listId)
|
|
|
|
|
o(rangeAfter).equals(null)
|
2023-02-02 17:21:34 +01:00
|
|
|
})
|
2024-08-07 08:38:58 +02:00
|
|
|
|
2024-09-09 11:57:46 +02:00
|
|
|
o("deleteWholeList", async function () {
|
|
|
|
|
const listOne = "listId1"
|
|
|
|
|
const listTwo = "listId2"
|
|
|
|
|
await storage.init({ userId: "user", databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
const listOneMailOne = createTestEntity(MailTypeRef, { _id: [listOne, "id1"] })
|
|
|
|
|
const listOneMailTwo = createTestEntity(MailTypeRef, { _id: [listOne, "id2"] })
|
|
|
|
|
const listTwoMail = createTestEntity(MailTypeRef, { _id: [listTwo, "id3"] })
|
|
|
|
|
await storage.put(listOneMailOne)
|
|
|
|
|
await storage.put(listOneMailTwo)
|
|
|
|
|
await storage.put(listTwoMail)
|
|
|
|
|
await storage.setNewRangeForList(MailTypeRef, listOne, "id1", "id2")
|
|
|
|
|
await storage.setNewRangeForList(MailTypeRef, listTwo, "id3", "id3")
|
|
|
|
|
|
|
|
|
|
await storage.deleteWholeList(MailTypeRef, listOne)
|
|
|
|
|
|
|
|
|
|
const mailsInListOne = await storage.getWholeList(MailTypeRef, listOne)
|
|
|
|
|
const mailsInListTwo = await storage.getWholeList(MailTypeRef, listTwo)
|
|
|
|
|
const rangeListOne = await storage.getRangeForList(MailTypeRef, listOne)
|
|
|
|
|
const rangeListTwo = await storage.getRangeForList(MailTypeRef, listTwo)
|
|
|
|
|
|
|
|
|
|
o(mailsInListOne).deepEquals([])
|
|
|
|
|
o(mailsInListTwo).deepEquals([listTwoMail])
|
|
|
|
|
o(rangeListOne).equals(null)
|
|
|
|
|
o(rangeListTwo).deepEquals({ lower: "id3", upper: "id3" })
|
|
|
|
|
})
|
|
|
|
|
|
2024-08-07 08:38:58 +02:00
|
|
|
o("provideMultiple", async function () {
|
|
|
|
|
const listId = "listId1"
|
|
|
|
|
const elementId1 = "id1"
|
|
|
|
|
const elementId2 = "id2"
|
|
|
|
|
const storableMail1 = createTestEntity(MailTypeRef, { _id: [listId, elementId1] })
|
|
|
|
|
const storableMail2 = createTestEntity(MailTypeRef, { _id: [listId, elementId2] })
|
|
|
|
|
|
|
|
|
|
await storage.init({ userId: elementId1, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let mails = await storage.provideMultiple(MailTypeRef, listId, [elementId1])
|
|
|
|
|
o(mails).deepEquals([])
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMail1)
|
|
|
|
|
|
|
|
|
|
mails = await storage.provideMultiple(MailTypeRef, listId, [elementId1, elementId2])
|
|
|
|
|
o(mails).deepEquals([storableMail1])
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMail2)
|
|
|
|
|
|
|
|
|
|
mails = await storage.provideMultiple(MailTypeRef, listId, [elementId1, elementId2])
|
|
|
|
|
o(mails).deepEquals([storableMail1, storableMail2])
|
|
|
|
|
})
|
2023-02-02 17:21:34 +01:00
|
|
|
})
|
|
|
|
|
|
2024-08-26 15:07:37 +02:00
|
|
|
o.spec("ListElementType customId", function () {
|
|
|
|
|
o("deleteAllOfType", async function () {
|
|
|
|
|
const listId = "listId1"
|
|
|
|
|
const elementId = constructMailSetEntryId(new Date(), "mailId")
|
|
|
|
|
const storableMailSetEntry = createTestEntity(MailSetEntryTypeRef, { _id: [listId, elementId] })
|
|
|
|
|
|
|
|
|
|
await storage.init({ userId: elementId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let mailSetEntry = await storage.get(MailSetEntryTypeRef, listId, elementId)
|
|
|
|
|
o(mailSetEntry).equals(null)
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMailSetEntry)
|
|
|
|
|
await storage.setNewRangeForList(MailSetEntryTypeRef, listId, elementId, elementId)
|
|
|
|
|
|
|
|
|
|
mailSetEntry = await storage.get(MailSetEntryTypeRef, listId, elementId)
|
|
|
|
|
o(mailSetEntry!._id).deepEquals(storableMailSetEntry._id)
|
|
|
|
|
const rangeBefore = await storage.getRangeForList(MailSetEntryTypeRef, listId)
|
|
|
|
|
o(rangeBefore).deepEquals({ upper: elementId, lower: elementId })
|
|
|
|
|
await storage.deleteAllOfType(MailSetEntryTypeRef)
|
|
|
|
|
|
|
|
|
|
mailSetEntry = await storage.get(MailSetEntryTypeRef, listId, elementId)
|
|
|
|
|
o(mailSetEntry).equals(null)
|
|
|
|
|
const rangeAfter = await storage.getRangeForList(MailSetEntryTypeRef, listId)
|
|
|
|
|
o(rangeAfter).equals(null)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("provideMultiple", async function () {
|
|
|
|
|
const listId = "listId1"
|
|
|
|
|
const elementId1 = constructMailSetEntryId(new Date(1724675875113), "mailId1")
|
|
|
|
|
const elementId2 = constructMailSetEntryId(new Date(1724675899978), "mailId2")
|
|
|
|
|
const storableMailSetEntry1 = createTestEntity(MailSetEntryTypeRef, { _id: [listId, elementId1] })
|
|
|
|
|
const storableMailSetEntry2 = createTestEntity(MailSetEntryTypeRef, { _id: [listId, elementId2] })
|
|
|
|
|
|
|
|
|
|
await storage.init({ userId: elementId1, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let mails = await storage.provideMultiple(MailSetEntryTypeRef, listId, [elementId1])
|
|
|
|
|
o(mails).deepEquals([])
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMailSetEntry1)
|
|
|
|
|
|
|
|
|
|
mails = await storage.provideMultiple(MailSetEntryTypeRef, listId, [elementId1, elementId2])
|
|
|
|
|
o(mails).deepEquals([storableMailSetEntry1])
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMailSetEntry2)
|
|
|
|
|
|
|
|
|
|
mails = await storage.provideMultiple(MailSetEntryTypeRef, listId, [elementId1, elementId2])
|
|
|
|
|
o(mails).deepEquals([storableMailSetEntry1, storableMailSetEntry2])
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
o.spec("BlobElementType", function () {
|
|
|
|
|
o("put, get and delete", async function () {
|
|
|
|
|
const archiveId = "archiveId"
|
|
|
|
|
const blobElementId = "id1"
|
2023-11-10 16:59:39 +01:00
|
|
|
const storableMailDetails = createTestEntity(MailDetailsBlobTypeRef, {
|
|
|
|
|
_id: [archiveId, blobElementId],
|
|
|
|
|
details: createTestEntity(MailDetailsTypeRef),
|
|
|
|
|
})
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
|
|
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
let mailDetailsBlob = await storage.get(MailDetailsBlobTypeRef, archiveId, blobElementId)
|
|
|
|
|
o(mailDetailsBlob).equals(null)
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMailDetails)
|
|
|
|
|
|
|
|
|
|
mailDetailsBlob = await storage.get(MailDetailsBlobTypeRef, archiveId, blobElementId)
|
|
|
|
|
mailDetailsBlob!.details._type = MailDetailsTypeRef // we do not set the proper typeRef class on nested aggregates, so we overwrite it here
|
|
|
|
|
o(mailDetailsBlob).deepEquals(storableMailDetails)
|
|
|
|
|
|
|
|
|
|
await storage.deleteIfExists(MailDetailsBlobTypeRef, archiveId, blobElementId)
|
|
|
|
|
|
|
|
|
|
mailDetailsBlob = await storage.get(MailDetailsBlobTypeRef, archiveId, blobElementId)
|
|
|
|
|
o(mailDetailsBlob).equals(null)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("put, get and deleteAllOwnedBy", async function () {
|
|
|
|
|
const archiveId = "archiveId"
|
|
|
|
|
const blobElementId = "id1"
|
|
|
|
|
const _ownerGroup = "ownerGroup"
|
2023-11-10 16:59:39 +01:00
|
|
|
const storableMailDetails = createTestEntity(MailDetailsBlobTypeRef, {
|
2023-11-09 17:04:42 +01:00
|
|
|
_id: [archiveId, blobElementId],
|
|
|
|
|
_ownerGroup,
|
|
|
|
|
details: createTestEntity(MailDetailsTypeRef),
|
|
|
|
|
})
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
|
|
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
await storage.put(storableMailDetails)
|
|
|
|
|
|
|
|
|
|
await storage.deleteAllOwnedBy(_ownerGroup)
|
|
|
|
|
|
|
|
|
|
const mailDetailsBlob = await storage.get(MailDetailsBlobTypeRef, archiveId, blobElementId)
|
|
|
|
|
o(mailDetailsBlob).equals(null)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2024-08-26 15:07:37 +02:00
|
|
|
o.spec("Clearing excluded data for MailSet mailbox", function () {
|
|
|
|
|
const spamFolderId = "spamFolder"
|
|
|
|
|
const trashFolderId = "trashFolder"
|
|
|
|
|
const spamListId = "spamList"
|
|
|
|
|
const trashListId = "trashList"
|
|
|
|
|
const spamMailSetEntriesId = "spamMailSetEntriesId"
|
|
|
|
|
const trashMailSetEntriesId = "trashMailSetEntriesId"
|
|
|
|
|
const mailListId = "listId"
|
|
|
|
|
const mailType = getTypeId(MailTypeRef)
|
|
|
|
|
|
|
|
|
|
o.beforeEach(async function () {
|
|
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailBoxTypeRef, {
|
|
|
|
|
_id: "mailboxId",
|
|
|
|
|
currentMailBag: createTestEntity(MailBagTypeRef, { _id: "mailBagId", mails: mailListId }),
|
|
|
|
|
folders: createMailFolderRef({ folders: "mailFolderList" }),
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailFolderTypeRef, {
|
|
|
|
|
_id: ["mailFolderList", spamFolderId],
|
|
|
|
|
mails: spamListId,
|
|
|
|
|
entries: spamMailSetEntriesId,
|
|
|
|
|
folderType: MailSetKind.SPAM,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailFolderTypeRef, {
|
|
|
|
|
_id: ["mailFolderList", trashFolderId],
|
|
|
|
|
mails: trashListId,
|
|
|
|
|
entries: trashMailSetEntriesId,
|
|
|
|
|
folderType: MailSetKind.TRASH,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("ranges before timeRangeDays will be deleted", async function () {
|
|
|
|
|
const upperBeforeTimeRangeDays = offsetId(-1)
|
|
|
|
|
const lowerBeforeTimeRangeDays = offsetId(-2)
|
|
|
|
|
const upperDate = getDayShifted(now, 0 - timeRangeDays - 1)
|
|
|
|
|
const lowerDate = getDayShifted(now, 0 - timeRangeDays - 2)
|
|
|
|
|
const mailSetEntryTypeModel = await resolveTypeReference(MailSetEntryTypeRef)
|
|
|
|
|
const lowerMailSetEntryIdBeforeTimeRangeDays = ensureBase64Ext(mailSetEntryTypeModel, constructMailSetEntryId(lowerDate, GENERATED_MIN_ID))
|
|
|
|
|
const upperMailSetEntryIdBeforeTimeRangeDays = ensureBase64Ext(mailSetEntryTypeModel, constructMailSetEntryId(upperDate, GENERATED_MAX_ID))
|
|
|
|
|
const mailId: IdTuple = [mailListId, "anything"]
|
|
|
|
|
const mailSetEntryId: IdTuple = ["mailSetEntriesListId", constructMailSetEntryId(upperDate, elementIdPart(mailId))]
|
|
|
|
|
const mailDetailsBlobId: IdTuple = ["mailDetailsList", "mailDetailsBlobId"]
|
|
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailFolderTypeRef, {
|
|
|
|
|
_id: ["mailFolderList", "mailFolderId"],
|
|
|
|
|
mails: mailListId,
|
|
|
|
|
entries: listIdPart(mailSetEntryId),
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
await insertEntity(createTestEntity(MailSetEntryTypeRef, { _id: mailSetEntryId, mail: mailId }))
|
|
|
|
|
await insertEntity(createTestEntity(MailTypeRef, { _id: mailId, mailDetails: mailDetailsBlobId, sets: [mailSetEntryId] }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: mailDetailsBlobId, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertRange(
|
|
|
|
|
MailSetEntryTypeRef,
|
|
|
|
|
listIdPart(mailSetEntryId),
|
|
|
|
|
lowerMailSetEntryIdBeforeTimeRangeDays,
|
|
|
|
|
upperMailSetEntryIdBeforeTimeRangeDays,
|
|
|
|
|
)
|
|
|
|
|
await insertRange(MailTypeRef, mailListId, lowerBeforeTimeRangeDays, upperBeforeTimeRangeDays)
|
|
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
|
|
|
|
const allRanges = await dbFacade.all("SELECT * FROM ranges", [])
|
|
|
|
|
o(allRanges).deepEquals([])
|
|
|
|
|
const allMails = await getAllIdsForType(MailTypeRef)
|
|
|
|
|
o(allMails).deepEquals([])
|
|
|
|
|
const allMailSetEntries = await getAllIdsForType(MailSetEntryTypeRef)
|
|
|
|
|
o(allMailSetEntries).deepEquals([])
|
|
|
|
|
const allBlobDetails = await getAllIdsForType(MailDetailsBlobTypeRef)
|
|
|
|
|
o(allBlobDetails).deepEquals([])
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// we should refactor these tests once all mailboxes are migrated to the new MailSet architecture
|
|
|
|
|
o.spec("Clearing excluded data for Non-MailSet mailbox", function () {
|
2023-01-12 14:54:42 +01:00
|
|
|
const spamFolderId = "spamFolder"
|
|
|
|
|
const trashFolderId = "trashFolder"
|
|
|
|
|
const spamListId = "spamList"
|
|
|
|
|
const trashListId = "trashList"
|
2022-04-20 10:39:52 +02:00
|
|
|
const listId = "listId"
|
2022-05-23 17:09:09 +02:00
|
|
|
const mailType = getTypeId(MailTypeRef)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2023-01-12 14:54:42 +01:00
|
|
|
o.beforeEach(async function () {
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(
|
2024-08-07 08:38:58 +02:00
|
|
|
createTestEntity(MailBoxTypeRef, { _id: "mailboxId", currentMailBag: null, folders: createMailFolderRef({ folders: "mailFolderList" }) }),
|
2023-11-10 16:59:39 +01:00
|
|
|
)
|
|
|
|
|
await insertEntity(
|
2024-08-07 08:38:58 +02:00
|
|
|
createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", spamFolderId], mails: spamListId, folderType: MailSetKind.SPAM }),
|
|
|
|
|
)
|
|
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", trashFolderId], mails: trashListId, folderType: MailSetKind.TRASH }),
|
2023-11-10 16:59:39 +01:00
|
|
|
)
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
})
|
|
|
|
|
|
2024-08-26 15:07:37 +02:00
|
|
|
o("ranges before timeRangeDays will be deleted", async function () {
|
|
|
|
|
const upperBeforeTimeRangeDays = offsetId(-1)
|
|
|
|
|
const lowerBeforeTimeRangeDays = offsetId(-2)
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const mailDetailsBlobId: IdTuple = ["mailDetailsList", "mailDetailsBlobId"]
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "mailFolderId"], mails: listId }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: mailDetailsBlobId, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertEntity(createTestEntity(MailTypeRef, { _id: [listId, "anything"], mailDetails: mailDetailsBlobId }))
|
2024-08-26 15:07:37 +02:00
|
|
|
await insertRange(MailTypeRef, listId, lowerBeforeTimeRangeDays, upperBeforeTimeRangeDays)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-11-30 17:15:08 +01:00
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const allRanges = await dbFacade.all("SELECT * FROM ranges", [])
|
|
|
|
|
o(allRanges).deepEquals([])
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const allMails = await getAllIdsForType(MailTypeRef)
|
|
|
|
|
o(allMails).deepEquals([])
|
|
|
|
|
const allBlobDetails = await getAllIdsForType(MailDetailsBlobTypeRef)
|
|
|
|
|
o(allBlobDetails).deepEquals([])
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("modified ranges will be shrunk", async function () {
|
|
|
|
|
const upper = offsetId(2)
|
|
|
|
|
const lower = offsetId(-2)
|
2024-08-07 08:38:58 +02:00
|
|
|
await insertEntity(
|
|
|
|
|
createTestEntity(MailFolderTypeRef, {
|
|
|
|
|
_id: ["mailFolderList", "mailFolderId"],
|
|
|
|
|
folderType: MailSetKind.INBOX,
|
|
|
|
|
mails: listId,
|
|
|
|
|
}),
|
|
|
|
|
)
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertRange(MailTypeRef, listId, lower, upper)
|
2022-11-30 17:15:08 +01:00
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const newRange = await dbFacade.get("select * from ranges", [])
|
2022-12-27 15:37:40 +01:00
|
|
|
o(mapNullable(newRange, untagSqlObject)).deepEquals({ type: mailType, listId, lower: cutoffId, upper })
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("unmodified ranges will not be deleted or shrunk", async function () {
|
|
|
|
|
const upper = offsetId(2)
|
|
|
|
|
const lower = offsetId(1)
|
|
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "mailFolderId"], mails: listId }))
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertRange(MailTypeRef, listId, lower, upper)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-11-30 17:15:08 +01:00
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const newRange = await dbFacade.get("select * from ranges", [])
|
2022-12-27 15:37:40 +01:00
|
|
|
o(mapNullable(newRange, untagSqlObject)).deepEquals({ type: mailType, listId, lower, upper })
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("complete ranges won't be lost if entities are all newer than cutoff", async function () {
|
|
|
|
|
const upper = offsetId(2)
|
|
|
|
|
const lower = GENERATED_MIN_ID
|
2023-11-10 16:59:39 +01:00
|
|
|
const mail = createTestEntity(MailTypeRef, { _id: [listId, offsetId(1)] })
|
|
|
|
|
const mailFolder = createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "folderId"], mails: listId })
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertEntity(mailFolder)
|
|
|
|
|
await insertEntity(mail)
|
|
|
|
|
await insertRange(MailTypeRef, listId, lower, upper)
|
2022-11-30 17:15:08 +01:00
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
2022-08-11 16:38:53 +02:00
|
|
|
|
|
|
|
|
const newRange = await dbFacade.get("select * from ranges", [])
|
2022-12-27 15:37:40 +01:00
|
|
|
o(mapNullable(newRange, untagSqlObject)).deepEquals({ type: mailType, listId, lower, upper })
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const allFolderIds = await getAllIdsForType(MailFolderTypeRef)
|
2023-01-12 14:54:42 +01:00
|
|
|
o(allFolderIds).deepEquals(["folderId", spamFolderId, trashFolderId])
|
2022-08-11 16:38:53 +02:00
|
|
|
const allMailIds = await getAllIdsForType(MailTypeRef)
|
|
|
|
|
o(allMailIds).deepEquals([getElementId(mail)])
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
2023-01-12 14:54:42 +01:00
|
|
|
o("trash and spam descendants are cleared", async function () {
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const spamDetailsId: IdTuple = ["detailsListId", "spamDetailsId"]
|
|
|
|
|
const trashDetailsId: IdTuple = ["detailsListId", "trashDetailsId"]
|
|
|
|
|
const trashSubfolderDetailsId: IdTuple = ["detailsListId", "trashSubFolderDetailsId"]
|
|
|
|
|
|
2023-01-12 14:54:42 +01:00
|
|
|
const trashSubfolderId = "trashSubfolderId"
|
|
|
|
|
const trashSubfolderListId = "trashSubfolderListId"
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const spamMailId = offsetId(2)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const spamMail = createTestEntity(MailTypeRef, { _id: [spamListId, spamMailId], mailDetails: spamDetailsId })
|
2022-08-11 16:38:53 +02:00
|
|
|
const trashMailId = offsetId(2)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const trashMail = createTestEntity(MailTypeRef, { _id: [trashListId, trashMailId], mailDetails: trashDetailsId })
|
2023-01-12 14:54:42 +01:00
|
|
|
const trashSubfolderMailId = offsetId(2)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const trashSubfolderMail = createTestEntity(MailTypeRef, {
|
|
|
|
|
_id: [trashSubfolderListId, trashSubfolderMailId],
|
|
|
|
|
mailDetails: trashSubfolderDetailsId,
|
|
|
|
|
})
|
2023-01-12 14:54:42 +01:00
|
|
|
|
|
|
|
|
await insertEntity(
|
2023-11-10 16:59:39 +01:00
|
|
|
createTestEntity(MailFolderTypeRef, {
|
2023-01-12 14:54:42 +01:00
|
|
|
_id: ["mailFolderList", trashSubfolderId],
|
|
|
|
|
parentFolder: ["mailFolderList", trashFolderId],
|
|
|
|
|
mails: trashSubfolderListId,
|
2024-08-07 08:38:58 +02:00
|
|
|
folderType: MailSetKind.CUSTOM,
|
2023-01-12 14:54:42 +01:00
|
|
|
}),
|
|
|
|
|
)
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertEntity(spamMail)
|
|
|
|
|
await insertEntity(trashMail)
|
2023-01-12 14:54:42 +01:00
|
|
|
await insertEntity(trashSubfolderMail)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: spamDetailsId, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: trashDetailsId, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: trashSubfolderDetailsId, details: createTestEntity(MailDetailsTypeRef) }))
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-11-30 17:15:08 +01:00
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
const allEntities = await dbFacade.all("select * from list_entities", [])
|
2023-01-12 14:54:42 +01:00
|
|
|
o(allEntities.map((r) => r.elementId.value)).deepEquals([spamFolderId, trashFolderId, trashSubfolderId])
|
2022-08-11 16:38:53 +02:00
|
|
|
|
2023-01-12 14:54:42 +01:00
|
|
|
o(await getAllIdsForType(MailFolderTypeRef)).deepEquals([spamFolderId, trashFolderId, trashSubfolderId])
|
2022-08-11 16:38:53 +02:00
|
|
|
o(await getAllIdsForType(MailTypeRef)).deepEquals([])
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
o(await getAllIdsForType(MailDetailsBlobTypeRef)).deepEquals([])
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
2023-01-12 17:26:41 +01:00
|
|
|
o("trash and spam are cleared", async function () {
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const spamDetailsId: IdTuple = ["detailsListId", "spamDetailsId"]
|
|
|
|
|
const trashDetailsId: IdTuple = ["detailsListId", "trashDetailsId"]
|
|
|
|
|
|
|
|
|
|
const spamMailId = offsetId(2)
|
|
|
|
|
const trashMailId = offsetId(2)
|
2023-11-10 16:59:39 +01:00
|
|
|
const spamMail = createTestEntity(MailTypeRef, { _id: [spamListId, spamMailId], mailDetails: spamDetailsId })
|
|
|
|
|
const trashMail = createTestEntity(MailTypeRef, { _id: [trashListId, trashMailId], mailDetails: trashDetailsId })
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
|
|
|
|
|
await storage.init({ userId, databaseKey, timeRangeDays, forceNewDatabase: false })
|
|
|
|
|
|
|
|
|
|
await insertEntity(spamMail)
|
|
|
|
|
await insertEntity(trashMail)
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: spamDetailsId, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: trashDetailsId, details: createTestEntity(MailDetailsTypeRef) }))
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
|
|
|
|
const allEntities = await dbFacade.all("select * from list_entities", [])
|
|
|
|
|
o(allEntities.map((r) => r.elementId.value)).deepEquals([spamFolderId, trashFolderId])
|
|
|
|
|
|
|
|
|
|
o(await getAllIdsForType(MailFolderTypeRef)).deepEquals([spamFolderId, trashFolderId])
|
|
|
|
|
o(await getAllIdsForType(MailTypeRef)).deepEquals([])
|
|
|
|
|
o(await getAllIdsForType(MailDetailsBlobTypeRef)).deepEquals([])
|
|
|
|
|
})
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
o("normal folder is partially cleared", async function () {
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const beforeMailDetailsId: IdTuple = ["detailsListId", "beforeDetailsId"]
|
|
|
|
|
const afterMailDetailsId: IdTuple = ["detailsListId", "afterDetailsId"]
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
const inboxMailList = "inboxMailList"
|
|
|
|
|
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mailBefore = createTestEntity(MailTypeRef, { _id: [inboxMailList, offsetId(-2)], mailDetails: beforeMailDetailsId })
|
|
|
|
|
const mailAfter = createTestEntity(MailTypeRef, { _id: [inboxMailList, offsetId(2)], mailDetails: afterMailDetailsId })
|
|
|
|
|
const beforeMailDetails = createTestEntity(MailDetailsBlobTypeRef, { _id: beforeMailDetailsId, details: createTestEntity(MailDetailsTypeRef) })
|
|
|
|
|
const afterMailDetails = createTestEntity(MailDetailsBlobTypeRef, { _id: afterMailDetailsId, details: createTestEntity(MailDetailsTypeRef) })
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(
|
2024-08-07 08:38:58 +02:00
|
|
|
createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "folderId"], mails: inboxMailList, folderType: MailSetKind.INBOX }),
|
2023-11-10 16:59:39 +01:00
|
|
|
)
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertEntity(mailBefore)
|
|
|
|
|
await insertEntity(mailAfter)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await insertEntity(beforeMailDetails)
|
|
|
|
|
await insertEntity(afterMailDetails)
|
2022-11-30 17:15:08 +01:00
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
2022-08-11 16:38:53 +02:00
|
|
|
|
|
|
|
|
const allMailIds = await getAllIdsForType(MailTypeRef)
|
|
|
|
|
o(allMailIds).deepEquals([getElementId(mailAfter)])
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const allMailDetailsIds = await getAllIdsForType(MailDetailsBlobTypeRef)
|
|
|
|
|
o(allMailDetailsIds).deepEquals([getElementId(afterMailDetails)])
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
2022-04-06 16:55:16 +02:00
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
o("normal folder is completely cleared", async function () {
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mailDetailsId1: IdTuple = ["detailsListId", "mailDetailsId1"]
|
|
|
|
|
const mailDetailsId2: IdTuple = ["detailsListId", "mailDetailsId2"]
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
const inboxMailList = "inboxMailList"
|
2022-04-06 16:55:16 +02:00
|
|
|
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mail1 = createTestEntity(MailTypeRef, { _id: [inboxMailList, offsetId(-2)], mailDetails: mailDetailsId1 })
|
|
|
|
|
const mail2 = createTestEntity(MailTypeRef, { _id: [inboxMailList, offsetId(-3)], mailDetails: mailDetailsId2 })
|
2022-04-06 16:55:16 +02:00
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(
|
2024-08-07 08:38:58 +02:00
|
|
|
createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "folderId"], mails: inboxMailList, folderType: MailSetKind.INBOX }),
|
2023-11-10 16:59:39 +01:00
|
|
|
)
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertEntity(mail1)
|
|
|
|
|
await insertEntity(mail2)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: mailDetailsId1, details: createTestEntity(MailDetailsTypeRef) }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: mailDetailsId2, details: createTestEntity(MailDetailsTypeRef) }))
|
2022-11-30 17:15:08 +01:00
|
|
|
|
|
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
2022-08-11 16:38:53 +02:00
|
|
|
|
|
|
|
|
o(await getAllIdsForType(MailTypeRef)).deepEquals([])
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
o(await getAllIdsForType(MailDetailsBlobTypeRef)).deepEquals([])
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
o("when mail is deleted, attachment is also deleted", async function () {
|
|
|
|
|
const inboxMailList = "inboxMailList"
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const beforeMailDetailsId: IdTuple = ["detailsListId", "beforeDetailsId"]
|
|
|
|
|
const afterMailDetailsId: IdTuple = ["detailsListId", "afterDetailsId"]
|
2022-04-20 10:39:52 +02:00
|
|
|
const fileListId = "fileListId"
|
|
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
const fileBefore = createTestEntity(FileTypeRef, { _id: [fileListId, "fileBefore"] })
|
|
|
|
|
const fileAfter = createTestEntity(FileTypeRef, { _id: [fileListId, "fileAfter"] })
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mailBefore = createTestEntity(MailTypeRef, {
|
|
|
|
|
_id: [inboxMailList, offsetId(-2)],
|
|
|
|
|
mailDetails: beforeMailDetailsId,
|
|
|
|
|
attachments: [fileBefore._id],
|
|
|
|
|
})
|
|
|
|
|
const mailAfter = createTestEntity(MailTypeRef, {
|
|
|
|
|
_id: [inboxMailList, offsetId(2)],
|
|
|
|
|
mailDetails: afterMailDetailsId,
|
|
|
|
|
attachments: [fileAfter._id],
|
|
|
|
|
})
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2023-11-10 16:59:39 +01:00
|
|
|
await insertEntity(
|
2024-08-07 08:38:58 +02:00
|
|
|
createTestEntity(MailFolderTypeRef, { _id: ["mailFolderList", "folderId"], mails: inboxMailList, folderType: MailSetKind.INBOX }),
|
2023-11-10 16:59:39 +01:00
|
|
|
)
|
2022-08-11 16:38:53 +02:00
|
|
|
await insertEntity(mailBefore)
|
|
|
|
|
await insertEntity(mailAfter)
|
|
|
|
|
await insertEntity(fileBefore)
|
|
|
|
|
await insertEntity(fileAfter)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: beforeMailDetailsId }))
|
|
|
|
|
await insertEntity(createTestEntity(MailDetailsBlobTypeRef, { _id: afterMailDetailsId }))
|
2022-08-11 16:38:53 +02:00
|
|
|
|
2022-11-30 17:15:08 +01:00
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
o(await getAllIdsForType(MailTypeRef)).deepEquals([getElementId(mailAfter)])
|
|
|
|
|
o(await getAllIdsForType(FileTypeRef)).deepEquals([getElementId(fileAfter)])
|
|
|
|
|
})
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
2022-04-06 16:55:16 +02:00
|
|
|
})
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
o.spec("Integration test", function () {
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
function createMailList(numMails, listId, idGenerator, getSubject, getBody): { mails: Array<Mail>; mailDetailsBlobs: Array<MailDetailsBlob> } {
|
2022-04-20 10:39:52 +02:00
|
|
|
const mails: Array<Mail> = []
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mailDetailsBlobs: Array<MailDetailsBlob> = []
|
2022-04-20 10:39:52 +02:00
|
|
|
for (let i = 0; i < numMails; ++i) {
|
|
|
|
|
const mailId = idGenerator.getNext()
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const mailDetailsId = idGenerator.getNext()
|
2022-12-27 15:37:40 +01:00
|
|
|
mails.push(
|
2023-11-10 16:59:39 +01:00
|
|
|
createTestEntity(MailTypeRef, {
|
2022-12-27 15:37:40 +01:00
|
|
|
_id: [listId, mailId],
|
|
|
|
|
subject: getSubject(i),
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
mailDetails: ["detailsListId", mailDetailsId],
|
2022-12-27 15:37:40 +01:00
|
|
|
}),
|
|
|
|
|
)
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
mailDetailsBlobs.push(
|
|
|
|
|
createTestEntity(MailDetailsBlobTypeRef, {
|
|
|
|
|
_id: ["detailsListId", mailDetailsId],
|
|
|
|
|
details: createTestEntity(MailDetailsTypeRef, {
|
|
|
|
|
_id: mailDetailsId,
|
|
|
|
|
body: createTestEntity(BodyTypeRef, { text: getBody(i) }),
|
|
|
|
|
}),
|
2022-12-27 15:37:40 +01:00
|
|
|
}),
|
|
|
|
|
)
|
2022-04-20 10:39:52 +02:00
|
|
|
}
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
return { mails, mailDetailsBlobs: mailDetailsBlobs }
|
2022-04-20 10:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o("cleanup works as expected", async function () {
|
|
|
|
|
// Time range is five days
|
|
|
|
|
const oldIds = new IdGenerator(offsetId(-5))
|
|
|
|
|
const newIds = new IdGenerator(offsetId(5))
|
|
|
|
|
|
2024-08-07 08:38:58 +02:00
|
|
|
const userMailbox = createTestEntity(MailBoxTypeRef, {
|
|
|
|
|
_id: "mailboxId",
|
|
|
|
|
currentMailBag: null,
|
|
|
|
|
folders: createMailFolderRef({ folders: "mailFolderList" }),
|
|
|
|
|
})
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
const inboxListId = oldIds.getNext()
|
2023-11-10 16:59:39 +01:00
|
|
|
const inboxFolder = createTestEntity(MailFolderTypeRef, {
|
2024-08-07 08:38:58 +02:00
|
|
|
_id: ["mailFolderList", oldIds.getNext()],
|
2022-04-20 10:39:52 +02:00
|
|
|
mails: inboxListId,
|
2024-08-07 08:38:58 +02:00
|
|
|
folderType: MailSetKind.INBOX,
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const { mails: oldInboxMails, mailDetailsBlobs: oldInboxMailDetailsBlobs } = createMailList(
|
2022-12-27 15:37:40 +01:00
|
|
|
3,
|
|
|
|
|
inboxListId,
|
|
|
|
|
oldIds,
|
|
|
|
|
(i) => `old subject ${i}`,
|
|
|
|
|
(i) => `old body ${i}`,
|
|
|
|
|
)
|
|
|
|
|
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const { mails: newInboxMails, mailDetailsBlobs: newInboxMailDetailsBlobs } = createMailList(
|
2022-12-27 15:37:40 +01:00
|
|
|
3,
|
|
|
|
|
inboxListId,
|
|
|
|
|
newIds,
|
|
|
|
|
(i) => `new subject ${i}`,
|
|
|
|
|
(i) => `new body ${i}`,
|
|
|
|
|
)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
const trashListId = oldIds.getNext()
|
2023-11-10 16:59:39 +01:00
|
|
|
const trashFolder = createTestEntity(MailFolderTypeRef, {
|
2024-08-07 08:38:58 +02:00
|
|
|
_id: ["mailFolderList", oldIds.getNext()],
|
2022-04-20 10:39:52 +02:00
|
|
|
mails: trashListId,
|
2024-08-07 08:38:58 +02:00
|
|
|
folderType: MailSetKind.TRASH,
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
const { mails: trashMails, mailDetailsBlobs: trashMailDetailsBlobs } = createMailList(
|
2022-12-27 15:37:40 +01:00
|
|
|
3,
|
|
|
|
|
trashListId,
|
|
|
|
|
newIds,
|
|
|
|
|
(i) => `trash subject ${i}`,
|
|
|
|
|
(i) => `trash body ${i}`,
|
|
|
|
|
)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2023-01-12 14:54:42 +01:00
|
|
|
const spamListId = oldIds.getNext()
|
2023-11-10 16:59:39 +01:00
|
|
|
const spamFolder = createTestEntity(MailFolderTypeRef, {
|
2024-08-07 08:38:58 +02:00
|
|
|
_id: ["mailFolderList", oldIds.getNext()],
|
2023-01-12 14:54:42 +01:00
|
|
|
mails: spamListId,
|
2024-08-07 08:38:58 +02:00
|
|
|
folderType: MailSetKind.SPAM,
|
2023-01-12 14:54:42 +01:00
|
|
|
})
|
|
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
const everyEntity = [
|
2024-08-07 08:38:58 +02:00
|
|
|
userMailbox,
|
2022-12-27 15:37:40 +01:00
|
|
|
inboxFolder,
|
|
|
|
|
trashFolder,
|
2023-01-12 14:54:42 +01:00
|
|
|
spamFolder,
|
2022-12-27 15:37:40 +01:00
|
|
|
...oldInboxMails,
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
...oldInboxMailDetailsBlobs,
|
2022-12-27 15:37:40 +01:00
|
|
|
...newInboxMails,
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
...newInboxMailDetailsBlobs,
|
2022-12-27 15:37:40 +01:00
|
|
|
...trashMails,
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
...trashMailDetailsBlobs,
|
2022-04-20 10:39:52 +02:00
|
|
|
]
|
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
await storage.init({ userId, databaseKey: offlineDatabaseTestKey, timeRangeDays, forceNewDatabase: false })
|
2022-05-17 17:40:44 +02:00
|
|
|
|
2022-04-20 10:39:52 +02:00
|
|
|
for (let entity of everyEntity) {
|
2022-08-11 16:38:53 +02:00
|
|
|
await storage.put(entity)
|
2022-04-20 10:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-15 13:18:25 +01:00
|
|
|
await storage.setNewRangeForList(MailTypeRef, inboxListId, getFirstOrThrow(oldInboxMails)._id[1], lastThrow(newInboxMails)._id[1])
|
|
|
|
|
await storage.setNewRangeForList(MailTypeRef, trashListId, getFirstOrThrow(trashMails)._id[1], lastThrow(trashMails)._id[1])
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-11-30 17:15:08 +01:00
|
|
|
// Here we clear the excluded data
|
|
|
|
|
await storage.clearExcludedData(timeRangeDays, userId)
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
const assertContents = async ({ _id, _type }, expected, msg) => {
|
|
|
|
|
const { listId, elementId } = expandId(_id)
|
2022-08-11 16:38:53 +02:00
|
|
|
return o(await storage.get(_type, listId, elementId)).deepEquals(expected)(msg)
|
2022-04-20 10:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
await promiseMap(oldInboxMails, (mail) => assertContents(mail, null, `old mail ${mail._id} was deleted`))
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await promiseMap(oldInboxMailDetailsBlobs, (body) => assertContents(body, null, `old mailBody ${body._id} was deleted`))
|
2022-04-20 10:39:52 +02:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
await promiseMap(newInboxMails, (mail) => assertContents(mail, mail, `new mail ${mail._id} was not deleted`))
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await promiseMap(newInboxMailDetailsBlobs, (body) => assertContents(body, body, `new mailBody ${body._id} was not deleted`))
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
// All of trash should be cleared, even though the ids are old
|
2022-12-27 15:37:40 +01:00
|
|
|
await promiseMap(trashMails, (mail) => assertContents(mail, null, `trash mail ${mail._id} was deleted`))
|
Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).
Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
the "body", "toRecipients", "ccRecipients", "bccRecipients",
"replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
FILE_TYPE and CONTACT_TYPE
Closes #7255
Co-authored-by: sug <sug@tutao.de>
2024-07-23 10:05:35 +02:00
|
|
|
await promiseMap(trashMailDetailsBlobs, (body) => assertContents(body, null, `trash mailBody ${body._id} was deleted`))
|
2022-04-20 10:39:52 +02:00
|
|
|
|
|
|
|
|
await assertContents(inboxFolder, inboxFolder, `inbox folder was not deleted`)
|
|
|
|
|
await assertContents(trashFolder, trashFolder, `trash folder was not deleted`)
|
|
|
|
|
|
2022-08-11 16:38:53 +02:00
|
|
|
o(await storage.getRangeForList(MailTypeRef, inboxListId)).deepEquals({
|
2022-04-20 10:39:52 +02:00
|
|
|
lower: cutoffId,
|
2022-12-27 15:37:40 +01:00
|
|
|
upper: lastThrow(newInboxMails)._id[1],
|
2022-04-20 10:39:52 +02:00
|
|
|
})("lower range for inbox was set to cutoff")
|
2022-08-11 16:38:53 +02:00
|
|
|
o(await storage.getRangeForList(MailTypeRef, trashListId)).equals(null)("range for trash was deleted")
|
2022-04-20 10:39:52 +02:00
|
|
|
})
|
2022-04-06 16:55:16 +02:00
|
|
|
})
|
2022-12-27 15:37:40 +01:00
|
|
|
})
|