Skip to content

Commit

Permalink
feat(ext): DeleteMessages support private chats
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisin0 committed Oct 28, 2024
1 parent cc44bb2 commit 7cf3a58
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions ext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func (ctx *Context) DeleteMessages(chatId int64, messageIDs []int) error {
return mtp_errors.ErrPeerNotFound
}
switch storage.EntityType(peer.Type) {
case storage.TypeChat:
case storage.TypeChat, storage.TypeUser:
_, err := ctx.Raw.MessagesDeleteMessages(ctx, &tg.MessagesDeleteMessagesRequest{
Revoke: true,
ID: messageIDs,
Expand All @@ -584,8 +584,6 @@ func (ctx *Context) DeleteMessages(chatId int64, messageIDs []int) error {
ID: messageIDs,
})
return err
case storage.TypeUser:
return mtp_errors.ErrNotChat
default:
return mtp_errors.ErrPeerNotFound
}
Expand Down Expand Up @@ -618,19 +616,19 @@ func (ctx *Context) ForwardMessages(fromChatId, toChatId int64, request *tg.Mess
request.RandomID[i] = ctx.generateRandomID()
}
return ctx.Raw.MessagesForwardMessages(ctx, &tg.MessagesForwardMessagesRequest{
RandomID: request.RandomID,
ID: request.ID,
FromPeer: fromPeer,
ToPeer: toPeer,
DropAuthor: request.DropAuthor,
Silent: request.Silent,
Background: request.Background,
WithMyScore: request.WithMyScore,
DropMediaCaptions: request.DropMediaCaptions,
Noforwards: request.Noforwards,
TopMsgID: request.TopMsgID,
ScheduleDate: request.ScheduleDate,
SendAs: request.SendAs,
RandomID: request.RandomID,
ID: request.ID,
FromPeer: fromPeer,
ToPeer: toPeer,
DropAuthor: request.DropAuthor,
Silent: request.Silent,
Background: request.Background,
WithMyScore: request.WithMyScore,
DropMediaCaptions: request.DropMediaCaptions,
Noforwards: request.Noforwards,
TopMsgID: request.TopMsgID,
ScheduleDate: request.ScheduleDate,
SendAs: request.SendAs,
QuickReplyShortcut: request.QuickReplyShortcut,
})
}
Expand Down

0 comments on commit 7cf3a58

Please sign in to comment.