2024-07-20 11:58:54 +00:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-10-23 16:13:16 +00:00
|
|
|
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
|
|
|
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
2024-10-31 12:38:50 +00:00
|
|
|
"git.solsynth.dev/hypernet/passport/pkg/internal/services"
|
2024-12-03 13:24:16 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2024-07-20 11:58:54 +00:00
|
|
|
)
|
|
|
|
|
2024-10-27 04:50:07 +00:00
|
|
|
func (v *App) BroadcastEvent(ctx context.Context, request *proto.EventInfo) (*proto.EventResponse, error) {
|
2024-07-20 11:58:54 +00:00
|
|
|
switch request.GetEvent() {
|
2024-10-23 16:13:16 +00:00
|
|
|
case "ws.client.register":
|
2024-07-20 11:58:54 +00:00
|
|
|
// No longer need update user online status
|
|
|
|
// Based on realtime sever connection status
|
|
|
|
break
|
2024-10-23 16:13:16 +00:00
|
|
|
case "ws.client.unregister":
|
2024-07-20 11:58:54 +00:00
|
|
|
// Update user last seen at
|
2024-10-23 16:13:16 +00:00
|
|
|
data := nex.DecodeMap(request.GetData())
|
2024-12-03 13:24:16 +00:00
|
|
|
err := services.SetAccountLastSeen(uint(data["user"].(float64)))
|
|
|
|
log.Debug().Err(err).Any("event", data).Msg("Setting account last seen...")
|
2024-07-20 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2024-10-23 16:13:16 +00:00
|
|
|
return &proto.EventResponse{}, nil
|
2024-07-20 11:58:54 +00:00
|
|
|
}
|