Antonio Mika
·
2026-03-27
1diff --git a/downstream.go b/downstream.go
2index b627450..b845ecd 100644
3--- a/downstream.go
4+++ b/downstream.go
5@@ -3341,6 +3341,9 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
6 network.pushTargets.Del(target)
7 }
8 go network.broadcastWebPush(&irc.Message{
9+ Tags: irc.Tags{
10+ "bouncerNetwork": strconv.FormatInt(dc.network.ID, 10),
11+ },
12 Command: "MARKREAD",
13 Params: []string{target, timestampStr},
14 })
15@@ -3694,6 +3697,10 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
16 }}
17 }
18
19+ if filterCommands, filterCommandExists := rawKeys["filterCommands"]; filterCommandExists {
20+ endpoint = fmt.Sprintf("%s;%s", endpoint, filterCommands)
21+ }
22+
23 newSub := database.WebPushSubscription{
24 Endpoint: endpoint,
25 }
26diff --git a/server.go b/server.go
27index f1f56d7..81c8bd6 100644
28--- a/server.go
29+++ b/server.go
30@@ -10,6 +10,7 @@ import (
31 "net/http"
32 "net/netip"
33 "runtime/debug"
34+ "strings"
35 "sync"
36 "sync/atomic"
37 "syscall"
38@@ -340,6 +341,15 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
39 ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
40 defer cancel()
41
42+ if strings.Contains(sub.Endpoint, ";") {
43+ parts := strings.Split(sub.Endpoint, ";")
44+ sub.Endpoint = parts[0]
45+
46+ if !strings.Contains(parts[1], msg.Command) {
47+ return nil
48+ }
49+ }
50+
51 var urgency webpush.Urgency
52 switch msg.Command {
53 case "PRIVMSG", "NOTICE", "INVITE":
54@@ -352,7 +362,7 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
55 HTTPClient: webPushHTTPClient,
56 VAPIDPublicKey: s.webPush.VAPIDKeys.Public,
57 VAPIDPrivateKey: s.webPush.VAPIDKeys.Private,
58- Subscriber: "https://soju.im",
59+ Subscriber: "hello@pico.sh",
60 TTL: 7 * 24 * 60 * 60, // seconds
61 Urgency: urgency,
62 RecordSize: 2048,
63diff --git a/upstream.go b/upstream.go
64index 37cf508..8f6ff03 100644
65--- a/upstream.go
66+++ b/upstream.go
67@@ -771,6 +771,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
68 }
69
70 if sendWebPush {
71+ msg.Tags["bouncerNetwork"] = strconv.FormatInt(uc.network.ID, 10)
72 timestamp, err := time.Parse(xirc.ServerTimeLayout, msg.Tags["time"])
73 if err != nil {
74 // Cannot fail, was set above if unset or invalid.
75@@ -1760,6 +1761,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
76 })
77
78 if weAreInvited {
79+ msg.Tags["bouncerNetwork"] = strconv.FormatInt(uc.network.ID, 10)
80 go uc.network.broadcastWebPush(msg)
81 }
82 case irc.RPL_INVITING: