fix unmarshalling MessageOrigin senderChat info for channels
This commit is contained in:
parent
c88341ccc3
commit
936966ac6d
1 changed files with 18 additions and 0 deletions
18
types.go
18
types.go
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue