@remit/backend 0.0.58 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -122,6 +122,7 @@ export const toAccountResponse = (
|
|
|
122
122
|
smtpUsername: account.smtpUsername ?? "",
|
|
123
123
|
signaturePlainText: signature.plainText,
|
|
124
124
|
signatureHtml: signature.html,
|
|
125
|
+
composeLanguages: overrides.composeLanguages,
|
|
125
126
|
isActive: account.isActive,
|
|
126
127
|
connectionState: account.connectionState,
|
|
127
128
|
lastConnectedAt: account.lastConnectedAt,
|
|
@@ -33,6 +33,25 @@ describe("groupAccountOverrides", () => {
|
|
|
33
33
|
assert.equal(grouped.get("acc-2")?.displayName, "Bob");
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
it("groups the compose-language list by accountId", () => {
|
|
37
|
+
const settings = [
|
|
38
|
+
setting("AccountComposeLanguages#acc-1", {
|
|
39
|
+
kind: "StringList",
|
|
40
|
+
value: ["nl", "en"],
|
|
41
|
+
}),
|
|
42
|
+
stringSetting("AccountDisplayName#acc-1", "Alice"),
|
|
43
|
+
];
|
|
44
|
+
const grouped = groupAccountOverrides(settings);
|
|
45
|
+
assert.deepEqual(grouped.get("acc-1")?.composeLanguages, ["nl", "en"]);
|
|
46
|
+
assert.equal(grouped.get("acc-1")?.displayName, "Alice");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("ignores a compose-language row stored under the wrong value kind", () => {
|
|
50
|
+
const settings = [stringSetting("AccountComposeLanguages#acc-1", "nl")];
|
|
51
|
+
const grouped = groupAccountOverrides(settings);
|
|
52
|
+
assert.equal(grouped.get("acc-1"), undefined);
|
|
53
|
+
});
|
|
54
|
+
|
|
36
55
|
it("ignores a leftover MailboxRole#<mailboxId> row instead of throwing", () => {
|
|
37
56
|
// Leftover rows from the #963/#964 backfill (superseded by
|
|
38
57
|
// FolderRoleAppointment, RFC 032 exclusive-folder-appointment #976) must
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
const ACCOUNT_OVERRIDE_NAMES = {
|
|
25
25
|
displayName: "AccountDisplayName",
|
|
26
26
|
muted: "AccountMuted",
|
|
27
|
+
composeLanguages: "AccountComposeLanguages",
|
|
27
28
|
} as const;
|
|
28
29
|
|
|
29
30
|
const MAILBOX_OVERRIDE_NAMES = {
|
|
@@ -34,6 +35,7 @@ const MAILBOX_OVERRIDE_NAMES = {
|
|
|
34
35
|
export interface AccountOverrides {
|
|
35
36
|
displayName?: string;
|
|
36
37
|
muted?: MutedFlag;
|
|
38
|
+
composeLanguages?: string[];
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export interface MailboxOverrides {
|
|
@@ -53,6 +55,12 @@ const mutedValueOf = (item: AccountSettingItem): MutedFlag | undefined => {
|
|
|
53
55
|
return undefined;
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
const stringListValueOf = (item: AccountSettingItem): string[] | undefined => {
|
|
59
|
+
const { value } = item;
|
|
60
|
+
if (value.kind === "StringList") return value.value;
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
56
64
|
const targetIdOf = (name: string): string | undefined => {
|
|
57
65
|
const idx = name.indexOf(SETTING_NAME_SEPARATOR);
|
|
58
66
|
if (idx === -1) return undefined;
|
|
@@ -85,6 +93,14 @@ export const groupAccountOverrides = (
|
|
|
85
93
|
const current = byAccount.get(accountId) ?? {};
|
|
86
94
|
current.muted = muted;
|
|
87
95
|
byAccount.set(accountId, current);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (base === ACCOUNT_OVERRIDE_NAMES.composeLanguages) {
|
|
99
|
+
const composeLanguages = stringListValueOf(setting);
|
|
100
|
+
if (composeLanguages === undefined) continue;
|
|
101
|
+
const current = byAccount.get(accountId) ?? {};
|
|
102
|
+
current.composeLanguages = composeLanguages;
|
|
103
|
+
byAccount.set(accountId, current);
|
|
88
104
|
}
|
|
89
105
|
}
|
|
90
106
|
return byAccount;
|
|
@@ -99,7 +115,7 @@ export const loadAccountOverrides = async (
|
|
|
99
115
|
accountConfigId: string,
|
|
100
116
|
accountId: string,
|
|
101
117
|
): Promise<AccountOverrides> => {
|
|
102
|
-
const [displayName, muted] = await Promise.all([
|
|
118
|
+
const [displayName, muted, composeLanguages] = await Promise.all([
|
|
103
119
|
accountSetting.get(
|
|
104
120
|
accountConfigId,
|
|
105
121
|
composeSettingName(ACCOUNT_OVERRIDE_NAMES.displayName, accountId),
|
|
@@ -108,12 +124,20 @@ export const loadAccountOverrides = async (
|
|
|
108
124
|
accountConfigId,
|
|
109
125
|
composeSettingName(ACCOUNT_OVERRIDE_NAMES.muted, accountId),
|
|
110
126
|
),
|
|
127
|
+
accountSetting.get(
|
|
128
|
+
accountConfigId,
|
|
129
|
+
composeSettingName(ACCOUNT_OVERRIDE_NAMES.composeLanguages, accountId),
|
|
130
|
+
),
|
|
111
131
|
]);
|
|
112
132
|
const overrides: AccountOverrides = {};
|
|
113
133
|
const displayNameValue = displayName ? stringValueOf(displayName) : undefined;
|
|
114
134
|
const mutedValue = muted ? mutedValueOf(muted) : undefined;
|
|
135
|
+
const languagesValue = composeLanguages
|
|
136
|
+
? stringListValueOf(composeLanguages)
|
|
137
|
+
: undefined;
|
|
115
138
|
if (displayNameValue !== undefined) overrides.displayName = displayNameValue;
|
|
116
139
|
if (mutedValue !== undefined) overrides.muted = mutedValue;
|
|
140
|
+
if (languagesValue !== undefined) overrides.composeLanguages = languagesValue;
|
|
117
141
|
return overrides;
|
|
118
142
|
};
|
|
119
143
|
|
|
@@ -129,6 +153,32 @@ export const upsertAccountDisplayName = (
|
|
|
129
153
|
value: { kind: "String", value: displayName },
|
|
130
154
|
});
|
|
131
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Replace the account's compose-language list. An empty array deletes the row:
|
|
158
|
+
* the client falls back to the browser's own languages when the setting is
|
|
159
|
+
* absent, and an account that offers no language at all has nothing to pick
|
|
160
|
+
* from (RFC 032: absence is "unset").
|
|
161
|
+
*/
|
|
162
|
+
export const writeAccountComposeLanguages = (
|
|
163
|
+
accountSetting: IAccountSettingRepository,
|
|
164
|
+
accountConfigId: string,
|
|
165
|
+
accountId: string,
|
|
166
|
+
languages: string[],
|
|
167
|
+
): Promise<unknown> => {
|
|
168
|
+
const name = composeSettingName(
|
|
169
|
+
ACCOUNT_OVERRIDE_NAMES.composeLanguages,
|
|
170
|
+
accountId,
|
|
171
|
+
);
|
|
172
|
+
if (languages.length === 0) {
|
|
173
|
+
return accountSetting.delete(accountConfigId, name);
|
|
174
|
+
}
|
|
175
|
+
return accountSetting.upsert({
|
|
176
|
+
accountConfigId,
|
|
177
|
+
name,
|
|
178
|
+
value: { kind: "StringList", value: languages },
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
132
182
|
/**
|
|
133
183
|
* Set or clear the account mute flag. A `MutedFlag` upserts the row; `null`
|
|
134
184
|
* deletes it (RFC 032: absence is "unset"). Mirrors the address-flag
|
package/src/handlers/account.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
import {
|
|
48
48
|
loadAccountOverrides,
|
|
49
49
|
upsertAccountDisplayName,
|
|
50
|
+
writeAccountComposeLanguages,
|
|
50
51
|
writeAccountMuted,
|
|
51
52
|
} from "./account-overrides.js";
|
|
52
53
|
import { assertAccountOwnership } from "./account-ownership.js";
|
|
@@ -443,6 +444,14 @@ export const AccountDetailOperations: Record<
|
|
|
443
444
|
input.displayName,
|
|
444
445
|
);
|
|
445
446
|
}
|
|
447
|
+
if (input.composeLanguages !== undefined) {
|
|
448
|
+
await writeAccountComposeLanguages(
|
|
449
|
+
accountSetting,
|
|
450
|
+
accountConfigId,
|
|
451
|
+
accountId,
|
|
452
|
+
input.composeLanguages,
|
|
453
|
+
);
|
|
454
|
+
}
|
|
446
455
|
if (Object.hasOwn(input, "muted")) {
|
|
447
456
|
if (input.muted !== undefined) {
|
|
448
457
|
await writeAccountMuted(
|