From c77ac77e78268bc2f4265a872b213d4300b3eb66 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sun, 2 Feb 2025 19:23:50 +0200 Subject: Added support for offline notifications where the server calculates them and sends the info to the client when it connects --- internal/server/api/api.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/server/api/api.go') 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 +} -- cgit v1.3.1