2026-06-03 11:15:59 +00:00
|
|
|
|
// Einstellungen lesen/schreiben (browser.storage.local).
|
2026-06-03 13:14:05 +00:00
|
|
|
|
// Wichtig: Das Passwort wird NICHT gespeichert. Es wird beim Login einmalig
|
|
|
|
|
|
// abgefragt, daraus ein OAuth-Token geholt und sofort verworfen (siehe auth.js
|
|
|
|
|
|
// + background.js). In storage.local liegen nur unkritische Daten.
|
2026-06-03 11:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
const DEFAULTS = {
|
|
|
|
|
|
serverUrl: "", // z.B. https://docuware.example.com (ohne /DocuWare/Platform)
|
|
|
|
|
|
organization: "",
|
|
|
|
|
|
username: "",
|
|
|
|
|
|
defaultCabinetId: "",
|
|
|
|
|
|
dialogByCabinet: {}, // gemerkter Ablagedialog je Schrank: { [cabinetId]: dialogId }
|
2026-06-16 11:23:39 +00:00
|
|
|
|
mailFormat: "eml", // E-Mail wird als "eml" ODER "pdf" abgelegt (nie beides)
|
2026-06-03 11:15:59 +00:00
|
|
|
|
storeAttachments: true,
|
|
|
|
|
|
tagOnSuccess: true,
|
2026-06-16 11:23:39 +00:00
|
|
|
|
fieldMapping: {}, // DocuWare-Feldname -> Mail-Attribut (Token). Leer = DEFAULT_FIELD_MAP.
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Mögliche Mail-Attribute für die Vorbefüllung (Token + Anzeigename).
|
|
|
|
|
|
// Wird von dialog.js (Werte aus meta) und options.js (Mapping-Editor) genutzt.
|
|
|
|
|
|
const MAIL_TOKENS = [
|
|
|
|
|
|
{ key: "senderEmail", label: "Absender – E-Mail" },
|
|
|
|
|
|
{ key: "senderName", label: "Absender – Name" },
|
|
|
|
|
|
{ key: "to", label: "Empfänger (An)" },
|
|
|
|
|
|
{ key: "cc", label: "CC" },
|
|
|
|
|
|
{ key: "bcc", label: "BCC" },
|
|
|
|
|
|
{ key: "subject", label: "Betreff" },
|
|
|
|
|
|
{ key: "body", label: "Text (Body)" },
|
|
|
|
|
|
{ key: "date", label: "Datum" },
|
|
|
|
|
|
{ key: "direction", label: "Richtung (Ein-/Ausgang)" },
|
|
|
|
|
|
{ key: "size", label: "Größe (Bytes)" },
|
|
|
|
|
|
{ key: "account", label: "Konto" },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// Standard-Zuordnung DocuWare-Feldname -> Mail-Token. Greift, solange der Nutzer
|
|
|
|
|
|
// in den Einstellungen kein eigenes fieldMapping gespeichert hat.
|
|
|
|
|
|
const DEFAULT_FIELD_MAP = {
|
|
|
|
|
|
EML_SENDER: "senderEmail",
|
|
|
|
|
|
EML_SENDER_DISPLAYNAME: "senderName",
|
|
|
|
|
|
EML_SENDER_NAME: "senderName",
|
|
|
|
|
|
EML_RECEIVER: "to",
|
|
|
|
|
|
EML_CC: "cc",
|
|
|
|
|
|
EML_BCC: "bcc",
|
|
|
|
|
|
EML_SUBJECT: "subject",
|
|
|
|
|
|
DOC_SUBJECT: "subject",
|
|
|
|
|
|
EML_BODY: "body",
|
|
|
|
|
|
EML_SENDINGDATE: "date",
|
|
|
|
|
|
EML_DISPLAYDATE: "date",
|
|
|
|
|
|
EML_RECEIVINGDATE: "date",
|
|
|
|
|
|
EML_DIRECTION: "direction",
|
|
|
|
|
|
EML_SIZE: "size",
|
|
|
|
|
|
EML_ACCOUNT: "account",
|
|
|
|
|
|
DOC_DATE: "date",
|
|
|
|
|
|
SUBJECT: "subject",
|
|
|
|
|
|
BETREFF: "subject",
|
|
|
|
|
|
EMAIL: "senderEmail",
|
|
|
|
|
|
E_MAIL: "senderEmail",
|
|
|
|
|
|
DATE: "date",
|
|
|
|
|
|
DATUM: "date",
|
2026-06-03 11:15:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const Settings = {
|
|
|
|
|
|
async get() {
|
|
|
|
|
|
const stored = await browser.storage.local.get("settings");
|
2026-06-16 11:23:39 +00:00
|
|
|
|
const raw = stored.settings || {};
|
|
|
|
|
|
const s = { ...DEFAULTS, ...raw };
|
|
|
|
|
|
// Migration: altes storeEml/storePdf -> mailFormat (einmalig, nicht persistiert).
|
|
|
|
|
|
if (raw.mailFormat === undefined && raw.storePdf && !raw.storeEml) {
|
|
|
|
|
|
s.mailFormat = "pdf";
|
|
|
|
|
|
}
|
|
|
|
|
|
return s;
|
2026-06-03 11:15:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
async set(partial) {
|
|
|
|
|
|
const current = await this.get();
|
|
|
|
|
|
const next = { ...current, ...partial };
|
2026-06-03 13:14:05 +00:00
|
|
|
|
// Sicherheitsnetz: Passwort darf NIE persistiert werden (z.B. aus Alt-Importen).
|
|
|
|
|
|
delete next.password;
|
2026-06-03 11:15:59 +00:00
|
|
|
|
await browser.storage.local.set({ settings: next });
|
|
|
|
|
|
return next;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/** Basis-URL der Platform-API ohne abschließenden Slash. */
|
|
|
|
|
|
platformUrl(settings) {
|
|
|
|
|
|
const base = (settings.serverUrl || "").replace(/\/+$/, "");
|
|
|
|
|
|
if (!base) throw new Error("Keine DocuWare-Server-URL konfiguriert.");
|
|
|
|
|
|
return `${base}/DocuWare/Platform`;
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-16 11:23:39 +00:00
|
|
|
|
if (typeof module !== "undefined")
|
|
|
|
|
|
module.exports = { Settings, DEFAULTS, MAIL_TOKENS, DEFAULT_FIELD_MAP };
|