Skip to content

Commit

Permalink
fix lint errors and regenerate generic package
Browse files Browse the repository at this point in the history
  • Loading branch information
celestix committed Jan 15, 2025
1 parent 8789cb6 commit 443253b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func (ctx *Context) extractContactResolvedPeer(p *tg.ContactsResolvedPeer, err e
functions.SavePeersFromClassArray(ctx.PeerStorage, p.Chats, p.Users)
switch p.Peer.(type) {
case *tg.PeerChannel:
if p.Chats == nil || len(p.Chats) == 0 {
if len(p.Chats) == 0 {
return &types.EmptyUC{}, errors.New("peer info not found in the resolved Chats")
}
switch chat := p.Chats[0].(type) {
Expand All @@ -704,7 +704,7 @@ func (ctx *Context) extractContactResolvedPeer(p *tg.ContactsResolvedPeer, err e
return &types.EmptyUC{}, errors.New("peer could not be resolved because Channel Forbidden")
}
case *tg.PeerUser:
if p.Users == nil || len(p.Users) == 0 {
if len(p.Users) == 0 {
return &types.EmptyUC{}, errors.New("peer info not found in the resolved Chats")
}
switch user := p.Users[0].(type) {
Expand Down Expand Up @@ -814,8 +814,8 @@ func (ctx *Context) DownloadMedia(media tg.MessageMediaClass, downloadOutput Dow
return downloadOutput.run(ctx, d)
}

func (ctx *Context) TransferStarGift(msgId int, toId int64) (tg.UpdatesClass, error) {
peerUser := ctx.PeerStorage.GetPeerById(toId)
func (ctx *Context) TransferStarGift(chatId int64, msgId int) (tg.UpdatesClass, error) {
peerUser := ctx.PeerStorage.GetPeerById(chatId)
if peerUser == nil {
return nil, mtp_errors.ErrPeerNotFound
}
Expand Down
11 changes: 11 additions & 0 deletions generic/gen_cu.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,14 @@ func GetUserProfilePhotos[chatUnion ChatUnion](ctx *ext.Context, user chatUnion,

return ctx.GetUserProfilePhotos(userId, opts)
}

// TransferStarGift is a generic helper for ext.Context.TransferStarGift method.
func TransferStarGift[chatUnion ChatUnion](ctx *ext.Context, chat chatUnion, msgId int) (tg.UpdatesClass, error) {

chatId, err := getIdByUnion(ctx, chat)
if err != nil {
return nil, err
}

return ctx.TransferStarGift(chatId, msgId)
}

0 comments on commit 443253b

Please sign in to comment.