fix unmarshalling MessageOrigin senderChat info for channels

This commit is contained in:
dmekhov 2024-03-04 21:22:58 +03:00
parent c88341ccc3
commit 936966ac6d

View file

@ -1191,6 +1191,24 @@ func (m MessageOrigin) IsChannel() bool {
return m.Type == MessageOriginChannel return m.Type == MessageOriginChannel
} }
func (m *MessageOrigin) UnmarshalJSON(data []byte) error {
type Alias MessageOrigin
aux := &struct {
Chat *Chat `json:"chat,omitempty"`
*Alias
}{
Alias: (*Alias)(m),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if m.IsChannel() {
// MessageOriginChannel struct has Chat struct in chat field and MessageOriginChat in sender_chat
m.SenderChat = aux.Chat
}
return nil
}
// PhotoSize represents one size of a photo or a file / sticker thumbnail. // PhotoSize represents one size of a photo or a file / sticker thumbnail.
type PhotoSize struct { type PhotoSize struct {
// FileID identifier for this file, which can be used to download or reuse // FileID identifier for this file, which can be used to download or reuse