Skip to content

Commit

Permalink
fix(api): fix participants count fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Apr 18, 2024
1 parent 78a9e89 commit c9c7bad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/go-faster/errors v0.7.1
github.com/go-faster/jx v1.1.0
github.com/go-faster/sdk v0.13.0
github.com/go-telegram/bot v1.2.1
github.com/google/go-github/v52 v52.0.0
github.com/google/uuid v1.6.0
github.com/gotd/contrib v0.19.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
github.com/go-openapi/inflect v0.21.0 h1:FoBjBTQEcbg2cJUWX6uwL9OyIW8eqc9k4KhN4lfbeYk=
github.com/go-openapi/inflect v0.21.0/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw=
github.com/go-telegram/bot v1.2.1 h1:FkrixLCtMtPUQAN4plXdNElbhkdXkx2p68YPXKBruDg=
github.com/go-telegram/bot v1.2.1/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand Down
19 changes: 2 additions & 17 deletions internal/api/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,10 @@ func (s Server) GetTelegramBadge(ctx context.Context, params oas.GetTelegramBadg
if err != nil {
return nil, errors.Wrap(err, "get chat")
}
chanFull := full.FullChat.(*tg.ChannelFull)
members = full.FullChat.(*tg.ChannelFull).ParticipantsCount
s.lg.Info("Got chat",
zap.Int("chats", len(full.Chats)),
zap.Int64("id", chanFull.ID),
zap.String("about", chanFull.About),
zap.Int("participants", members),
)
for _, chat := range full.Chats {
s.lg.Info("Chat", zap.Any("chat", chat))
switch c := chat.(type) {
case *tg.Chat:
members = c.ParticipantsCount
case *tg.Channel:
members = c.ParticipantsCount
default:
s.lg.Warn("Unexpected chat type",
zap.String("type", fmt.Sprintf("%T", chat)),
)
}
}
}
var (
title = params.Title.Or(params.GroupName)
Expand Down

0 comments on commit c9c7bad

Please sign in to comment.