fix new all command

This commit is contained in:
2022-04-25 03:11:23 +07:00
parent 3e0bfc433b
commit 292888ce9c
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -10,6 +10,10 @@ import (
)
type chatDTO struct {
ChatID int64 `bson:"chat_id"`
}
type chatInfoDTO struct {
ChatID int64 `bson:"chat_id"`
Users []string `bson:"users"`
}
@@ -77,9 +81,9 @@ func GetUsers(chatID int64) ([]string, error) {
}
collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName)
chatDTO := &chatDTO{}
if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatDTO); err != nil {
chatInfoDTO := &chatInfoDTO{}
if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatInfoDTO); err != nil {
return nil, err
}
return chatDTO.Users, err
return chatInfoDTO.Users, err
}