v.0.0.2.4 Внесены правки в StreamMessages для исправления паники преобразования числовых значений из JSON в int32
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
458c5a9dad
commit
a2b3fa4ad0
29
server.go
29
server.go
@ -356,15 +356,28 @@ func (s *server) StreamMessages(req *proto.StreamMessagesRequest, stream proto.M
|
||||
continue
|
||||
}
|
||||
|
||||
// Преобразуем обратно в proto.Message
|
||||
createdAt, _ := time.Parse(time.RFC3339Nano, msgData["createdAt"].(string))
|
||||
// Безопасное преобразование типов
|
||||
id, _ := msgData["id"].(float64)
|
||||
chatId, _ := msgData["chatId"].(float64)
|
||||
senderId, _ := msgData["senderId"].(float64)
|
||||
receiverId, _ := msgData["receiverId"].(float64)
|
||||
content, _ := msgData["content"].(string)
|
||||
status, _ := msgData["status"].(string)
|
||||
createdAtStr, _ := msgData["createdAt"].(string)
|
||||
|
||||
createdAt, err := time.Parse(time.RFC3339Nano, createdAtStr)
|
||||
if err != nil {
|
||||
log.Printf("Failed to parse createdAt: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
msg := &proto.Message{
|
||||
Id: msgData["id"].(int32),
|
||||
ChatId: msgData["chatId"].(int32),
|
||||
SenderId: msgData["senderId"].(int32),
|
||||
ReceiverId: msgData["receiverId"].(int32),
|
||||
Content: msgData["content"].(string),
|
||||
Status: msgData["status"].(string),
|
||||
Id: int32(id),
|
||||
ChatId: int32(chatId),
|
||||
SenderId: int32(senderId),
|
||||
ReceiverId: int32(receiverId),
|
||||
Content: content,
|
||||
Status: status,
|
||||
CreatedAt: timestamppb.New(createdAt),
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user