Skip to content

Feat: Add Web Push support#53

Merged
link2xt merged 11 commits intochatmail:mainfrom
p1gp1g:webpush
Mar 5, 2026
Merged

Feat: Add Web Push support#53
link2xt merged 11 commits intochatmail:mainfrom
p1gp1g:webpush

Conversation

@p1gp1g
Copy link
Contributor

@p1gp1g p1gp1g commented Mar 5, 2026

This PR adds web push support. It allows Android and Linux clients to use UnifiedPush, and potential web apps to use the browser push service. I'm opening a PR to DeltaChat android client right after this one.

I have also updated the README, it missed some doc about the current cli arguments.

If you want to try a local notifier without setting up FCM and APNS, I've a branch (https://github.com/p1gp1g/chatmail-notifiers/tree/dev) where they are behind a config flag (8015980). If you want I can open a PR with the code for the flags, and I can put webpush behind another one

I will add a few comments on the PR

)?,
Auth::clone_from_slice(&base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(ua_auth)?),
)
.with_vapid(vapid_key, "https://github.com/chatmail/notifiers/issues")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is RFC8292 contact info ("sub" field), in case something goes wrong and a push service (e.g. Mozilla) wants to inform you about the bug

Auth::clone_from_slice(&base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(ua_auth)?),
)
.with_vapid(vapid_key, "https://github.com/chatmail/notifiers/issues")
.build("ping")?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We send a simple "ping" message. This message is encrypted with the client keys, but it isn't relevant as it doesn't contain any usable data

.build("ping")?;

let res = client
.post(endpoint)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we do a POST. We do not control if the endpoint resolve to a private IP - which would be a problem for a server hosted in a private network, or with other services on the machine.

If this is a problem for you, I can easily update the function to first do the DNS resolution, then filter out private IPs, disable redirections, and do the request (e.g. what I did for mollysocket: https://github.com/mollyim/mollysocket/blob/main/src/utils/post_allowed.rs). Just let me know

// Map web push responses to chatmail/relay notifier values
match status.as_u16() {
201 => Ok(StatusCode::OK),
404 | 403 | 401 => Ok(StatusCode::GONE),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid modifying chatmail/relay

schedule: Schedule,

fcm_client: reqwest::Client,
http_client: reqwest::Client,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now used by FCM, UBport and Web Push - I think it is better renaming it

http_client: reqwest::Client,

production_client: Client,
apns_production_client: Client,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be named when notifiers was only about apns. I think apns prefix makes things more clear to read today

@link2xt
Copy link
Contributor

link2xt commented Mar 5, 2026

Clippy lint failure is from main, I have fixed it in #54 so can be fixed with rebase but not necessary.

@p1gp1g
Copy link
Contributor Author

p1gp1g commented Mar 5, 2026

Thanks, I've rebased the PR 👍

Copy link
Contributor

@link2xt link2xt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise looks good, we can deploy it quite easily for testing once Android PR is ready.

@p1gp1g
Copy link
Contributor Author

p1gp1g commented Mar 5, 2026

I'm pushing your suggestions

The PR for Android is here: deltachat/deltachat-android#4251 - we will need notifiers VAPID public key there :)

@link2xt link2xt merged commit eded3d1 into chatmail:main Mar 5, 2026
1 check passed
registry.register(
"webpush_notifications",
"Number of web push notifications",
ubports_notifications_total.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste error, fixed in #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants