forge
Clone
https://git.tahinli.com/Tahinli/forge.git
0 watching·0 forks·Rust·AGPL-3.0·7.1 MiB·490f099·Tahinli·7 hours ago·322 commits
| 1 | # Notifications |
| 2 | |
| 3 | Forge keeps an inbox of notifications for each user (the bell in the top bar). The same |
| 4 | notifications can also reach you by email, and by Web Push on your devices. |
| 5 | |
| 6 | ## Web Push |
| 7 | |
| 8 | Web Push delivers a notification to a device even when no Forge tab is open. It works in |
| 9 | Chromium-based browsers, Firefox and Safari, on desktop and on Android. On iPhone and iPad it works |
| 10 | only for an app installed to the Home Screen. |
| 11 | |
| 12 | ### Requirements |
| 13 | |
| 14 | - **HTTPS.** Browsers only offer push on a secure origin. Serve Forge over HTTPS (the usual |
| 15 | reverse-proxy setup). `localhost` also counts as secure for testing. |
| 16 | - **iOS and iPadOS.** Open Forge in Safari, use Share, then Add to Home Screen, and open Forge from |
| 17 | that icon. Then turn push on in the notification settings. Safari in a normal tab cannot receive |
| 18 | push. iOS 16.4 or later is needed. |
| 19 | - **Permission.** The browser asks for permission the first time you turn push on. If you refused, |
| 20 | allow notifications for the site in the browser's site settings and try again. |
| 21 | |
| 22 | ### Turning it on |
| 23 | |
| 24 | 1. Open **Settings, Notifications**. |
| 25 | 2. Under **Push notifications on this device**, choose **Turn on for this device**, then allow |
| 26 | notifications when the browser asks. |
| 27 | 3. Choose **Send test notification** to check that the device gets one. |
| 28 | |
| 29 | Each browser profile, and each installed app, is a separate device. The **Devices** list shows |
| 30 | every device with push on, when it was added and when it last received a notification. Remove a |
| 31 | device there to stop its notifications; **Turn off for this device** does the same for the device |
| 32 | you are using. |
| 33 | |
| 34 | ### What is sent |
| 35 | |
| 36 | A notification carries a short title (for example `owner/repo#12`), a one-line body (the activity |
| 37 | and the start of the title, at most 140 characters) and the link it opens. Nothing else is sent: no |
| 38 | token, no email address and no body text. The push service sees that a message was delivered to |
| 39 | your device, as with any push service. |
| 40 | |
| 41 | Only notifications that reach your inbox are pushed. The same rules apply: you hear about activity |
| 42 | on threads you follow, when you are mentioned, assigned or asked to review, and so on. Watching a |
| 43 | repo or ignoring a thread changes what reaches your inbox, and so what is pushed. Security alerts |
| 44 | and site admin alerts are pushed the same way. |
| 45 | |
| 46 | Notifications on a lock screen can show the title of a private repository. Turn push off for a |
| 47 | device you share. |
| 48 | |
| 49 | ### Devices that stop working |
| 50 | |
| 51 | A push service answers `404` or `410` for a subscription that no longer exists, for example after |
| 52 | the browser was reset or the app was uninstalled. Forge removes such a device by itself. A device |
| 53 | that keeps failing is kept, so a temporary outage does not drop it. |
| 54 | |
| 55 | ### Operator notes |
| 56 | |
| 57 | - Forge creates one VAPID key pair the first time push is used and stores it in the database. The |
| 58 | private key is sealed with the instance key (`data_dir/forge.key`). Keep both in your backups: a |
| 59 | restore that loses the VAPID key makes every device subscribe again. |
| 60 | - The VAPID contact is the `base_url` of the instance when it is an `https` URL. Behind plain HTTP |
| 61 | the contact falls back to `https://localhost`. |
| 62 | - Pushes go out from a background task and never delay the request that caused them. The server |
| 63 | makes outgoing requests to the push services, so it needs outbound HTTPS. |
| 64 | - Each account can turn push on for at most 20 devices. |
| 65 | - The service worker is served at `/sw.js`, the web app manifest at `/manifest.webmanifest`. |