Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0250743250 | ||
|
|
3d5eb5517f | ||
|
|
b9d46fde1e | ||
|
|
1f550dc5c3 | ||
|
|
3963778da1 |
@@ -6,9 +6,10 @@ Related: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md), [SECURITY_REVIEW.md](./SECU
|
|||||||
|
|
||||||
## Implementation progress (2026-11-03)
|
## Implementation progress (2026-11-03)
|
||||||
|
|
||||||
- Implemented: explicit Android cleartext denial and backup/data-extraction exclusions; removed the wildcard Cordova origin and unused broad `FileProvider`; DAV now requires HTTPS, rejects embedded credentials/fragments, stays on the configured origin, and does not follow redirects; saved attachment names are sanitized; notification previews and native logs no longer expose mailbox content; debug APKs are labeled as debug and signed release builds require environment-provided signing credentials.
|
- Implemented: explicit Android cleartext denial and backup/data-extraction exclusions; removed the wildcard Cordova origin and unused broad `FileProvider`; DAV now requires HTTPS, rejects embedded credentials/fragments, stays on the configured origin, and does not follow redirects; saved attachment names are sanitized; notification details are opt-in, stored in the encrypted vault, and redacted on the lock screen; native logs no longer expose mailbox content; debug APKs are labeled as debug and signed release builds require environment-provided signing credentials.
|
||||||
- Tested: DAV URL policy and attachment-name policy have Android unit tests. The debug Android build and unit tests pass, as does the Node test suite.
|
- Tested: DAV URL, attachment-name, and notification privacy policies have Android unit tests. The debug Android build and unit tests pass, as does the Node test suite.
|
||||||
- Still open: invalid-certificate integration tests, device-level review of the merged release APK, private notification preference UI, app lock/biometric unlock, full vault lifecycle testing, and Android OpenPGP. OpenPGP work remains gated on an independent cryptography/security review.
|
- Phase 2 preparation only: OpenPGP.js is pinned to the locked 6.3.2 version. `npm audit --omit=dev` reports three moderate advisories in `ip-address` and the `nodemailer`/`mailparser` dependency chain; those dependency updates are not applied here because the suggested mailparser update is outside the current declared range and needs separate compatibility review.
|
||||||
|
- Still open: invalid-certificate integration tests, device-level review of the merged release APK, app lock/biometric unlock, full vault lifecycle testing, and Android OpenPGP. OpenPGP work remains gated on an independent cryptography/security review.
|
||||||
|
|
||||||
## Goals and limits
|
## Goals and limits
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ npm install
|
|||||||
npm run android:apk
|
npm run android:apk
|
||||||
```
|
```
|
||||||
|
|
||||||
The debug APK is written to `android/app/build/outputs/apk/debug/app-debug.apk` and copied to `release/ep-mail <version>-debug.apk`; install it on a connected test device with `adb install -r android/app/build/outputs/apk/debug/app-debug.apk`. For a signed release, configure `EP_MAIL_ANDROID_STORE_FILE` (an absolute path), `EP_MAIL_ANDROID_STORE_PASSWORD`, `EP_MAIL_ANDROID_KEY_ALIAS`, and `EP_MAIL_ANDROID_KEY_PASSWORD` in the build environment, then run `npm run android:release-apk`. The signed artifact is copied to `release/ep-mail <version>.apk`; keep keystores and passwords out of the repository and logs. The first account enables a visible, ongoing foreground-service notification while IMAP IDLE checks for new mail; Android also runs a network-constrained periodic reconciliation. Notification previews contain generic text rather than mailbox addresses or message subjects. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management.
|
The debug APK is written to `android/app/build/outputs/apk/debug/app-debug.apk` and copied to `release/ep-mail <version>-debug.apk`; install it on a connected test device with `adb install -r android/app/build/outputs/apk/debug/app-debug.apk`. For a signed release, configure `EP_MAIL_ANDROID_STORE_FILE` (an absolute path), `EP_MAIL_ANDROID_STORE_PASSWORD`, `EP_MAIL_ANDROID_KEY_ALIAS`, and `EP_MAIL_ANDROID_KEY_PASSWORD` in the build environment, then run `npm run android:release-apk`. The signed artifact is copied to `release/ep-mail <version>.apk`; keep keystores and passwords out of the repository and logs. The first account enables a visible, ongoing foreground-service notification while IMAP IDLE checks for new mail; Android also runs a network-constrained periodic reconciliation. Notification sender/subject details are hidden by default; enabling them in Settings still keeps lock-screen previews redacted. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management.
|
||||||
|
|
||||||
## Run on Windows or Linux
|
## Run on Windows or Linux
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ Applied fixes:
|
|||||||
|
|
||||||
- Replacement-key and trust-elevation confirmation are enforced in `desktop/ipc/pgp.cjs`. `tests/pgp-ipc-registration.test.cjs` verifies both cancellation and confirmation paths for those changes.
|
- Replacement-key and trust-elevation confirmation are enforced in `desktop/ipc/pgp.cjs`. `tests/pgp-ipc-registration.test.cjs` verifies both cancellation and confirmation paths for those changes.
|
||||||
- Main-process plaintext-send confirmation is implemented in `desktop/ipc/mail.cjs`; direct regression coverage for that dialog's accept/cancel branches remains open.
|
- Main-process plaintext-send confirmation is implemented in `desktop/ipc/mail.cjs`; direct regression coverage for that dialog's accept/cancel branches remains open.
|
||||||
- Human cryptography/security review, dependency audit and OpenPGP.js version pinning remain outstanding. GnuPG interoperability tests are in the current test suite and should be rerun after dependency changes.
|
- Human cryptography/security review and dependency remediation remain outstanding. OpenPGP.js is pinned to 6.3.2; `npm audit --omit=dev` currently reports three moderate advisories in `ip-address` and the Nodemailer/mailparser dependency chain. GnuPG interoperability tests are in the current test suite and should be rerun after dependency changes.
|
||||||
- Android has no OpenPGP implementation and is outside the reviewed desktop scope.
|
- Android has no OpenPGP implementation and is outside the reviewed desktop scope.
|
||||||
|
|
||||||
## Third review pass (2026-10-17)
|
## Third review pass (2026-10-17)
|
||||||
|
|||||||
@@ -38,8 +38,11 @@
|
|||||||
- [x] Manual interoperability check with Thunderbird.
|
- [x] Manual interoperability check with Thunderbird.
|
||||||
- [x] Address findings from the automated OpenPGP security reviews (see [SECURITY_REVIEW.md](./SECURITY_REVIEW.md)).
|
- [x] Address findings from the automated OpenPGP security reviews (see [SECURITY_REVIEW.md](./SECURITY_REVIEW.md)).
|
||||||
- [ ] Complete an independent human security review of the encryption code before expanding OpenPGP support to Android.
|
- [ ] Complete an independent human security review of the encryption code before expanding OpenPGP support to Android.
|
||||||
|
- [x] Pin OpenPGP.js to the exact lockfile version while security review is pending.
|
||||||
|
- [ ] Resolve the current moderate dependency advisories reported by `npm audit --omit=dev` with compatibility tests.
|
||||||
- [ ] Add direct IPC-handler tests for both accept and cancel paths of the main-process plaintext-send confirmation.
|
- [ ] Add direct IPC-handler tests for both accept and cancel paths of the main-process plaintext-send confirmation.
|
||||||
- [ ] Complete the Android security work in [ANDROID_SECURITY_PLAN.md](./ANDROID_SECURITY_PLAN.md), including Android OpenPGP and release security checks.
|
- [ ] Complete the Android security work in [ANDROID_SECURITY_PLAN.md](./ANDROID_SECURITY_PLAN.md), including Android OpenPGP and release security checks.
|
||||||
|
- [x] Make Android notification details opt-in, persist the preference in the encrypted vault, and redact lock-screen previews.
|
||||||
|
|
||||||
## Appearance and settings
|
## Appearance and settings
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,16 @@ internal object AndroidAccountVault {
|
|||||||
|
|
||||||
fun accounts(): JSONArray = read().optJSONArray("accounts") ?: JSONArray()
|
fun accounts(): JSONArray = read().optJSONArray("accounts") ?: JSONArray()
|
||||||
|
|
||||||
|
fun notificationDetailsEnabled(): Boolean =
|
||||||
|
read().optBoolean("showNotificationDetails", NotificationPrivacyPolicy.DEFAULT_SHOW_DETAILS)
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun setNotificationDetailsEnabled(enabled: Boolean): Boolean {
|
||||||
|
val store = read().put("showNotificationDetails", enabled)
|
||||||
|
write(store)
|
||||||
|
return enabled
|
||||||
|
}
|
||||||
|
|
||||||
fun account(id: String? = null): JSONObject? {
|
fun account(id: String? = null): JSONObject? {
|
||||||
val store = read()
|
val store = read()
|
||||||
val accounts = store.optJSONArray("accounts") ?: return null
|
val accounts = store.optJSONArray("accounts") ?: return null
|
||||||
@@ -432,6 +442,10 @@ internal object AndroidAccountVault {
|
|||||||
.put("displayName", account.optString("displayName"))
|
.put("displayName", account.optString("displayName"))
|
||||||
.put("imapHost", account.optString("imapHost"))
|
.put("imapHost", account.optString("imapHost"))
|
||||||
.put("smtpHost", account.optString("smtpHost"))
|
.put("smtpHost", account.optString("smtpHost"))
|
||||||
|
.put("imapPort", account.optInt("imapPort", 143))
|
||||||
|
.put("smtpPort", account.optInt("smtpPort", 587))
|
||||||
|
.put("imapSecure", account.optBoolean("imapSecure", false))
|
||||||
|
.put("smtpSecure", account.optBoolean("smtpSecure", false))
|
||||||
.put("signature", account.optString("signature"))
|
.put("signature", account.optString("signature"))
|
||||||
.put("notificationsEnabled", account.optBoolean("notificationsEnabled", true))
|
.put("notificationsEnabled", account.optBoolean("notificationsEnabled", true))
|
||||||
.put("syncIntervalMinutes", account.optInt("syncIntervalMinutes", 2))
|
.put("syncIntervalMinutes", account.optInt("syncIntervalMinutes", 2))
|
||||||
|
|||||||
@@ -491,14 +491,15 @@ internal object AndroidMailService {
|
|||||||
shouldStop: () -> Boolean,
|
shouldStop: () -> Boolean,
|
||||||
onConnection: (Store?, Folder?) -> Unit
|
onConnection: (Store?, Folder?) -> Unit
|
||||||
) {
|
) {
|
||||||
|
val protocol = imapProtocol(account)
|
||||||
val props = imapProperties(account).apply {
|
val props = imapProperties(account).apply {
|
||||||
setProperty("mail.imap.timeout", "0")
|
setProperty("mail.$protocol.timeout", "0")
|
||||||
setProperty("mail.imap.writetimeout", "60000")
|
setProperty("mail.$protocol.writetimeout", "60000")
|
||||||
}
|
}
|
||||||
val pollingIntervalMs = account.optInt("syncIntervalMinutes", 2)
|
val pollingIntervalMs = account.optInt("syncIntervalMinutes", 2)
|
||||||
.coerceIn(2, 60) * 60_000L
|
.coerceIn(2, 60) * 60_000L
|
||||||
val session = Session.getInstance(props, credentials(account))
|
val session = Session.getInstance(props, credentials(account))
|
||||||
val store = session.getStore("imap")
|
val store = session.getStore(protocol)
|
||||||
try {
|
try {
|
||||||
store.connect(
|
store.connect(
|
||||||
account.optString("imapHost"),
|
account.optString("imapHost"),
|
||||||
@@ -784,7 +785,7 @@ internal object AndroidMailService {
|
|||||||
|
|
||||||
private fun <T> withStore(account: JSONObject, block: (Session, Store) -> T): T {
|
private fun <T> withStore(account: JSONObject, block: (Session, Store) -> T): T {
|
||||||
val session = Session.getInstance(imapProperties(account), credentials(account))
|
val session = Session.getInstance(imapProperties(account), credentials(account))
|
||||||
val store = session.getStore("imap")
|
val store = session.getStore(imapProtocol(account))
|
||||||
try {
|
try {
|
||||||
store.connect(
|
store.connect(
|
||||||
account.optString("imapHost"),
|
account.optString("imapHost"),
|
||||||
@@ -806,29 +807,20 @@ internal object AndroidMailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun imapProperties(account: JSONObject) = Properties().apply {
|
private fun imapProperties(account: JSONObject) = Properties().apply {
|
||||||
setProperty("mail.store.protocol", "imap")
|
putAll(AndroidMailTransport.imapProperties(MailServerConnection(
|
||||||
setProperty("mail.imap.host", account.optString("imapHost"))
|
account.optString("imapHost"),
|
||||||
setProperty("mail.imap.port", account.optInt("imapPort", 143).toString())
|
account.optInt("imapPort", 143),
|
||||||
setProperty("mail.imap.auth", "true")
|
account.optBoolean("imapSecure", false)
|
||||||
setProperty("mail.imap.starttls.enable", "true")
|
)))
|
||||||
setProperty("mail.imap.starttls.required", "true")
|
|
||||||
setProperty("mail.imap.ssl.checkserveridentity", "true")
|
|
||||||
setProperty("mail.imap.connectiontimeout", "20000")
|
|
||||||
setProperty("mail.imap.timeout", "30000")
|
|
||||||
setProperty("mail.imap.writetimeout", "30000")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun smtpProperties(account: JSONObject) = Properties().apply {
|
private fun imapProtocol(account: JSONObject) = if (account.optBoolean("imapSecure", false)) "imaps" else "imap"
|
||||||
setProperty("mail.smtp.host", account.optString("smtpHost"))
|
|
||||||
setProperty("mail.smtp.port", account.optInt("smtpPort", 587).toString())
|
private fun smtpProperties(account: JSONObject) = AndroidMailTransport.smtpProperties(MailServerConnection(
|
||||||
setProperty("mail.smtp.auth", "true")
|
account.optString("smtpHost"),
|
||||||
setProperty("mail.smtp.starttls.enable", "true")
|
account.optInt("smtpPort", 587),
|
||||||
setProperty("mail.smtp.starttls.required", "true")
|
account.optBoolean("smtpSecure", false)
|
||||||
setProperty("mail.smtp.ssl.checkserveridentity", "true")
|
))
|
||||||
setProperty("mail.smtp.connectiontimeout", "20000")
|
|
||||||
setProperty("mail.smtp.timeout", "30000")
|
|
||||||
setProperty("mail.smtp.writetimeout", "30000")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun displayName(account: JSONObject) =
|
private fun displayName(account: JSONObject) =
|
||||||
account.optString("displayName").replace(Regex("[\\r\\n]"), " ").take(80)
|
account.optString("displayName").replace(Regex("[\\r\\n]"), " ").take(80)
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
|
internal data class MailServerConnection(
|
||||||
|
val host: String,
|
||||||
|
val port: Int,
|
||||||
|
val secure: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
internal object AndroidMailTransport {
|
||||||
|
fun imapProperties(server: MailServerConnection): Properties = Properties().apply {
|
||||||
|
val protocol = if (server.secure) "imaps" else "imap"
|
||||||
|
setProperty("mail.store.protocol", protocol)
|
||||||
|
setProperty("mail.$protocol.host", server.host)
|
||||||
|
setProperty("mail.$protocol.port", server.port.toString())
|
||||||
|
setProperty("mail.$protocol.auth", "true")
|
||||||
|
setProperty("mail.$protocol.ssl.checkserveridentity", "true")
|
||||||
|
if (server.secure) {
|
||||||
|
setProperty("mail.$protocol.ssl.enable", "true")
|
||||||
|
} else {
|
||||||
|
setProperty("mail.$protocol.starttls.enable", "true")
|
||||||
|
setProperty("mail.$protocol.starttls.required", "true")
|
||||||
|
}
|
||||||
|
setProperty("mail.$protocol.connectiontimeout", "20000")
|
||||||
|
setProperty("mail.$protocol.timeout", "30000")
|
||||||
|
setProperty("mail.$protocol.writetimeout", "30000")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun smtpProperties(server: MailServerConnection): Properties = Properties().apply {
|
||||||
|
setProperty("mail.smtp.host", server.host)
|
||||||
|
setProperty("mail.smtp.port", server.port.toString())
|
||||||
|
setProperty("mail.smtp.auth", "true")
|
||||||
|
setProperty("mail.smtp.ssl.checkserveridentity", "true")
|
||||||
|
if (server.secure) {
|
||||||
|
setProperty("mail.smtp.ssl.enable", "true")
|
||||||
|
} else {
|
||||||
|
setProperty("mail.smtp.starttls.enable", "true")
|
||||||
|
setProperty("mail.smtp.starttls.required", "true")
|
||||||
|
}
|
||||||
|
setProperty("mail.smtp.connectiontimeout", "20000")
|
||||||
|
setProperty("mail.smtp.timeout", "30000")
|
||||||
|
setProperty("mail.smtp.writetimeout", "30000")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,6 +56,27 @@ class EpMailPlugin : Plugin() {
|
|||||||
call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME))
|
call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PluginMethod
|
||||||
|
fun getNotificationPrivacy(call: PluginCall) {
|
||||||
|
try {
|
||||||
|
call.resolve(JSObject().put("showDetails", AndroidAccountVault.notificationDetailsEnabled()))
|
||||||
|
} catch (error: Exception) {
|
||||||
|
call.reject(error.message ?: "Could not read notification privacy settings.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PluginMethod
|
||||||
|
fun setNotificationDetails(call: PluginCall) {
|
||||||
|
try {
|
||||||
|
val enabled = call.getBoolean("enabled")
|
||||||
|
?: throw IllegalArgumentException("Choose whether notifications may show details.")
|
||||||
|
AndroidAccountVault.setNotificationDetailsEnabled(enabled)
|
||||||
|
call.resolve(JSObject().put("showDetails", enabled))
|
||||||
|
} catch (error: Exception) {
|
||||||
|
call.reject(error.message ?: "Could not save notification privacy settings.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
fun getAccount(call: PluginCall) {
|
fun getAccount(call: PluginCall) {
|
||||||
val account = AndroidAccountVault.account()
|
val account = AndroidAccountVault.account()
|
||||||
@@ -458,9 +479,14 @@ class EpMailPlugin : Plugin() {
|
|||||||
val displayName = input.optString("displayName").trim().take(80)
|
val displayName = input.optString("displayName").trim().take(80)
|
||||||
val imapHost = input.optString("imapHost").trim()
|
val imapHost = input.optString("imapHost").trim()
|
||||||
val smtpHost = input.optString("smtpHost").trim()
|
val smtpHost = input.optString("smtpHost").trim()
|
||||||
|
val imapPort = input.optInt("imapPort", 143)
|
||||||
|
val smtpPort = input.optInt("smtpPort", 587)
|
||||||
require(EMAIL.matches(email) && password.isNotBlank() && displayName.isNotBlank() && imapHost.isNotBlank() && smtpHost.isNotBlank()) {
|
require(EMAIL.matches(email) && password.isNotBlank() && displayName.isNotBlank() && imapHost.isNotBlank() && smtpHost.isNotBlank()) {
|
||||||
"Enter a valid email, account display name, password, and both mail server names."
|
"Enter a valid email, account display name, password, and both mail server names."
|
||||||
}
|
}
|
||||||
|
require(imapPort in 1..65535 && smtpPort in 1..65535) {
|
||||||
|
"Enter valid IMAP and SMTP ports (1–65535)."
|
||||||
|
}
|
||||||
return JSONObject()
|
return JSONObject()
|
||||||
.put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() })
|
.put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() })
|
||||||
.put("email", email)
|
.put("email", email)
|
||||||
@@ -474,8 +500,10 @@ class EpMailPlugin : Plugin() {
|
|||||||
require(it in setOf(2, 5, 15, 30, 60)) { "Choose a supported mailbox sync interval." }
|
require(it in setOf(2, 5, 15, 30, 60)) { "Choose a supported mailbox sync interval." }
|
||||||
})
|
})
|
||||||
.put("rules", normalizeRules(input.optJSONArray("rules")))
|
.put("rules", normalizeRules(input.optJSONArray("rules")))
|
||||||
.put("imapPort", input.optInt("imapPort", 143))
|
.put("imapPort", imapPort)
|
||||||
.put("smtpPort", input.optInt("smtpPort", 587))
|
.put("smtpPort", smtpPort)
|
||||||
|
.put("imapSecure", input.optBoolean("imapSecure", false))
|
||||||
|
.put("smtpSecure", input.optBoolean("smtpSecure", false))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun normalizeRules(input: JSONArray?): JSONArray {
|
private fun normalizeRules(input: JSONArray?): JSONArray {
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class MailIdleService : Service() {
|
|||||||
.setContentIntent(appPendingIntent())
|
.setContentIntent(appPendingIntent())
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun appPendingIntent(): PendingIntent {
|
private fun appPendingIntent(): PendingIntent {
|
||||||
@@ -219,13 +220,20 @@ class MailIdleService : Service() {
|
|||||||
appContext, 0, launchIntent,
|
appContext, 0, launchIntent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
)
|
||||||
val title = if (count == 1) "New mail" else "$count new messages"
|
val showDetails = runCatching { AndroidAccountVault.notificationDetailsEnabled() }.getOrDefault(false)
|
||||||
val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
||||||
.setContentTitle(title)
|
.setContentTitle("New mail")
|
||||||
.setContentText("Open ep-mail to check your inbox")
|
.setContentText(NotificationPrivacyPolicy.newMailText(showDetails, email, count))
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
|
.setPublicVersion(NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
||||||
|
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
||||||
|
.setContentTitle("ep-mail")
|
||||||
|
.setContentText("New mail")
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
.build())
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.build()
|
.build()
|
||||||
try {
|
try {
|
||||||
@@ -256,12 +264,20 @@ class MailIdleService : Service() {
|
|||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
val showDetails = runCatching { AndroidAccountVault.notificationDetailsEnabled() }.getOrDefault(false)
|
||||||
val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
||||||
.setContentTitle("Mail reminder")
|
.setContentTitle("Mail reminder")
|
||||||
.setContentText("A snoozed message is due")
|
.setContentText(NotificationPrivacyPolicy.reminderText(showDetails, reminder.optString("subject")))
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
|
.setPublicVersion(NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID)
|
||||||
|
.setSmallIcon(android.R.drawable.ic_dialog_email)
|
||||||
|
.setContentTitle("ep-mail")
|
||||||
|
.setContentText("A mail reminder is due")
|
||||||
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
.build())
|
||||||
.setContentIntent(appPendingIntentFor(appContext))
|
.setContentIntent(appPendingIntentFor(appContext))
|
||||||
.build()
|
.build()
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import com.getcapacitor.BridgeActivity;
|
|||||||
public class MainActivity extends BridgeActivity {
|
public class MainActivity extends BridgeActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
registerPlugin(EpMailPlugin.class);
|
registerPlugin(EpMailPlugin.class);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
if (Build.VERSION.SDK_INT >= 33 && checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
if (Build.VERSION.SDK_INT >= 33 && checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.POST_NOTIFICATIONS }, 701);
|
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.POST_NOTIFICATIONS }, 701);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
internal object NotificationPrivacyPolicy {
|
||||||
|
const val DEFAULT_SHOW_DETAILS = false
|
||||||
|
|
||||||
|
fun newMailText(showDetails: Boolean, email: String, count: Int): String =
|
||||||
|
if (showDetails) {
|
||||||
|
if (count == 1) email else "$count new messages · $email"
|
||||||
|
} else {
|
||||||
|
"Open ep-mail to check your inbox"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reminderText(showDetails: Boolean, subject: String): String =
|
||||||
|
if (showDetails && subject.isNotBlank()) subject else "A snoozed message is due"
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class AndroidMailTransportTest {
|
||||||
|
@Test
|
||||||
|
fun imapUsesRequiredStarttlsWhenImplicitTlsIsOff() {
|
||||||
|
val properties = AndroidMailTransport.imapProperties(
|
||||||
|
MailServerConnection("imap.example.test", 143, false)
|
||||||
|
)
|
||||||
|
assertEquals("imap", properties.getProperty("mail.store.protocol"))
|
||||||
|
assertEquals("true", properties.getProperty("mail.imap.starttls.enable"))
|
||||||
|
assertEquals("true", properties.getProperty("mail.imap.starttls.required"))
|
||||||
|
assertEquals("true", properties.getProperty("mail.imap.ssl.checkserveridentity"))
|
||||||
|
assertNull(properties.getProperty("mail.imap.ssl.enable"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun imapUsesImplicitTlsForSecurePort() {
|
||||||
|
val properties = AndroidMailTransport.imapProperties(
|
||||||
|
MailServerConnection("imap.example.test", 993, true)
|
||||||
|
)
|
||||||
|
assertEquals("imaps", properties.getProperty("mail.store.protocol"))
|
||||||
|
assertEquals("true", properties.getProperty("mail.imaps.ssl.enable"))
|
||||||
|
assertEquals("true", properties.getProperty("mail.imaps.ssl.checkserveridentity"))
|
||||||
|
assertNull(properties.getProperty("mail.imaps.starttls.required"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun smtpSupportsStarttlsAndImplicitTlsWithoutDowngrade() {
|
||||||
|
val startTls = AndroidMailTransport.smtpProperties(
|
||||||
|
MailServerConnection("smtp.example.test", 587, false)
|
||||||
|
)
|
||||||
|
assertEquals("true", startTls.getProperty("mail.smtp.starttls.enable"))
|
||||||
|
assertEquals("true", startTls.getProperty("mail.smtp.starttls.required"))
|
||||||
|
|
||||||
|
val implicitTls = AndroidMailTransport.smtpProperties(
|
||||||
|
MailServerConnection("smtp.example.test", 465, true)
|
||||||
|
)
|
||||||
|
assertEquals("true", implicitTls.getProperty("mail.smtp.ssl.enable"))
|
||||||
|
assertEquals("true", implicitTls.getProperty("mail.smtp.ssl.checkserveridentity"))
|
||||||
|
assertNull(implicitTls.getProperty("mail.smtp.starttls.required"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class NotificationPrivacyPolicyTest {
|
||||||
|
@Test
|
||||||
|
fun notificationDetailsAreDisabledByDefault() {
|
||||||
|
assertFalse(NotificationPrivacyPolicy.DEFAULT_SHOW_DETAILS)
|
||||||
|
assertEquals(
|
||||||
|
"Open ep-mail to check your inbox",
|
||||||
|
NotificationPrivacyPolicy.newMailText(NotificationPrivacyPolicy.DEFAULT_SHOW_DETAILS, "person@example.test", 1)
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
"A snoozed message is due",
|
||||||
|
NotificationPrivacyPolicy.reminderText(NotificationPrivacyPolicy.DEFAULT_SHOW_DETAILS, "Private subject")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun detailsAppearOnlyAfterExplicitOptIn() {
|
||||||
|
assertEquals("person@example.test", NotificationPrivacyPolicy.newMailText(true, "person@example.test", 1))
|
||||||
|
assertEquals(
|
||||||
|
"3 new messages · person@example.test",
|
||||||
|
NotificationPrivacyPolicy.newMailText(true, "person@example.test", 3)
|
||||||
|
)
|
||||||
|
assertEquals("Private subject", NotificationPrivacyPolicy.reminderText(true, "Private subject"))
|
||||||
|
assertEquals("A snoozed message is due", NotificationPrivacyPolicy.reminderText(true, " "))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,11 +4,12 @@ const state = window.epMailState;
|
|||||||
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
||||||
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
||||||
const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity;
|
const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity;
|
||||||
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length){document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader()}}
|
||||||
function openMessage(id){
|
function openMessage(id){
|
||||||
state.activeMessage=id;
|
state.activeMessage=id;
|
||||||
const m=state.messages.find(x=>x.id===id);
|
const m=state.messages.find(x=>x.id===id);
|
||||||
if(!m)return;
|
if(!m){state.activeMessage=null;document.body.classList.remove('reader-open');return;}
|
||||||
|
document.body.classList.add('reader-open');
|
||||||
m.unread=false;
|
m.unread=false;
|
||||||
renderList();
|
renderList();
|
||||||
let safeHtml={html:'',remoteImageCount:0};
|
let safeHtml={html:'',remoteImageCount:0};
|
||||||
@@ -16,7 +17,8 @@ function openMessage(id){
|
|||||||
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
||||||
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
||||||
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
||||||
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><button class="reader-back" id="reader-back" type="button" aria-label="Back to messages">Back</button><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
||||||
|
$('#reader-back').onclick=()=>{state.activeMessage=null;document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader();renderList()};
|
||||||
$('#load-remote-images')?.addEventListener('click',()=>{
|
$('#load-remote-images')?.addEventListener('click',()=>{
|
||||||
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
||||||
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
||||||
@@ -25,8 +27,8 @@ function openMessage(id){
|
|||||||
});
|
});
|
||||||
$('.remote-image-notice')?.remove();
|
$('.remote-image-notice')?.remove();
|
||||||
});
|
});
|
||||||
$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
$('#reader-archive').onclick=()=>{m.archived=true;state.activeMessage=null;document.body.classList.remove('reader-open');toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
$('#reader-delete').onclick=()=>{m.deleted=true;state.activeMessage=null;document.body.classList.remove('reader-open');toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
||||||
$('#reply').onclick=()=>showCompose(m);
|
$('#reply').onclick=()=>showCompose(m);
|
||||||
$('#forward').onclick=()=>showCompose(m,true);
|
$('#forward').onclick=()=>showCompose(m,true);
|
||||||
@@ -35,7 +37,7 @@ function emptyReader(){return `<div class="reader-empty"><div><div class="empty-
|
|||||||
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
||||||
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
||||||
function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();}
|
function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();}
|
||||||
$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage);
|
$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;state.activeMessage=null;document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader();$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{document.body.classList.remove('reader-open');switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage);
|
||||||
|
|
||||||
window.epMailShell = Object.freeze({
|
window.epMailShell = Object.freeze({
|
||||||
state,
|
state,
|
||||||
|
|||||||
+24
-2
@@ -228,7 +228,7 @@ function openMailAccount(existingAccount = null) {
|
|||||||
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${escapeMailUi(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${escapeMailUi(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
||||||
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${editing ? 'Edit mailbox' : 'Add a mailbox'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Your password is encrypted with this computer's credential storage. Connections require TLS.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="${escapeMailUi(existingAccount?.email || '')}" placeholder="name@example.com"></label><label class="compose-line"><span>Account display name</span><input id="mail-account-display-name" maxlength="80" autocomplete="name" value="${escapeMailUi(displayName)}" placeholder="Your name" required></label><label class="compose-line"><span>Password</span><input id="mail-account-password" type="password" autocomplete="${editing ? 'new-password' : 'current-password'}" placeholder="${editing ? 'Leave blank to keep current password' : 'Enter mailbox password'}"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="${escapeMailUi(existingAccount?.imapHost || '')}" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="${escapeMailUi(existingAccount?.smtpHost || '')}" autocomplete="off" placeholder="smtp.example.com"></label><label class="compose-line"><span>Sync interval</span><select id="mail-account-sync-interval" class="settings-select">${[2,5,15,30,60].map(minutes=>`<option value="${minutes}"${Number(existingAccount?.syncIntervalMinutes||2)===minutes?' selected':''}>Every ${minutes} minutes</option>`).join('')}</select></label><label class="compose-line"><span>New-mail notifications</span><input id="mail-account-notifications" type="checkbox"${existingAccount?.notificationsEnabled!==false?' checked':''}></label><label class="compose-line" style="display:block;padding:8px 0"><span>Signature</span><textarea id="mail-account-signature" maxlength="5000" rows="3" placeholder="Add a signature for this mailbox" style="display:block;box-sizing:border-box;width:100%;margin-top:7px">${escapeMailUi(existingAccount?.signature || '')}</textarea></label><section class="mail-rules"><div class="section-label"><span>MAIL RULES</span><button type="button" class="tiny-plus" id="add-mail-rule" aria-label="Add mail rule">+</button></div><p class="account-note">Rules match the sender or subject of incoming mail. The first matching rule runs.</p><div id="mail-rule-list">${ruleMarkup}</div></section><p class="account-note">Signatures are appended to outgoing messages. Sync interval controls periodic checks when IMAP IDLE is unavailable; Android may apply its 15-minute minimum background interval.${editing ? ' Leave the password empty to keep the saved password.' : ''}</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">${editing ? 'Save & reconnect' : 'Test & connect'}</button></div></div></div>`;
|
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${editing ? 'Edit mailbox' : 'Add a mailbox'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Credentials are stored encrypted. Choose the server's advertised TLS mode and ports.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="${escapeMailUi(existingAccount?.email || '')}" placeholder="name@example.com"></label><label class="compose-line"><span>Account display name</span><input id="mail-account-display-name" maxlength="80" autocomplete="name" value="${escapeMailUi(displayName)}" placeholder="Your name" required></label><label class="compose-line"><span>Password / app password</span><input id="mail-account-password" type="password" autocomplete="${editing ? 'new-password' : 'current-password'}" placeholder="${editing ? 'Leave blank to keep current password' : 'Enter mailbox password'}"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="${escapeMailUi(existingAccount?.imapHost || '')}" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>IMAP port</span><input id="mail-account-imap-port" type="number" inputmode="numeric" min="1" max="65535" value="${existingAccount?.imapPort || (existingAccount?.authMethod === 'oauth2' ? 993 : 143)}"></label><label class="compose-line mail-security-option"><span>IMAP implicit SSL/TLS (usually port 993)</span><input id="mail-account-imap-secure" type="checkbox"${existingAccount?.imapSecure ? ' checked' : ''}></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="${escapeMailUi(existingAccount?.smtpHost || '')}" autocomplete="off" placeholder="smtp.example.com"></label><label class="compose-line"><span>SMTP port</span><input id="mail-account-smtp-port" type="number" inputmode="numeric" min="1" max="65535" value="${existingAccount?.smtpPort || 587}"></label><label class="compose-line mail-security-option"><span>SMTP implicit SSL/TLS (usually port 465)</span><input id="mail-account-smtp-secure" type="checkbox"${existingAccount?.smtpSecure ? ' checked' : ''}></label><p class="account-note">For IMAP port 143 and SMTP port 587, leave implicit SSL/TLS off to use required STARTTLS. Common Gmail settings are IMAP SSL/TLS on port 993 and SMTP STARTTLS on port 587; use an app password if required by your provider.</p><label class="compose-line"><span>Sync interval</span><select id="mail-account-sync-interval" class="settings-select">${[2,5,15,30,60].map(minutes=>`<option value="${minutes}"${Number(existingAccount?.syncIntervalMinutes||2)===minutes?' selected':''}>Every ${minutes} minutes</option>`).join('')}</select></label><label class="compose-line"><span>New-mail notifications</span><input id="mail-account-notifications" type="checkbox"${existingAccount?.notificationsEnabled!==false?' checked':''}></label><label class="compose-line" style="display:block;padding:8px 0"><span>Signature</span><textarea id="mail-account-signature" maxlength="5000" rows="3" placeholder="Add a signature for this mailbox" style="display:block;box-sizing:border-box;width:100%;margin-top:7px">${escapeMailUi(existingAccount?.signature || '')}</textarea></label><section class="mail-rules"><div class="section-label"><span>MAIL RULES</span><button type="button" class="tiny-plus" id="add-mail-rule" aria-label="Add mail rule">+</button></div><p class="account-note">Rules match the sender or subject of incoming mail. The first matching rule runs.</p><div id="mail-rule-list">${ruleMarkup}</div></section><p class="account-note">Signatures are appended to outgoing messages. Sync interval controls periodic checks when IMAP IDLE is unavailable; Android may apply its 15-minute minimum background interval.${editing ? ' Leave the password empty to keep the saved password.' : ''}</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">${editing ? 'Save & reconnect' : 'Test & connect'}</button></div></div></div>`;
|
||||||
const authMethodRow = document.createElement('label');
|
const authMethodRow = document.createElement('label');
|
||||||
authMethodRow.className = 'compose-line';
|
authMethodRow.className = 'compose-line';
|
||||||
authMethodRow.innerHTML = '<span>Sign-in method</span><select id="mail-account-auth-method" class="settings-select"><option value="password">App password</option><option value="oauth2">OAuth2</option></select>';
|
authMethodRow.innerHTML = '<span>Sign-in method</span><select id="mail-account-auth-method" class="settings-select"><option value="password">App password</option><option value="oauth2">OAuth2</option></select>';
|
||||||
@@ -249,7 +249,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
if (oauthMethodOption) oauthMethodOption.disabled = existingAccount?.authMethod !== 'oauth2';
|
if (oauthMethodOption) oauthMethodOption.disabled = existingAccount?.authMethod !== 'oauth2';
|
||||||
const passwordRow = selectMailUi('#mail-account-password').closest('.compose-line');
|
const passwordRow = selectMailUi('#mail-account-password').closest('.compose-line');
|
||||||
const imapRow = selectMailUi('#mail-account-imap').closest('.compose-line');
|
const imapRow = selectMailUi('#mail-account-imap').closest('.compose-line');
|
||||||
|
const imapPortRow = selectMailUi('#mail-account-imap-port').closest('.compose-line');
|
||||||
|
const imapSecureRow = selectMailUi('#mail-account-imap-secure').closest('.compose-line');
|
||||||
const smtpRow = selectMailUi('#mail-account-smtp').closest('.compose-line');
|
const smtpRow = selectMailUi('#mail-account-smtp').closest('.compose-line');
|
||||||
|
const smtpPortRow = selectMailUi('#mail-account-smtp-port').closest('.compose-line');
|
||||||
|
const smtpSecureRow = selectMailUi('#mail-account-smtp-secure').closest('.compose-line');
|
||||||
const authNote = selectMailUi('#modal-root .compose-fields > .account-note');
|
const authNote = selectMailUi('#modal-root .compose-fields > .account-note');
|
||||||
authMethodSelect.value = existingAccount?.authMethod === 'oauth2' ? 'oauth2' : 'password';
|
authMethodSelect.value = existingAccount?.authMethod === 'oauth2' ? 'oauth2' : 'password';
|
||||||
if (existingAccount?.oauthProvider) oauthProviderSelect.value = existingAccount.oauthProvider;
|
if (existingAccount?.oauthProvider) oauthProviderSelect.value = existingAccount.oauthProvider;
|
||||||
@@ -258,7 +262,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
? { imap: 'imap.gmail.com', smtp: 'smtp.gmail.com' }
|
? { imap: 'imap.gmail.com', smtp: 'smtp.gmail.com' }
|
||||||
: { imap: 'outlook.office365.com', smtp: 'smtp.office365.com' };
|
: { imap: 'outlook.office365.com', smtp: 'smtp.office365.com' };
|
||||||
selectMailUi('#mail-account-imap').value = servers.imap;
|
selectMailUi('#mail-account-imap').value = servers.imap;
|
||||||
|
selectMailUi('#mail-account-imap-port').value = '993';
|
||||||
|
selectMailUi('#mail-account-imap-secure').checked = true;
|
||||||
selectMailUi('#mail-account-smtp').value = servers.smtp;
|
selectMailUi('#mail-account-smtp').value = servers.smtp;
|
||||||
|
selectMailUi('#mail-account-smtp-port').value = '587';
|
||||||
|
selectMailUi('#mail-account-smtp-secure').checked = false;
|
||||||
};
|
};
|
||||||
const updateAuthFields = () => {
|
const updateAuthFields = () => {
|
||||||
const oauth = authMethodSelect.value === 'oauth2';
|
const oauth = authMethodSelect.value === 'oauth2';
|
||||||
@@ -267,12 +275,16 @@ function openMailAccount(existingAccount = null) {
|
|||||||
reauthorizeRow.hidden = !oauth || !editing;
|
reauthorizeRow.hidden = !oauth || !editing;
|
||||||
passwordRow.hidden = oauth;
|
passwordRow.hidden = oauth;
|
||||||
imapRow.hidden = oauth;
|
imapRow.hidden = oauth;
|
||||||
|
imapPortRow.hidden = oauth;
|
||||||
|
imapSecureRow.hidden = oauth;
|
||||||
smtpRow.hidden = oauth;
|
smtpRow.hidden = oauth;
|
||||||
|
smtpPortRow.hidden = oauth;
|
||||||
|
smtpSecureRow.hidden = oauth;
|
||||||
authNote.textContent = oauth
|
authNote.textContent = oauth
|
||||||
? 'Sign in in your browser. Configure the provider client ID in the desktop environment; OAuth refresh tokens are stored in encrypted credential storage.'
|
? 'Sign in in your browser. Configure the provider client ID in the desktop environment; OAuth refresh tokens are stored in encrypted credential storage.'
|
||||||
: configuredOAuthProviders && configuredOAuthProviders.size === 0
|
: configuredOAuthProviders && configuredOAuthProviders.size === 0
|
||||||
? 'Password sign-in is available. To enable OAuth2, configure EP_MAIL_GOOGLE_OAUTH_CLIENT_ID and/or EP_MAIL_MICROSOFT_OAUTH_CLIENT_ID, then restart ep-mail.'
|
? 'Password sign-in is available. To enable OAuth2, configure EP_MAIL_GOOGLE_OAUTH_CLIENT_ID and/or EP_MAIL_MICROSOFT_OAUTH_CLIENT_ID, then restart ep-mail.'
|
||||||
: 'Your password is encrypted with this computer\'s credential storage. Connections require TLS.';
|
: 'Credentials are stored encrypted. Connections require verified TLS.';
|
||||||
selectMailUi('#mail-account-password').placeholder = editing && existingAccount?.authMethod !== 'oauth2'
|
selectMailUi('#mail-account-password').placeholder = editing && existingAccount?.authMethod !== 'oauth2'
|
||||||
? 'Leave blank to keep current password' : 'Enter mailbox password';
|
? 'Leave blank to keep current password' : 'Enter mailbox password';
|
||||||
};
|
};
|
||||||
@@ -332,6 +344,12 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const name = selectMailUi('#mail-account-display-name').value.trim();
|
const name = selectMailUi('#mail-account-display-name').value.trim();
|
||||||
if (!name) { status.textContent = 'Enter a display name for this mail account.'; selectMailUi('#mail-account-display-name').focus(); return; }
|
if (!name) { status.textContent = 'Enter a display name for this mail account.'; selectMailUi('#mail-account-display-name').focus(); return; }
|
||||||
if (authMethod === 'password' && !password && (!editing || existingAccount?.authMethod === 'oauth2')) { status.textContent = 'Enter the mailbox password to connect.'; selectMailUi('#mail-account-password').focus(); return; }
|
if (authMethod === 'password' && !password && (!editing || existingAccount?.authMethod === 'oauth2')) { status.textContent = 'Enter the mailbox password to connect.'; selectMailUi('#mail-account-password').focus(); return; }
|
||||||
|
const imapPort = Number(selectMailUi('#mail-account-imap-port').value);
|
||||||
|
const smtpPort = Number(selectMailUi('#mail-account-smtp-port').value);
|
||||||
|
if (authMethod === 'password' && (![imapPort, smtpPort].every(port => Number.isInteger(port) && port >= 1 && port <= 65535))) {
|
||||||
|
status.textContent = 'Enter valid IMAP and SMTP ports (1–65535).';
|
||||||
|
return;
|
||||||
|
}
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
const reauthorizeOAuth = authMethod === 'oauth2' && editing && selectMailUi('#mail-account-reauthorize').checked;
|
const reauthorizeOAuth = authMethod === 'oauth2' && editing && selectMailUi('#mail-account-reauthorize').checked;
|
||||||
button.textContent = authMethod === 'oauth2' && (!editing || reauthorizeOAuth) ? 'Starting OAuth2 sign-in…' : editing ? 'Checking updated settings…' : 'Checking secure connections…';
|
button.textContent = authMethod === 'oauth2' && (!editing || reauthorizeOAuth) ? 'Starting OAuth2 sign-in…' : editing ? 'Checking updated settings…' : 'Checking secure connections…';
|
||||||
@@ -347,7 +365,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}),
|
...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}),
|
||||||
displayName: name,
|
displayName: name,
|
||||||
imapHost: selectMailUi('#mail-account-imap').value,
|
imapHost: selectMailUi('#mail-account-imap').value,
|
||||||
|
imapPort,
|
||||||
|
imapSecure: selectMailUi('#mail-account-imap-secure').checked,
|
||||||
smtpHost: selectMailUi('#mail-account-smtp').value,
|
smtpHost: selectMailUi('#mail-account-smtp').value,
|
||||||
|
smtpPort,
|
||||||
|
smtpSecure: selectMailUi('#mail-account-smtp-secure').checked,
|
||||||
signature: selectMailUi('#mail-account-signature').value,
|
signature: selectMailUi('#mail-account-signature').value,
|
||||||
notificationsEnabled: selectMailUi('#mail-account-notifications').checked,
|
notificationsEnabled: selectMailUi('#mail-account-notifications').checked,
|
||||||
syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value),
|
syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value),
|
||||||
|
|||||||
Generated
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.2",
|
"version": "0.5.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.2",
|
"version": "0.5.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"imapflow": "2.2.1",
|
"imapflow": "2.2.1",
|
||||||
"mailparser": "3.9.33",
|
"mailparser": "3.9.33",
|
||||||
"nodemailer": "10.0.9",
|
"nodemailer": "10.0.9",
|
||||||
"openpgp": "^6.3.2",
|
"openpgp": "6.3.2",
|
||||||
"tsdav": "^2.3.4",
|
"tsdav": "^2.3.4",
|
||||||
"v8-compile-cache": "^2.4.0"
|
"v8-compile-cache": "^2.4.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.2",
|
"version": "0.5.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
"imapflow": "2.2.1",
|
"imapflow": "2.2.1",
|
||||||
"mailparser": "3.9.33",
|
"mailparser": "3.9.33",
|
||||||
"nodemailer": "10.0.9",
|
"nodemailer": "10.0.9",
|
||||||
"openpgp": "^6.3.2",
|
"openpgp": "6.3.2",
|
||||||
"tsdav": "^2.3.4",
|
"tsdav": "^2.3.4",
|
||||||
"v8-compile-cache": "^2.4.0"
|
"v8-compile-cache": "^2.4.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,6 +513,8 @@
|
|||||||
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === "android") {
|
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === "android") {
|
||||||
window.daybreakMail = {
|
window.daybreakMail = {
|
||||||
getAppVersion: () => EpMail.getAppVersion().then((result) => result.version),
|
getAppVersion: () => EpMail.getAppVersion().then((result) => result.version),
|
||||||
|
getNotificationPrivacy: () => EpMail.getNotificationPrivacy(),
|
||||||
|
setNotificationDetails: (enabled) => EpMail.setNotificationDetails({ enabled }),
|
||||||
getAccount: () => EpMail.getAccount(),
|
getAccount: () => EpMail.getAccount(),
|
||||||
listAccounts: () => EpMail.listAccounts(),
|
listAccounts: () => EpMail.listAccounts(),
|
||||||
selectAccount: (id) => EpMail.selectAccount({ id }),
|
selectAccount: (id) => EpMail.selectAccount({ id }),
|
||||||
|
|||||||
+7
-3
@@ -27,16 +27,20 @@ function openAccountSettings() {
|
|||||||
selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')};
|
selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')};
|
||||||
selectProductivityUi('#profile-name').focus();
|
selectProductivityUi('#profile-name').focus();
|
||||||
}
|
}
|
||||||
function openPreferences() {
|
async function openPreferences() {
|
||||||
const root=selectProductivityUi('#modal-root');
|
const root=selectProductivityUi('#modal-root');
|
||||||
const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']];
|
const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']];
|
||||||
const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland';
|
const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland';
|
||||||
const options=themes.map(([value,label])=>`<option value="${value}"${value===selectedTheme?' selected':''}>${label}</option>`).join('');
|
const options=themes.map(([value,label])=>`<option value="${value}"${value===selectedTheme?' selected':''}>${label}</option>`).join('');
|
||||||
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Settings</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Theme</span><select class="settings-select" id="theme-select">${options}</select></label><p class="account-note">Your selected theme is saved and applied whenever ep-mail starts.</p></div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-appearance">Save appearance</button></div></div></div>`;
|
const notificationBridge=window.daybreakMail?.getNotificationPrivacy&&window.daybreakMail?.setNotificationDetails?window.daybreakMail:null;
|
||||||
|
let notificationPrivacy={showDetails:false};
|
||||||
|
if(notificationBridge){try{notificationPrivacy=await notificationBridge.getNotificationPrivacy()}catch(error){toastProductivityUi(error.message||'Could not load notification privacy settings');return}}
|
||||||
|
const notificationSetting=notificationBridge?`<label class="compose-line"><span>Show sender and subject in notifications</span><input id="show-notification-details" type="checkbox"${notificationPrivacy.showDetails?' checked':''}></label><p class="account-note">Off by default. Android still hides private details from lock-screen previews.</p>`:'';
|
||||||
|
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Settings</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Theme</span><select class="settings-select" id="theme-select">${options}</select></label><p class="account-note">Your selected theme is saved and applied whenever ep-mail starts.</p>${notificationSetting}</div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-appearance">Save settings</button></div></div></div>`;
|
||||||
const close=()=>root.innerHTML='';
|
const close=()=>root.innerHTML='';
|
||||||
selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close);
|
selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close);
|
||||||
selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};
|
selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};
|
||||||
selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')};
|
selectProductivityUi('#save-appearance').onclick=async()=>{const button=selectProductivityUi('#save-appearance');button.disabled=true;try{if(notificationBridge)await notificationBridge.setNotificationDetails(selectProductivityUi('#show-notification-details').checked);productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Settings saved')}catch(error){button.disabled=false;toastProductivityUi(error.message||'Could not save settings')}};
|
||||||
selectProductivityUi('#theme-select').focus();
|
selectProductivityUi('#theme-select').focus();
|
||||||
}
|
}
|
||||||
function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${edit?'Edit event':'Add calendar event'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Event</span><input id="event-name" maxlength="120" value="${escapeProductivityUi(edit?.title||'')}" placeholder="Give it a name"></label><label class="compose-line"><span>Date</span><input id="event-date" type="date" value="${dateValue}"></label><label class="compose-line"><span>Time</span><input id="event-time" type="time" value="${escapeProductivityUi(edit?.time||'10:00')}"></label><label class="compose-line"><span>With</span><input id="event-people" value="${escapeProductivityUi(edit?.with||'')}" placeholder="Add people"></label><label class="compose-line"><span>Place</span><input id="event-place" value="${escapeProductivityUi(edit?.place||'')}" placeholder="Add a place"></label><label class="compose-line"><span>Notes</span><input id="event-notes" value="${escapeProductivityUi(edit?.notes||'')}" placeholder="Optional notes"></label></div><div class="compose-footer">${edit?'<button class="discard" id="delete-event">Delete event</button>':'<button class="discard modal-close">Cancel</button>'}<button class="send-button" id="save-event">${edit?'Save changes':'Save event'}</button></div></div></div>`; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); }
|
function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${edit?'Edit event':'Add calendar event'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Event</span><input id="event-name" maxlength="120" value="${escapeProductivityUi(edit?.title||'')}" placeholder="Give it a name"></label><label class="compose-line"><span>Date</span><input id="event-date" type="date" value="${dateValue}"></label><label class="compose-line"><span>Time</span><input id="event-time" type="time" value="${escapeProductivityUi(edit?.time||'10:00')}"></label><label class="compose-line"><span>With</span><input id="event-people" value="${escapeProductivityUi(edit?.with||'')}" placeholder="Add people"></label><label class="compose-line"><span>Place</span><input id="event-place" value="${escapeProductivityUi(edit?.place||'')}" placeholder="Add a place"></label><label class="compose-line"><span>Notes</span><input id="event-notes" value="${escapeProductivityUi(edit?.notes||'')}" placeholder="Optional notes"></label></div><div class="compose-footer">${edit?'<button class="discard" id="delete-event">Delete event</button>':'<button class="discard modal-close">Cancel</button>'}<button class="send-button" id="save-event">${edit?'Save changes':'Save event'}</button></div></div></div>`; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); }
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ const EpMail = registerPlugin('EpMail');
|
|||||||
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
||||||
window.daybreakMail = {
|
window.daybreakMail = {
|
||||||
getAppVersion: () => EpMail.getAppVersion().then(result => result.version),
|
getAppVersion: () => EpMail.getAppVersion().then(result => result.version),
|
||||||
|
getNotificationPrivacy: () => EpMail.getNotificationPrivacy(),
|
||||||
|
setNotificationDetails: enabled => EpMail.setNotificationDetails({ enabled }),
|
||||||
getAccount: () => EpMail.getAccount(),
|
getAccount: () => EpMail.getAccount(),
|
||||||
listAccounts: () => EpMail.listAccounts(),
|
listAccounts: () => EpMail.listAccounts(),
|
||||||
selectAccount: id => EpMail.selectAccount({ id }),
|
selectAccount: id => EpMail.selectAccount({ id }),
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
const CACHE='ep-mail-v12';
|
const CACHE='ep-mail-v16';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||||
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
||||||
|
|||||||
+93
-2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,53 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '..');
|
||||||
|
const styles = fs.readFileSync(path.join(root, 'styles.css'), 'utf8');
|
||||||
|
const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
|
||||||
|
const app = fs.readFileSync(path.join(root, 'app.js'), 'utf8');
|
||||||
|
const transport = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'AndroidMailTransport.kt'), 'utf8');
|
||||||
|
const mainActivity = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'MainActivity.java'), 'utf8');
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
||||||
|
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
||||||
|
|
||||||
|
test('mobile layout removes desktop minimum width and provides a compact reader flow', () => {
|
||||||
|
assert.match(styles, /min-width:320px/);
|
||||||
|
assert.match(styles, /@media\(max-width:1000px\),\(max-height:500px\) and \(orientation:landscape\)/);
|
||||||
|
assert.match(styles, /@media\(max-height:500px\) and \(orientation:landscape\)/);
|
||||||
|
assert.match(styles, /overflow-wrap:anywhere;word-break:break-word/);
|
||||||
|
assert.match(styles, /\.hidden,\[hidden\]\{display:none!important\}/);
|
||||||
|
assert.match(styles, /body\.reader-open \.mail-layout \.list-pane/);
|
||||||
|
assert.match(app, /id="reader-back"/);
|
||||||
|
assert.match(app, /classList\.add\('reader-open'\)/);
|
||||||
|
assert.match(app, /\$\$\('\.folder'\)\.forEach/);
|
||||||
|
assert.match(app, /if\(!m\)\{state\.activeMessage=null;document\.body\.classList\.remove\('reader-open'\);return;\}/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('mailbox setup exposes ports and TLS modes and submits them to Android', () => {
|
||||||
|
for (const id of ['mail-account-imap-port', 'mail-account-imap-secure', 'mail-account-smtp-port', 'mail-account-smtp-secure']) {
|
||||||
|
assert.ok(mailUi.includes(`id="${id}"`), `missing account field ${id}`);
|
||||||
|
}
|
||||||
|
assert.match(mailUi, /imapPort,/);
|
||||||
|
assert.match(mailUi, /imapSecure:/);
|
||||||
|
assert.match(mailUi, /smtpPort,/);
|
||||||
|
assert.match(mailUi, /smtpSecure:/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Android mail transport supports verified implicit TLS and required STARTTLS modes', () => {
|
||||||
|
assert.match(transport, /"imaps" else "imap"/);
|
||||||
|
assert.match(transport, /mail\.\$protocol\.starttls\.required/);
|
||||||
|
assert.match(transport, /mail\.smtp\.ssl\.enable/);
|
||||||
|
assert.match(transport, /mail\.smtp\.starttls\.required/);
|
||||||
|
assert.match(transport, /ssl\.checkserveridentity/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Capacitor mail plugin is registered before BridgeActivity creates the bridge', () => {
|
||||||
|
assert.ok(mainActivity.indexOf('registerPlugin(EpMailPlugin.class)') < mainActivity.indexOf('super.onCreate(savedInstanceState)'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('OpenPGP.js is pinned to the exact version in the lockfile pending security review', () => {
|
||||||
|
assert.equal(packageJson.dependencies.openpgp, packageLock.packages['node_modules/openpgp'].version);
|
||||||
|
assert.match(packageJson.dependencies.openpgp, /^\d+\.\d+\.\d+$/);
|
||||||
|
});
|
||||||
+8
-6
@@ -4,11 +4,12 @@ const state = window.epMailState;
|
|||||||
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
||||||
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
||||||
const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity;
|
const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity;
|
||||||
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length){document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader()}}
|
||||||
function openMessage(id){
|
function openMessage(id){
|
||||||
state.activeMessage=id;
|
state.activeMessage=id;
|
||||||
const m=state.messages.find(x=>x.id===id);
|
const m=state.messages.find(x=>x.id===id);
|
||||||
if(!m)return;
|
if(!m){state.activeMessage=null;document.body.classList.remove('reader-open');return;}
|
||||||
|
document.body.classList.add('reader-open');
|
||||||
m.unread=false;
|
m.unread=false;
|
||||||
renderList();
|
renderList();
|
||||||
let safeHtml={html:'',remoteImageCount:0};
|
let safeHtml={html:'',remoteImageCount:0};
|
||||||
@@ -16,7 +17,8 @@ function openMessage(id){
|
|||||||
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
||||||
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
||||||
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
||||||
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><button class="reader-back" id="reader-back" type="button" aria-label="Back to messages">Back</button><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
||||||
|
$('#reader-back').onclick=()=>{state.activeMessage=null;document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader();renderList()};
|
||||||
$('#load-remote-images')?.addEventListener('click',()=>{
|
$('#load-remote-images')?.addEventListener('click',()=>{
|
||||||
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
||||||
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
||||||
@@ -25,8 +27,8 @@ function openMessage(id){
|
|||||||
});
|
});
|
||||||
$('.remote-image-notice')?.remove();
|
$('.remote-image-notice')?.remove();
|
||||||
});
|
});
|
||||||
$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
$('#reader-archive').onclick=()=>{m.archived=true;state.activeMessage=null;document.body.classList.remove('reader-open');toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
$('#reader-delete').onclick=()=>{m.deleted=true;state.activeMessage=null;document.body.classList.remove('reader-open');toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
||||||
$('#reply').onclick=()=>showCompose(m);
|
$('#reply').onclick=()=>showCompose(m);
|
||||||
$('#forward').onclick=()=>showCompose(m,true);
|
$('#forward').onclick=()=>showCompose(m,true);
|
||||||
@@ -35,7 +37,7 @@ function emptyReader(){return `<div class="reader-empty"><div><div class="empty-
|
|||||||
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
||||||
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
||||||
function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();}
|
function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();}
|
||||||
$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage);
|
$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;state.activeMessage=null;document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader();$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{document.body.classList.remove('reader-open');switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage);
|
||||||
|
|
||||||
window.epMailShell = Object.freeze({
|
window.epMailShell = Object.freeze({
|
||||||
state,
|
state,
|
||||||
|
|||||||
+24
-2
@@ -228,7 +228,7 @@ function openMailAccount(existingAccount = null) {
|
|||||||
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${escapeMailUi(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${escapeMailUi(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
||||||
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${editing ? 'Edit mailbox' : 'Add a mailbox'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Your password is encrypted with this computer's credential storage. Connections require TLS.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="${escapeMailUi(existingAccount?.email || '')}" placeholder="name@example.com"></label><label class="compose-line"><span>Account display name</span><input id="mail-account-display-name" maxlength="80" autocomplete="name" value="${escapeMailUi(displayName)}" placeholder="Your name" required></label><label class="compose-line"><span>Password</span><input id="mail-account-password" type="password" autocomplete="${editing ? 'new-password' : 'current-password'}" placeholder="${editing ? 'Leave blank to keep current password' : 'Enter mailbox password'}"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="${escapeMailUi(existingAccount?.imapHost || '')}" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="${escapeMailUi(existingAccount?.smtpHost || '')}" autocomplete="off" placeholder="smtp.example.com"></label><label class="compose-line"><span>Sync interval</span><select id="mail-account-sync-interval" class="settings-select">${[2,5,15,30,60].map(minutes=>`<option value="${minutes}"${Number(existingAccount?.syncIntervalMinutes||2)===minutes?' selected':''}>Every ${minutes} minutes</option>`).join('')}</select></label><label class="compose-line"><span>New-mail notifications</span><input id="mail-account-notifications" type="checkbox"${existingAccount?.notificationsEnabled!==false?' checked':''}></label><label class="compose-line" style="display:block;padding:8px 0"><span>Signature</span><textarea id="mail-account-signature" maxlength="5000" rows="3" placeholder="Add a signature for this mailbox" style="display:block;box-sizing:border-box;width:100%;margin-top:7px">${escapeMailUi(existingAccount?.signature || '')}</textarea></label><section class="mail-rules"><div class="section-label"><span>MAIL RULES</span><button type="button" class="tiny-plus" id="add-mail-rule" aria-label="Add mail rule">+</button></div><p class="account-note">Rules match the sender or subject of incoming mail. The first matching rule runs.</p><div id="mail-rule-list">${ruleMarkup}</div></section><p class="account-note">Signatures are appended to outgoing messages. Sync interval controls periodic checks when IMAP IDLE is unavailable; Android may apply its 15-minute minimum background interval.${editing ? ' Leave the password empty to keep the saved password.' : ''}</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">${editing ? 'Save & reconnect' : 'Test & connect'}</button></div></div></div>`;
|
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${editing ? 'Edit mailbox' : 'Add a mailbox'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Credentials are stored encrypted. Choose the server's advertised TLS mode and ports.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="${escapeMailUi(existingAccount?.email || '')}" placeholder="name@example.com"></label><label class="compose-line"><span>Account display name</span><input id="mail-account-display-name" maxlength="80" autocomplete="name" value="${escapeMailUi(displayName)}" placeholder="Your name" required></label><label class="compose-line"><span>Password / app password</span><input id="mail-account-password" type="password" autocomplete="${editing ? 'new-password' : 'current-password'}" placeholder="${editing ? 'Leave blank to keep current password' : 'Enter mailbox password'}"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="${escapeMailUi(existingAccount?.imapHost || '')}" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>IMAP port</span><input id="mail-account-imap-port" type="number" inputmode="numeric" min="1" max="65535" value="${existingAccount?.imapPort || (existingAccount?.authMethod === 'oauth2' ? 993 : 143)}"></label><label class="compose-line mail-security-option"><span>IMAP implicit SSL/TLS (usually port 993)</span><input id="mail-account-imap-secure" type="checkbox"${existingAccount?.imapSecure ? ' checked' : ''}></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="${escapeMailUi(existingAccount?.smtpHost || '')}" autocomplete="off" placeholder="smtp.example.com"></label><label class="compose-line"><span>SMTP port</span><input id="mail-account-smtp-port" type="number" inputmode="numeric" min="1" max="65535" value="${existingAccount?.smtpPort || 587}"></label><label class="compose-line mail-security-option"><span>SMTP implicit SSL/TLS (usually port 465)</span><input id="mail-account-smtp-secure" type="checkbox"${existingAccount?.smtpSecure ? ' checked' : ''}></label><p class="account-note">For IMAP port 143 and SMTP port 587, leave implicit SSL/TLS off to use required STARTTLS. Common Gmail settings are IMAP SSL/TLS on port 993 and SMTP STARTTLS on port 587; use an app password if required by your provider.</p><label class="compose-line"><span>Sync interval</span><select id="mail-account-sync-interval" class="settings-select">${[2,5,15,30,60].map(minutes=>`<option value="${minutes}"${Number(existingAccount?.syncIntervalMinutes||2)===minutes?' selected':''}>Every ${minutes} minutes</option>`).join('')}</select></label><label class="compose-line"><span>New-mail notifications</span><input id="mail-account-notifications" type="checkbox"${existingAccount?.notificationsEnabled!==false?' checked':''}></label><label class="compose-line" style="display:block;padding:8px 0"><span>Signature</span><textarea id="mail-account-signature" maxlength="5000" rows="3" placeholder="Add a signature for this mailbox" style="display:block;box-sizing:border-box;width:100%;margin-top:7px">${escapeMailUi(existingAccount?.signature || '')}</textarea></label><section class="mail-rules"><div class="section-label"><span>MAIL RULES</span><button type="button" class="tiny-plus" id="add-mail-rule" aria-label="Add mail rule">+</button></div><p class="account-note">Rules match the sender or subject of incoming mail. The first matching rule runs.</p><div id="mail-rule-list">${ruleMarkup}</div></section><p class="account-note">Signatures are appended to outgoing messages. Sync interval controls periodic checks when IMAP IDLE is unavailable; Android may apply its 15-minute minimum background interval.${editing ? ' Leave the password empty to keep the saved password.' : ''}</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">${editing ? 'Save & reconnect' : 'Test & connect'}</button></div></div></div>`;
|
||||||
const authMethodRow = document.createElement('label');
|
const authMethodRow = document.createElement('label');
|
||||||
authMethodRow.className = 'compose-line';
|
authMethodRow.className = 'compose-line';
|
||||||
authMethodRow.innerHTML = '<span>Sign-in method</span><select id="mail-account-auth-method" class="settings-select"><option value="password">App password</option><option value="oauth2">OAuth2</option></select>';
|
authMethodRow.innerHTML = '<span>Sign-in method</span><select id="mail-account-auth-method" class="settings-select"><option value="password">App password</option><option value="oauth2">OAuth2</option></select>';
|
||||||
@@ -249,7 +249,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
if (oauthMethodOption) oauthMethodOption.disabled = existingAccount?.authMethod !== 'oauth2';
|
if (oauthMethodOption) oauthMethodOption.disabled = existingAccount?.authMethod !== 'oauth2';
|
||||||
const passwordRow = selectMailUi('#mail-account-password').closest('.compose-line');
|
const passwordRow = selectMailUi('#mail-account-password').closest('.compose-line');
|
||||||
const imapRow = selectMailUi('#mail-account-imap').closest('.compose-line');
|
const imapRow = selectMailUi('#mail-account-imap').closest('.compose-line');
|
||||||
|
const imapPortRow = selectMailUi('#mail-account-imap-port').closest('.compose-line');
|
||||||
|
const imapSecureRow = selectMailUi('#mail-account-imap-secure').closest('.compose-line');
|
||||||
const smtpRow = selectMailUi('#mail-account-smtp').closest('.compose-line');
|
const smtpRow = selectMailUi('#mail-account-smtp').closest('.compose-line');
|
||||||
|
const smtpPortRow = selectMailUi('#mail-account-smtp-port').closest('.compose-line');
|
||||||
|
const smtpSecureRow = selectMailUi('#mail-account-smtp-secure').closest('.compose-line');
|
||||||
const authNote = selectMailUi('#modal-root .compose-fields > .account-note');
|
const authNote = selectMailUi('#modal-root .compose-fields > .account-note');
|
||||||
authMethodSelect.value = existingAccount?.authMethod === 'oauth2' ? 'oauth2' : 'password';
|
authMethodSelect.value = existingAccount?.authMethod === 'oauth2' ? 'oauth2' : 'password';
|
||||||
if (existingAccount?.oauthProvider) oauthProviderSelect.value = existingAccount.oauthProvider;
|
if (existingAccount?.oauthProvider) oauthProviderSelect.value = existingAccount.oauthProvider;
|
||||||
@@ -258,7 +262,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
? { imap: 'imap.gmail.com', smtp: 'smtp.gmail.com' }
|
? { imap: 'imap.gmail.com', smtp: 'smtp.gmail.com' }
|
||||||
: { imap: 'outlook.office365.com', smtp: 'smtp.office365.com' };
|
: { imap: 'outlook.office365.com', smtp: 'smtp.office365.com' };
|
||||||
selectMailUi('#mail-account-imap').value = servers.imap;
|
selectMailUi('#mail-account-imap').value = servers.imap;
|
||||||
|
selectMailUi('#mail-account-imap-port').value = '993';
|
||||||
|
selectMailUi('#mail-account-imap-secure').checked = true;
|
||||||
selectMailUi('#mail-account-smtp').value = servers.smtp;
|
selectMailUi('#mail-account-smtp').value = servers.smtp;
|
||||||
|
selectMailUi('#mail-account-smtp-port').value = '587';
|
||||||
|
selectMailUi('#mail-account-smtp-secure').checked = false;
|
||||||
};
|
};
|
||||||
const updateAuthFields = () => {
|
const updateAuthFields = () => {
|
||||||
const oauth = authMethodSelect.value === 'oauth2';
|
const oauth = authMethodSelect.value === 'oauth2';
|
||||||
@@ -267,12 +275,16 @@ function openMailAccount(existingAccount = null) {
|
|||||||
reauthorizeRow.hidden = !oauth || !editing;
|
reauthorizeRow.hidden = !oauth || !editing;
|
||||||
passwordRow.hidden = oauth;
|
passwordRow.hidden = oauth;
|
||||||
imapRow.hidden = oauth;
|
imapRow.hidden = oauth;
|
||||||
|
imapPortRow.hidden = oauth;
|
||||||
|
imapSecureRow.hidden = oauth;
|
||||||
smtpRow.hidden = oauth;
|
smtpRow.hidden = oauth;
|
||||||
|
smtpPortRow.hidden = oauth;
|
||||||
|
smtpSecureRow.hidden = oauth;
|
||||||
authNote.textContent = oauth
|
authNote.textContent = oauth
|
||||||
? 'Sign in in your browser. Configure the provider client ID in the desktop environment; OAuth refresh tokens are stored in encrypted credential storage.'
|
? 'Sign in in your browser. Configure the provider client ID in the desktop environment; OAuth refresh tokens are stored in encrypted credential storage.'
|
||||||
: configuredOAuthProviders && configuredOAuthProviders.size === 0
|
: configuredOAuthProviders && configuredOAuthProviders.size === 0
|
||||||
? 'Password sign-in is available. To enable OAuth2, configure EP_MAIL_GOOGLE_OAUTH_CLIENT_ID and/or EP_MAIL_MICROSOFT_OAUTH_CLIENT_ID, then restart ep-mail.'
|
? 'Password sign-in is available. To enable OAuth2, configure EP_MAIL_GOOGLE_OAUTH_CLIENT_ID and/or EP_MAIL_MICROSOFT_OAUTH_CLIENT_ID, then restart ep-mail.'
|
||||||
: 'Your password is encrypted with this computer\'s credential storage. Connections require TLS.';
|
: 'Credentials are stored encrypted. Connections require verified TLS.';
|
||||||
selectMailUi('#mail-account-password').placeholder = editing && existingAccount?.authMethod !== 'oauth2'
|
selectMailUi('#mail-account-password').placeholder = editing && existingAccount?.authMethod !== 'oauth2'
|
||||||
? 'Leave blank to keep current password' : 'Enter mailbox password';
|
? 'Leave blank to keep current password' : 'Enter mailbox password';
|
||||||
};
|
};
|
||||||
@@ -332,6 +344,12 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const name = selectMailUi('#mail-account-display-name').value.trim();
|
const name = selectMailUi('#mail-account-display-name').value.trim();
|
||||||
if (!name) { status.textContent = 'Enter a display name for this mail account.'; selectMailUi('#mail-account-display-name').focus(); return; }
|
if (!name) { status.textContent = 'Enter a display name for this mail account.'; selectMailUi('#mail-account-display-name').focus(); return; }
|
||||||
if (authMethod === 'password' && !password && (!editing || existingAccount?.authMethod === 'oauth2')) { status.textContent = 'Enter the mailbox password to connect.'; selectMailUi('#mail-account-password').focus(); return; }
|
if (authMethod === 'password' && !password && (!editing || existingAccount?.authMethod === 'oauth2')) { status.textContent = 'Enter the mailbox password to connect.'; selectMailUi('#mail-account-password').focus(); return; }
|
||||||
|
const imapPort = Number(selectMailUi('#mail-account-imap-port').value);
|
||||||
|
const smtpPort = Number(selectMailUi('#mail-account-smtp-port').value);
|
||||||
|
if (authMethod === 'password' && (![imapPort, smtpPort].every(port => Number.isInteger(port) && port >= 1 && port <= 65535))) {
|
||||||
|
status.textContent = 'Enter valid IMAP and SMTP ports (1–65535).';
|
||||||
|
return;
|
||||||
|
}
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
const reauthorizeOAuth = authMethod === 'oauth2' && editing && selectMailUi('#mail-account-reauthorize').checked;
|
const reauthorizeOAuth = authMethod === 'oauth2' && editing && selectMailUi('#mail-account-reauthorize').checked;
|
||||||
button.textContent = authMethod === 'oauth2' && (!editing || reauthorizeOAuth) ? 'Starting OAuth2 sign-in…' : editing ? 'Checking updated settings…' : 'Checking secure connections…';
|
button.textContent = authMethod === 'oauth2' && (!editing || reauthorizeOAuth) ? 'Starting OAuth2 sign-in…' : editing ? 'Checking updated settings…' : 'Checking secure connections…';
|
||||||
@@ -347,7 +365,11 @@ function openMailAccount(existingAccount = null) {
|
|||||||
...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}),
|
...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}),
|
||||||
displayName: name,
|
displayName: name,
|
||||||
imapHost: selectMailUi('#mail-account-imap').value,
|
imapHost: selectMailUi('#mail-account-imap').value,
|
||||||
|
imapPort,
|
||||||
|
imapSecure: selectMailUi('#mail-account-imap-secure').checked,
|
||||||
smtpHost: selectMailUi('#mail-account-smtp').value,
|
smtpHost: selectMailUi('#mail-account-smtp').value,
|
||||||
|
smtpPort,
|
||||||
|
smtpSecure: selectMailUi('#mail-account-smtp-secure').checked,
|
||||||
signature: selectMailUi('#mail-account-signature').value,
|
signature: selectMailUi('#mail-account-signature').value,
|
||||||
notificationsEnabled: selectMailUi('#mail-account-notifications').checked,
|
notificationsEnabled: selectMailUi('#mail-account-notifications').checked,
|
||||||
syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value),
|
syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value),
|
||||||
|
|||||||
@@ -513,6 +513,8 @@
|
|||||||
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === "android") {
|
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === "android") {
|
||||||
window.daybreakMail = {
|
window.daybreakMail = {
|
||||||
getAppVersion: () => EpMail.getAppVersion().then((result) => result.version),
|
getAppVersion: () => EpMail.getAppVersion().then((result) => result.version),
|
||||||
|
getNotificationPrivacy: () => EpMail.getNotificationPrivacy(),
|
||||||
|
setNotificationDetails: (enabled) => EpMail.setNotificationDetails({ enabled }),
|
||||||
getAccount: () => EpMail.getAccount(),
|
getAccount: () => EpMail.getAccount(),
|
||||||
listAccounts: () => EpMail.listAccounts(),
|
listAccounts: () => EpMail.listAccounts(),
|
||||||
selectAccount: (id) => EpMail.selectAccount({ id }),
|
selectAccount: (id) => EpMail.selectAccount({ id }),
|
||||||
|
|||||||
+7
-3
@@ -27,16 +27,20 @@ function openAccountSettings() {
|
|||||||
selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')};
|
selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')};
|
||||||
selectProductivityUi('#profile-name').focus();
|
selectProductivityUi('#profile-name').focus();
|
||||||
}
|
}
|
||||||
function openPreferences() {
|
async function openPreferences() {
|
||||||
const root=selectProductivityUi('#modal-root');
|
const root=selectProductivityUi('#modal-root');
|
||||||
const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']];
|
const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']];
|
||||||
const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland';
|
const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland';
|
||||||
const options=themes.map(([value,label])=>`<option value="${value}"${value===selectedTheme?' selected':''}>${label}</option>`).join('');
|
const options=themes.map(([value,label])=>`<option value="${value}"${value===selectedTheme?' selected':''}>${label}</option>`).join('');
|
||||||
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Settings</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Theme</span><select class="settings-select" id="theme-select">${options}</select></label><p class="account-note">Your selected theme is saved and applied whenever ep-mail starts.</p></div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-appearance">Save appearance</button></div></div></div>`;
|
const notificationBridge=window.daybreakMail?.getNotificationPrivacy&&window.daybreakMail?.setNotificationDetails?window.daybreakMail:null;
|
||||||
|
let notificationPrivacy={showDetails:false};
|
||||||
|
if(notificationBridge){try{notificationPrivacy=await notificationBridge.getNotificationPrivacy()}catch(error){toastProductivityUi(error.message||'Could not load notification privacy settings');return}}
|
||||||
|
const notificationSetting=notificationBridge?`<label class="compose-line"><span>Show sender and subject in notifications</span><input id="show-notification-details" type="checkbox"${notificationPrivacy.showDetails?' checked':''}></label><p class="account-note">Off by default. Android still hides private details from lock-screen previews.</p>`:'';
|
||||||
|
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Settings</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Theme</span><select class="settings-select" id="theme-select">${options}</select></label><p class="account-note">Your selected theme is saved and applied whenever ep-mail starts.</p>${notificationSetting}</div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-appearance">Save settings</button></div></div></div>`;
|
||||||
const close=()=>root.innerHTML='';
|
const close=()=>root.innerHTML='';
|
||||||
selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close);
|
selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close);
|
||||||
selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};
|
selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};
|
||||||
selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')};
|
selectProductivityUi('#save-appearance').onclick=async()=>{const button=selectProductivityUi('#save-appearance');button.disabled=true;try{if(notificationBridge)await notificationBridge.setNotificationDetails(selectProductivityUi('#show-notification-details').checked);productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Settings saved')}catch(error){button.disabled=false;toastProductivityUi(error.message||'Could not save settings')}};
|
||||||
selectProductivityUi('#theme-select').focus();
|
selectProductivityUi('#theme-select').focus();
|
||||||
}
|
}
|
||||||
function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${edit?'Edit event':'Add calendar event'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Event</span><input id="event-name" maxlength="120" value="${escapeProductivityUi(edit?.title||'')}" placeholder="Give it a name"></label><label class="compose-line"><span>Date</span><input id="event-date" type="date" value="${dateValue}"></label><label class="compose-line"><span>Time</span><input id="event-time" type="time" value="${escapeProductivityUi(edit?.time||'10:00')}"></label><label class="compose-line"><span>With</span><input id="event-people" value="${escapeProductivityUi(edit?.with||'')}" placeholder="Add people"></label><label class="compose-line"><span>Place</span><input id="event-place" value="${escapeProductivityUi(edit?.place||'')}" placeholder="Add a place"></label><label class="compose-line"><span>Notes</span><input id="event-notes" value="${escapeProductivityUi(edit?.notes||'')}" placeholder="Optional notes"></label></div><div class="compose-footer">${edit?'<button class="discard" id="delete-event">Delete event</button>':'<button class="discard modal-close">Cancel</button>'}<button class="send-button" id="save-event">${edit?'Save changes':'Save event'}</button></div></div></div>`; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); }
|
function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${edit?'Edit event':'Add calendar event'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>Event</span><input id="event-name" maxlength="120" value="${escapeProductivityUi(edit?.title||'')}" placeholder="Give it a name"></label><label class="compose-line"><span>Date</span><input id="event-date" type="date" value="${dateValue}"></label><label class="compose-line"><span>Time</span><input id="event-time" type="time" value="${escapeProductivityUi(edit?.time||'10:00')}"></label><label class="compose-line"><span>With</span><input id="event-people" value="${escapeProductivityUi(edit?.with||'')}" placeholder="Add people"></label><label class="compose-line"><span>Place</span><input id="event-place" value="${escapeProductivityUi(edit?.place||'')}" placeholder="Add a place"></label><label class="compose-line"><span>Notes</span><input id="event-notes" value="${escapeProductivityUi(edit?.notes||'')}" placeholder="Optional notes"></label></div><div class="compose-footer">${edit?'<button class="discard" id="delete-event">Delete event</button>':'<button class="discard modal-close">Cancel</button>'}<button class="send-button" id="save-event">${edit?'Save changes':'Save event'}</button></div></div></div>`; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const CACHE='ep-mail-v12';
|
const CACHE='ep-mail-v16';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||||
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
||||||
|
|||||||
+93
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user