Let each install pick its app icon
Settings > General gets an App icon (super admin): one of the seven stones, or an uploaded image with the picked stone as a top-left corner mark (inside a round launcher's crop, clear of the browser's badge), previewed in both launcher crops before saving. Uploads are decoded and cropped to a stored square (no SVG); the set is drawn into DATA_DIR/install-icon/<version>/ and served publicly and immutable. The manifest, head icon links and push notifications point at it; the ember stone keeps the stock icons. The generator shares the icon renderer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import type { PushPayload } from "@/src/dict/push-dict";
|
||||
import grabPushSubscriptions from "@/src/functions/backend/db/push/grab-push-subscriptions";
|
||||
import grabInstallIcon from "@/src/functions/backend/db/app-settings/grab-install-icon";
|
||||
import installIconBase from "@/src/utils/install-icon-base";
|
||||
import sendWebPush from "./send-web-push";
|
||||
|
||||
/**
|
||||
* Sends to every device the user subscribed. Best effort: one failed
|
||||
* device does not stop the others.
|
||||
* Sends to every device the user subscribed, with the install's own icon
|
||||
* when it has one. Best effort: one failed device does not stop the
|
||||
* others.
|
||||
*/
|
||||
export default async function deliverToUser({
|
||||
user_id,
|
||||
@@ -15,9 +18,14 @@ export default async function deliverToUser({
|
||||
}) {
|
||||
const subscriptions = await grabPushSubscriptions({ user_id });
|
||||
|
||||
if (!subscriptions.length) return;
|
||||
|
||||
const icon_base = installIconBase({ icon: await grabInstallIcon().catch(() => null) });
|
||||
const sent = icon_base ? { ...payload, icon: `${icon_base}/icon-192.png` } : payload;
|
||||
|
||||
await Promise.all(
|
||||
subscriptions.map((subscription) =>
|
||||
sendWebPush({ subscription, payload }),
|
||||
sendWebPush({ subscription, payload: sent }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user