Skip to content

Commit 4e03c91

Browse files
committed
Add more push gateway types
1 parent cbeaaf9 commit 4e03c91

File tree

1 file changed

+65
-4
lines changed

1 file changed

+65
-4
lines changed

pushrules/pushgateway/gateway.go

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
type NotificationCounts struct {
2323
MissedCalls int `json:"missed_calls,omitempty"`
2424
Unread int `json:"unread,omitempty"`
25+
26+
BeeperServerType string `json:"com.beeper.server_type,omitempty"`
27+
BeeperAsOfToken string `json:"com.beeper.as_of_token,omitempty"`
2528
}
2629

2730
type PushPriority string
@@ -31,11 +34,69 @@ const (
3134
PushPriorityLow PushPriority = "low"
3235
)
3336

37+
type PushFormat string
38+
39+
const (
40+
PushFormatDefault PushFormat = ""
41+
PushFormatEventIDOnly PushFormat = "event_id_only"
42+
)
43+
44+
type PusherData map[string]any
45+
46+
func (pd PusherData) Format() PushFormat {
47+
val, _ := pd["format"].(string)
48+
return PushFormat(val)
49+
}
50+
51+
func (pd PusherData) URL() string {
52+
val, _ := pd["url"].(string)
53+
return val
54+
}
55+
56+
// ConvertToNotificationData returns a copy of the map with the url and format fields removed.
57+
func (pd PusherData) ConvertToNotificationData() PusherData {
58+
pdCopy := make(PusherData, len(pd)-2)
59+
for key, value := range pd {
60+
if key != "format" && key != "url" {
61+
pdCopy[key] = value
62+
}
63+
}
64+
return pdCopy
65+
}
66+
67+
type PusherKind string
68+
69+
const (
70+
PusherKindHTTP PusherKind = "http"
71+
PusherKindEmail PusherKind = "email"
72+
)
73+
74+
type PusherAppID string
75+
76+
const (
77+
PusherAppEmail PusherAppID = "m.email"
78+
)
79+
80+
type Pusher struct {
81+
AppDisplayName string `json:"app_display_name"`
82+
AppID PusherAppID `json:"app_id"`
83+
Data PusherData `json:"data"`
84+
DeviceDisplayName string `json:"device_display_name"`
85+
Kind *PusherKind `json:"kind"`
86+
Language string `json:"lang"`
87+
ProfileTag string `json:"profile_tag,omitempty"`
88+
PushKey string `json:"pushkey"`
89+
}
90+
91+
type RespPushers struct {
92+
Pushers []Pusher `json:"pushers"`
93+
}
94+
3495
type BaseDevice struct {
35-
AppID string `json:"app_id"`
36-
PushKey string `json:"pushkey"`
37-
PushKeyTS int64 `json:"pushkey_ts,omitempty"`
38-
Data map[string]any `json:"data,omitempty"`
96+
AppID PusherAppID `json:"app_id"`
97+
PushKey string `json:"pushkey"`
98+
PushKeyTS int64 `json:"pushkey_ts,omitempty"`
99+
Data PusherData `json:"data,omitempty"`
39100
}
40101

41102
type PushKey struct {

0 commit comments

Comments
 (0)