Enable OpenPGP key servers on Android, add keys.eternityproject.fi, allow removing built-in servers
- Android: key-server lookup, publish, add/remove/enable via native HTTP - Built-in servers can be removed; keys.eternityproject.fi (VKS) added as a default - Fix Settings additions (Encryption keys, shortcuts) missing on Android due to async preferences - Fix compose footer so Send is visible on small screens - Bump version to 0.5.22 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
import { Capacitor, registerPlugin } from '@capacitor/core';
|
||||
import { Capacitor, CapacitorHttp, registerPlugin } from '@capacitor/core';
|
||||
import { createAndroidPgp } from './android-pgp.js';
|
||||
|
||||
const EpMail = registerPlugin('EpMail');
|
||||
|
||||
// Native HTTP avoids WebView CORS limits; redirects are refused like on desktop.
|
||||
async function nativeFetch(url, options = {}) {
|
||||
const headers = options.headers || {};
|
||||
const contentType = String(headers['content-type'] || '');
|
||||
let data = options.body;
|
||||
if (typeof data === 'string' && contentType.includes('json')) data = JSON.parse(data);
|
||||
else if (typeof data === 'string' && contentType.includes('x-www-form-urlencoded')) data = Object.fromEntries(new URLSearchParams(data));
|
||||
const response = await CapacitorHttp.request({ url: String(url), method: options.method || 'GET', headers, data,
|
||||
responseType: 'text', disableRedirects: true, connectTimeout: 15000, readTimeout: 15000 });
|
||||
const text = typeof response.data === 'string' ? response.data : JSON.stringify(response.data ?? '');
|
||||
const lowered = Object.fromEntries(Object.entries(response.headers || {}).map(([name, value]) => [name.toLowerCase(), value]));
|
||||
return { status: response.status, ok: response.status >= 200 && response.status < 300,
|
||||
headers: { get: name => lowered[String(name).toLowerCase()] ?? null }, body: [new TextEncoder().encode(text)] };
|
||||
}
|
||||
|
||||
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
||||
const daybreakMail = {
|
||||
platform: 'android',
|
||||
@@ -63,6 +78,6 @@ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
||||
davSaveContact: contact => EpMail.davSaveContact(contact),
|
||||
davDeleteContact: remote => EpMail.davDeleteContact(remote)
|
||||
};
|
||||
daybreakMail.pgp = createAndroidPgp({ EpMail, getAccount: () => EpMail.getAccount() });
|
||||
daybreakMail.pgp = createAndroidPgp({ EpMail, getAccount: () => EpMail.getAccount(), fetchImpl: nativeFetch });
|
||||
window.daybreakMail = daybreakMail;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user