summaryrefslogtreecommitdiff
path: root/internal/server/api/api.go
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-02-02 19:23:50 +0200
committerKyren223 <Kyren223@proton.me>2025-02-02 19:23:50 +0200
commitc77ac77e78268bc2f4265a872b213d4300b3eb66 (patch)
tree1c2f1be6f2c7a724486d24b0c83014032e761f49 /internal/server/api/api.go
parenta1c20cbfc5a90642e486132d4673646342df13fd (diff)
Added support for offline notifications where the server calculates them
and sends the info to the client when it connects
Diffstat (limited to 'internal/server/api/api.go')
-rw-r--r--internal/server/api/api.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/server/api/api.go b/internal/server/api/api.go
index 3fff656..60e873e 100644
--- a/internal/server/api/api.go
+++ b/internal/server/api/api.go
@@ -1246,3 +1246,24 @@ func GetBannedMembers(ctx context.Context, sess *session.Session, request *packe
Network: request.Network,
}
}
+
+func GetNotifications(ctx context.Context, sess *session.Session, request *packet.GetNotifications) packet.Payload {
+ if len(request.Source) != len(request.LastReadId) {
+ return &packet.Error{Error: "source length and lastReadId length must match"}
+ }
+
+ if len(request.Source) == 0 {
+ return &packet.NotificationsInfo{
+ Source: []snowflake.ID{},
+ Pings: []*int64{},
+ }
+ }
+
+ info, err := getNotifications(ctx, request, sess.ID())
+ if err != nil {
+ log.Println("database error:", err)
+ return &ErrInternalError
+ }
+
+ return &info
+}