Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Message struct {
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"`
Quote *TextQuote `json:"quote,omitempty"`
ReplyToStore *Story `json:"reply_to_store,omitempty"`
ReplyToStory *Story `json:"reply_to_story,omitempty"`
ReplyToChecklistTaskID int `json:"reply_to_checklist_task_id,omitempty"`
ViaBot *User `json:"via_bot,omitempty"`
EditDate int `json:"edit_date,omitempty"`
Expand Down
26 changes: 25 additions & 1 deletion models/message_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package models

import "testing"
import (
"encoding/json"
"testing"
)

func TestUnmarshalMaybeInaccessibleMessage_inaccessible(t *testing.T) {
src := `{"date":0,"chat":{"id":123},"message_id":987}`
Expand Down Expand Up @@ -53,3 +56,24 @@ func TestUnmarshalMaybeInaccessibleMessage_message(t *testing.T) {
t.Fatal("wrong message id")
}
}

func TestUnmarshalMessage_replyToStory(t *testing.T) {
src := `{"date":0,"chat":{"id":123},"message_id":987,"reply_to_story":{"chat":{"id":42},"id":7}}`

msg := Message{}
if err := json.Unmarshal([]byte(src), &msg); err != nil {
t.Fatal(err)
}

if msg.ReplyToStory == nil {
t.Fatal("ReplyToStory is nil")
}

if msg.ReplyToStory.ID != 7 {
t.Fatal("wrong story id")
}

if msg.ReplyToStory.Chat.ID != 42 {
t.Fatal("wrong story chat id")
}
}