Skip to content

Commit

Permalink
drop online web clients support
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Dec 24, 2018
1 parent f55cc65 commit c5b7b95
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
10 changes: 1 addition & 9 deletions src/e2e/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ test.serial("general actions: app start, master password setup, add accounts, lo
if (!CI || platform() !== "linux") {
await workflow.addAccount({
type: "protonmail",
entryUrlValue: "https://app.protonmail.ch",
});
await workflow.addAccount({
type: "protonmail",
entryUrlValue: "https://mail.protonmail.com",
});
await workflow.addAccount({
type: "tutanota",
entryUrlValue: "https://mail.tutanota.com",
entryUrlValue: "https://beta.protonmail.com",
});
}
await workflow.logout();
Expand Down
19 changes: 18 additions & 1 deletion src/electron-main/storage-upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import compareVersions from "compare-versions";

import {APP_VERSION} from "src/shared/constants";
import {ACCOUNTS_CONFIG, ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX, APP_VERSION} from "src/shared/constants";
import {AccountConfig} from "src/shared/model/account";
import {Config, Settings} from "src/shared/model/options";
import {Database} from "./database";
import {DbAccountPk} from "src/shared/model/database";
import {EntryUrlItem} from "src/shared/types";
import {INITIAL_STORES} from "./constants";

const CONFIG_UPGRADES: Record<string, (config: Config) => void> = {
Expand Down Expand Up @@ -90,6 +91,22 @@ const SETTINGS_UPGRADES: Record<string, (settings: Settings) => void> = {
delete account.storeMails;
});
},
"2.0.0": (settings) => {
// dropping "online web clients" support, see https://github.com/vladimiry/email-securely-app/issues/80
const possibleEntryUrls: string[] = Object
.values(ACCOUNTS_CONFIG)
.reduce((list: EntryUrlItem[], {entryUrl}) => list.concat(entryUrl), [])
.map(({value}) => value);
settings.accounts.forEach((account) => {
if (possibleEntryUrls.includes(account.entryUrl)) {
return;
}
account.entryUrl = `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}${account.entryUrl}`;
if (!possibleEntryUrls.includes(account.entryUrl)) {
throw new Error(`Invalid entry url value "${account.entryUrl}"`);
}
});
},
};

export function upgradeConfig(config: Config): boolean {
Expand Down
26 changes: 7 additions & 19 deletions src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,29 @@ export const ACCOUNTS_CONFIG: Record<AccountType, Record<"entryUrl", EntryUrlIte
protonmail: {
entryUrl: [
{
value: "https://app.protonmail.ch",
title: "https://app.protonmail.ch (deprecated)",
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://mail.protonmail.com`,
title: `https://mail.protonmail.com (${getBuiltInWebClientTitle("protonmail")})`,
},
{
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://app.protonmail.ch`,
title: `https://app.protonmail.ch (${getBuiltInWebClientTitle("protonmail")})`,
},
{
value: "https://mail.protonmail.com",
title: "https://mail.protonmail.com (deprecated)",
},
{
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://mail.protonmail.com`,
title: `https://mail.protonmail.com (${getBuiltInWebClientTitle("protonmail")})`,
},
{
value: "https://beta.protonmail.com",
title: "https://beta.protonmail.com",
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://protonirockerxow.onion`,
title: `https://protonirockerxow.onion (${getBuiltInWebClientTitle("protonmail")})`,
},
{
value: "https://protonirockerxow.onion",
title: "https://protonirockerxow.onion (deprecated)",
},
{
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://protonirockerxow.onion`,
title: `https://protonirockerxow.onion (${getBuiltInWebClientTitle("protonmail")})`,
value: "https://beta.protonmail.com",
title: "https://beta.protonmail.com (deprecated)",
},
],
},
tutanota: {
entryUrl: [
{
value: "https://mail.tutanota.com",
title: "https://mail.tutanota.com (deprecated)",
},
{
value: `${ACCOUNTS_CONFIG_ENTRY_URL_LOCAL_PREFIX}https://mail.tutanota.com`,
title: `https://mail.tutanota.com (${getBuiltInWebClientTitle("tutanota")})`,
Expand All @@ -86,7 +74,7 @@ export const ACCOUNTS_CONFIG: Record<AccountType, Record<"entryUrl", EntryUrlIte
};

function getBuiltInWebClientTitle(accountType: AccountType): string {
return `built-in "web client" v${PROVIDER_REPO[accountType].version}-${PROVIDER_REPO[accountType].commit.substr(0, 7)}`;
return `v${PROVIDER_REPO[accountType].version}-${PROVIDER_REPO[accountType].commit.substr(0, 7)}`;
}

export const LOG_LEVELS: LogLevel[] = Object.keys(((stub: Record<LogLevel, null>) => stub)({
Expand Down
1 change: 1 addition & 0 deletions src/web/src/app/_options/account-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<div class="form-group required">
<ng-template #entryUrlItemTemplate let-item="item" let-index="index">
{{ item.title }}
<span class="badge badge-secondary" [ngClass]="{'badge-local': isLocalWebClient(item)}"></span>
</ng-template>
<label>Domain</label>
<ng-select [items]="entryUrlItems" [clearable]="false" formControlName="entryUrl" id="accountEditFormEntryUrlField"
Expand Down
1 change: 1 addition & 0 deletions src/webpack/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const configPatch: Record<BuildEnvironment, Configuration> = {
},
development: {
devServer: {
host: "127.0.0.1",
hot: true,
inline: true,
stats: "minimal",
Expand Down

0 comments on commit c5b7b95

Please sign in to comment.