diff --git a/pkg/internal/grpc/stream.go b/pkg/internal/grpc/stream.go index 25dc861..f2a105f 100644 --- a/pkg/internal/grpc/stream.go +++ b/pkg/internal/grpc/stream.go @@ -18,7 +18,7 @@ func (v *Server) EmitStreamEvent(_ context.Context, in *proto.StreamEventRequest switch in.GetEvent() { case "status.typing": var data struct { - ChannelID uint `json:"channel_id"` + ChannelID uint `json:"channel_id" validate:"required"` } err := jsoniter.Unmarshal(in.GetPayload(), &data) @@ -26,7 +26,7 @@ func (v *Server) EmitStreamEvent(_ context.Context, in *proto.StreamEventRequest err = exts.ValidateStruct(data) } if err != nil { - sc.PushStream(context.Background(), &proto.PushStreamRequest{ + _, _ = sc.PushStream(context.Background(), &proto.PushStreamRequest{ ClientId: &in.ClientId, Body: hyper.NetworkPackage{ Action: "error", @@ -37,7 +37,7 @@ func (v *Server) EmitStreamEvent(_ context.Context, in *proto.StreamEventRequest err = services.SetTypingStatus(data.ChannelID, uint(in.GetUserId())) if err != nil { - sc.PushStream(context.Background(), &proto.PushStreamRequest{ + _, _ = sc.PushStream(context.Background(), &proto.PushStreamRequest{ ClientId: &in.ClientId, Body: hyper.NetworkPackage{ Action: "error", diff --git a/pkg/internal/services/status.go b/pkg/internal/services/status.go index 4137001..a0194bc 100644 --- a/pkg/internal/services/status.go +++ b/pkg/internal/services/status.go @@ -13,13 +13,13 @@ import ( func SetTypingStatus(channelId uint, userId uint) error { var account models.Account - if err := database.C.Where("id = ?", userId).First(&account).Error; err != nil { + if err := database.C.Where("external_id = ?", userId).First(&account).Error; err != nil { return fmt.Errorf("account not found: %v", err) } var member models.ChannelMember if err := database.C. - Where("account_id = ? AND channel_id = ?", userId, channelId). + Where("account_id = ? AND channel_id = ?", account.ID, channelId). First(&member).Error; err != nil { return fmt.Errorf("channel member not found: %v", err) } else { @@ -34,17 +34,17 @@ func SetTypingStatus(channelId uint, userId uint) error { return fmt.Errorf("channel not found: %v", err) } - var boardcastTarget []uint64 + var broadcastTarget []uint64 for _, item := range channel.Members { if item.AccountID == member.AccountID { continue } - boardcastTarget = append(boardcastTarget, uint64(item.AccountID)) + broadcastTarget = append(broadcastTarget, uint64(item.AccountID)) } sc := proto.NewStreamControllerClient(gap.H.GetDealerGrpcConn()) _, err := sc.PushStreamBatch(context.Background(), &proto.PushStreamBatchRequest{ - UserId: boardcastTarget, + UserId: broadcastTarget, Body: hyper.NetworkPackage{ Action: "status.typing", Payload: map[string]any{