Dough Git

commit

Add a Get the Android app link

commit
425a8a818b49dca019a36a9ab98f536eb7097a17
author
Clove Twilight <[email protected]>
date
2026-10-31 08:37
/download redirects to the APK on the rolling latest release, so the link
stays the same while the file is named by version.

diff --git a/email/src/web/components/Sidebar.svelte b/email/src/web/components/Sidebar.svelte
index 9bf68e1..d091a9e 100644
--- a/email/src/web/components/Sidebar.svelte
+++ b/email/src/web/components/Sidebar.svelte
@@ -7,6 +7,7 @@
   import Globe from "../lib/icons/Globe.svelte";
   import InboxIcon from "../lib/icons/Inbox.svelte";
   import LogOut from "../lib/icons/LogOut.svelte";
+  import Mobile from "../lib/icons/Mobile.svelte";
   import Send from "../lib/icons/Send.svelte";
   import SettingsIcon from "../lib/icons/Settings.svelte";
   import Shield from "../lib/icons/Shield.svelte";
@@ -109,6 +110,8 @@
 
   <ul class="bottom">
     <li><a class="item" class:active={route.name === "settings" || route.name === "privacy" || route.name === "terms"} href={router.href("/settings")}><SettingsIcon size={16} /> <span class="label">Settings</span></a></li>
+    <!-- `download` keeps the router from treating it as a page in the app. -->
+    <li><a class="item" href="/download" download><Mobile size={16} /> <span class="label">Get the Android app</span></a></li>
     {#if session.me?.isAdmin}
       <li><a class="item" class:active={route.name === "admin"} href={router.href("/admin")}><Shield size={16} /> <span class="label">Admin</span></a></li>
     {/if}
diff --git a/email/src/web/lib/icons/Mobile.svelte b/email/src/web/lib/icons/Mobile.svelte
new file mode 100644
index 0000000..d165399
--- /dev/null
+++ b/email/src/web/lib/icons/Mobile.svelte
@@ -0,0 +1,11 @@
+<!-- src/web/lib/icons/Mobile.svelte
+     Licensed under the DASL-1.0 Licence — (c) Clove Twilight
+-->
+
+<script lang="ts">
+  import Icon from "./Icon.svelte";
+
+  let props: { size?: number; class?: string; [key: string]: unknown } = $props();
+</script>
+
+<Icon name="mobile" {...props} />
diff --git a/email/src/worker/index.ts b/email/src/worker/index.ts
index 6c64934..651bca4 100644
--- a/email/src/worker/index.ts
+++ b/email/src/worker/index.ts
@@ -3,6 +3,7 @@ import { secureHeaders } from "hono/secure-headers";
 import { requireUser, sameOrigin, type AppEnv } from "./middleware";
 import { admin } from "./routes/admin";
 import { auth } from "./routes/auth";
+import { download } from "./routes/download";
 import { mail } from "./routes/mail";
 import { webhook } from "./routes/webhook";
 import { sweepOrphanUploads } from "./services/attachments";
@@ -11,11 +12,12 @@ import { LiveHub } from "./services/live";
 import { purgeBin } from "./services/messages";
 import { sweepExpired } from "./services/sessions";
 
-// Only /api, /auth and /webhook reach the Worker (see run_worker_first in
+// Only /api, /auth, /webhook and /download reach the Worker (see run_worker_first in
 // wrangler.jsonc); the Svelte app is served straight from assets.
 const app = new Hono<AppEnv>()
   .use(secureHeaders({ referrerPolicy: "no-referrer", crossOriginResourcePolicy: "same-origin" }))
   .route("/webhook", webhook)
+  .route("/download", download)
   .use(sameOrigin)
   .route("/auth", auth)
   .use("/api/*", requireUser)
diff --git a/email/src/worker/routes/download.ts b/email/src/worker/routes/download.ts
new file mode 100644
index 0000000..12a4dd6
--- /dev/null
+++ b/email/src/worker/routes/download.ts
@@ -0,0 +1,20 @@
+import { Hono } from "hono";
+import type { AppEnv } from "../middleware";
+
+/** The rolling release CI keeps the newest Android build on. */
+const LATEST = "https://api.github.com/repos/doughmination/email/releases/tags/latest";
+const RELEASES = "https://github.com/doughmination/email/releases/latest";
+
+// Release APKs are named by version (inbox-1.0.6.apk), so /download looks up
+// the current one: the site's link stays the same from build to build.
+export const download = new Hono<AppEnv>().get("/", async (c) => {
+  const res = await fetch(LATEST, {
+    headers: { accept: "application/vnd.github+json", "user-agent": "doughmination-mail" },
+    // Cached at the edge, so a busy day doesn't run into GitHub's rate limit.
+    cf: { cacheTtl: 300, cacheEverything: true },
+  });
+  if (!res.ok) return c.redirect(RELEASES);
+  const { assets } = (await res.json()) as { assets: { name: string; browser_download_url: string }[] };
+  const apk = assets.find((a) => /^inbox-.+\.apk$/.test(a.name));
+  return c.redirect(apk?.browser_download_url ?? RELEASES);
+});
diff --git a/email/wrangler.jsonc b/email/wrangler.jsonc
index 96347ea..7c5363b 100644
--- a/email/wrangler.jsonc
+++ b/email/wrangler.jsonc
@@ -17,7 +17,8 @@
 		"run_worker_first": [
 			"/api/*",
 			"/auth/*",
-			"/webhook/*"
+			"/webhook/*",
+			"/download"
 		]
 	},
 	"d1_databases": [