Push relay
What the relay sees
Every field the push relay receives, stores and forwards to Apple and Google, with previews on and off, and what its logs contain.
This page lists exactly what passes through the push relay, what it keeps, and what Apple and
Google receive from it. It describes the code in hub/internal/platform/push.go (what the
Hub sends) and relay/ (what the relay does with it). For the overall flow, see
How push works.
The short version:
- The relay never sees your mail, your mailbox addresses or credentials, or your Hub login.
- With previews off, a push says only that something happened ("New mail") and carries IDs that let the app find the message.
- With previews on (the default), a push also carries the sender's name and address, the subject and the first words of the message. That text passes through the relay and through Apple's or Google's push service.
- The relay stores one row per registered Hub and nothing about devices or messages.
What the Hub sends #
When it registers #
Once per Hub and relay URL, POST /v1/register:
| Field | Content |
|---|---|
hubName |
Your Hub's name from Settings → Admin → Your Hub (default "Postern"). Control characters are removed and it is cut to 100 characters. |
version |
The Hub's version. Cut to 64 characters. |
The request has no user data. The relay answers with a random Hub ID and secret.
With every push #
POST /v1/push carries Authorization: Bearer <secret>, a User-Agent of
Postern-Hub/<version>, the Hub ID, and up to 100 messages, one per device:
| Field | Content |
|---|---|
platform |
ios or android. |
token |
The device's push token from Apple or Google. Needed to deliver anything. |
collapseKey |
The Hub's thread ID, so a newer notification for the same conversation replaces the older one. For notifications without a thread, the kind (for example mail). |
priority |
Always high. |
payload |
See the next table. |
The payload, field by field:
| Payload field | Previews off | Previews on (default) |
|---|---|---|
type |
mail |
mail |
title |
A generic title: "New mail", "Follow-up reminder", "A snoozed conversation is back", "A message could not be sent" or "Your mail needs attention" | The sender's name, or their address if there is no name |
subtitle |
not sent | The subject (up to 200 characters), or "(no subject)" |
body |
not sent | The first words of the message, whitespace collapsed (up to 240 characters) |
senderEmail |
not sent | The sender's address, lower case |
threadId |
The Hub's ID of the conversation (a random ID such as thr_...) |
same |
messageIdHeader |
The message's Message-ID header |
same |
badge |
not sent | not sent |
Never sent, with either setting: the full message, attachments, recipients, other headers, your mailbox addresses, mailbox credentials, your Hub's address, your account name or email, and anything about other users.
Note
messageIdHeader is sent even with previews off, so that apps that connect to your
provider directly can find the message in their own copy. A Message-ID usually looks like
<random@mail.example.com>, so it often reveals the domain of the system that sent the
mail.
A device only gets a push when the user's notification settings allow it (mode, quiet hours, mailbox choices) and notifications are turned on for that device.
What the relay does with it #
- It checks the Hub ID and secret against its database, and that the Hub is not disabled.
- It checks each message: the platform, the token format (APNs tokens must be hex), the
type, the sizes. Titles over 256 and bodies over 1024 characters are shortened. - It counts the messages against the Hub's rate limit.
- It builds the Apple or Google request (below), sends it, and returns for each message whether it was delivered and whether the token is dead.
- It adds the number of accepted messages to the Hub's counter and sets the time of the last push. These are written to the database once a minute.
Nothing about the message or the device is written anywhere. The payload exists only in memory for the time of the request.
What the relay stores #
relay.db (SQLite, in RELAY_DATA_DIR) has one table, hubs, with one row per registered
Hub:
| Column | Content |
|---|---|
id |
The random Hub ID (hub_...). |
secret_hash |
SHA-256 hash of the Hub's secret. The secret itself is never stored. |
name |
The name the Hub sent. |
version |
The version the Hub sent. |
created_at |
When it registered. |
last_push_at |
When it last pushed. |
pushes |
How many messages it has pushed in total. |
disabled |
Whether an operator disabled it. |
There is no table of devices, tokens, users or messages.
In memory only, the relay keeps rate-limit counters: one per Hub ID, and one per client IP address for registrations. They are dropped once they have refilled and are lost when the relay restarts.
Retention #
| Data | How long |
|---|---|
| Payloads and device tokens | Only while the request is being handled. |
Hub rows in relay.db |
Until the operator runs postern-relay hubs delete ID. There is no automatic expiry. |
| Rate-limit counters | In memory, until refilled or until a restart. |
| Logs | Whatever your log system keeps (journald or Docker). The relay itself writes no log files. |
| Undelivered pushes at Apple and Google | The relay asks both to drop a push after 24 hours if the phone could not be reached. |
Logs #
The relay logs to standard error. What it writes, by level:
| Level | Line | Fields |
|---|---|---|
info |
starting |
Version, listen address, registration mode, APNs host, FCM project ID, push limit. |
info |
hub registered |
Hub ID, the Hub's version. |
info |
push |
Hub ID, number of messages, delivered, unregistered, failed, milliseconds. |
warn |
push rate limited |
Hub ID, number of messages. |
warn |
request |
For server errors (5xx): method, path, status, milliseconds. |
debug |
request |
Every request: method, path, status, milliseconds. |
debug |
push failed |
Hub ID, platform, an 8-character fingerprint of the token (from its SHA-256 hash), the provider's HTTP status and reason. |
The relay never logs payloads, secrets, full device tokens, query strings or client IP addresses. A reverse proxy in front of it may log client addresses (your Hub's IP) by itself; configure that in the proxy.
The Hub logs registered with push relay (relay URL and Hub ID) and, at debug level,
relay push rejected with the error code. It never logs the payload either.
What Apple and Google see #
They receive what the relay forwards, plus what any push service sees: the relay's IP address, the time, and the device token, which they can tie to a device and an app.
Apple (iOS) #
The relay sends an HTTP/2 request to api.push.apple.com (or the sandbox host) for the
device token, signed with your APNs key:
| Header | Value |
|---|---|
apns-topic |
The app's bundle ID (APNS_TOPIC). |
apns-push-type |
alert. |
apns-priority |
10. |
apns-expiration |
24 hours from now. |
apns-collapse-id |
The collapse key (thread ID). |
The body:
| Key | Previews off | Previews on |
|---|---|---|
aps.alert.title |
Generic title ("New mail", ...) | Sender name |
aps.alert.subtitle |
none | Subject |
aps.alert.body |
none | First words |
aps.sound |
default |
default |
aps.thread-id |
Thread ID | Thread ID |
aps.category |
mail (the notification's Archive and Mark as Read buttons) |
mail |
aps.mutable-content |
1 |
1 |
type, hubId, threadId, messageIdHeader |
sent | sent |
senderEmail |
none | Sender's address |
mutable-content lets the app's notification extension change the notification before it
is shown. With previews on, it uses senderEmail to show the sender's picture: a photo from
the phone's contacts if there is one, otherwise the icon of the sender's domain, which it
loads from DuckDuckGo's icon service (icons.duckduckgo.com). Only the domain name leaves the
phone for that, and not for addresses on public mail services such as gmail.com. With
previews off, there is no sender address and no lookup.
Google (Android) #
The relay sends a Firebase Cloud Messaging v1 request for your Firebase project:
| Field | Previews off | Previews on |
|---|---|---|
notification.title |
Generic title | Sender name |
notification.body |
none | First words |
data.type, data.hubId, data.threadId |
sent | sent |
data.title, data.body |
data.title only |
both |
android.priority |
HIGH |
HIGH |
android.collapse_key, android.notification.tag |
Collapse key | Collapse key |
android.ttl |
86400s (24 hours) |
86400s |
The subject, senderEmail and messageIdHeader are not passed to Google. On Android a
notification with previews shows the sender and the first words, but not the subject.
How to send them less #
- Turn off previews: web app Settings → Notifications → Show sender and subject on phones, or mobile app Settings → Notifications → Show previews on phones. The setting applies to all your phones.
- Turn off notifications for a device: Settings → Notifications → Notifications in the mobile app. The device's token is then removed from the Hub.
- Do not set
POSTERN_RELAY_URLat all. Then nothing goes to a relay, Apple or Google, and phones show new mail only when you open the app.
What the Hub stores for push #
For completeness: the device tokens live on your Hub, in the push_registrations table of
hub.db (device, user, kind, token, platform). They are not encrypted at the application
level; see Encryption at rest. The relay's secret is stored
encrypted with the Hub's master key.