Initial commit

This commit is contained in:
Ilya Groshev
2026-04-14 09:28:26 +03:00
commit 02f511f40c
161 changed files with 21541 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package service
import (
"context"
"log"
pb "lunar-tear/server/gen/proto"
"lunar-tear/server/internal/store"
"lunar-tear/server/internal/userdata"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
type NotificationServiceServer struct {
pb.UnimplementedNotificationServiceServer
users store.UserRepository
sessions store.SessionRepository
}
func NewNotificationServiceServer(users store.UserRepository, sessions store.SessionRepository) *NotificationServiceServer {
return &NotificationServiceServer{users: users, sessions: sessions}
}
func (s *NotificationServiceServer) GetHeaderNotification(ctx context.Context, req *emptypb.Empty) (*pb.GetHeaderNotificationResponse, error) {
log.Printf("[NotificationService] GetHeaderNotification")
userId := currentUserId(ctx, s.users, s.sessions)
user, err := s.users.SnapshotUser(userId)
if err != nil {
return &pb.GetHeaderNotificationResponse{
GiftNotReceiveCount: 0,
FriendRequestReceiveCount: 0,
IsExistUnreadInformation: false,
DiffUserData: userdata.EmptyDiff(),
}, nil
}
return &pb.GetHeaderNotificationResponse{
GiftNotReceiveCount: int32(len(user.Gifts.NotReceived)),
FriendRequestReceiveCount: user.Notifications.FriendRequestReceiveCount,
IsExistUnreadInformation: user.Notifications.IsExistUnreadInformation,
DiffUserData: userdata.EmptyDiff(),
}, nil
}