From 590b53e3c9405a9d884ea258d067b3b36e742754 Mon Sep 17 00:00:00 2001 From: Mike Chetverikov Date: Sun, 5 Jul 2026 12:53:00 +0100 Subject: [PATCH] fix: message struct - correct reply_to_story field name and json tag The field for the Bot API `reply_to_story` was declared as `ReplyToStore` with a `json:"reply_to_store"` tag (typo: "store" instead of "story"), so Telegram's `reply_to_story` was never unmarshalled into the struct. Rename the field to `ReplyToStory` and fix the tag to `reply_to_story`. Add an unmarshal test covering the field. Co-Authored-By: Claude Opus 4.8 (1M context) --- models/message.go | 2 +- models/message_test.go | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/models/message.go b/models/message.go index 8632c69..a1b9444 100644 --- a/models/message.go +++ b/models/message.go @@ -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"` diff --git a/models/message_test.go b/models/message_test.go index e33580c..5a54fc3 100644 --- a/models/message_test.go +++ b/models/message_test.go @@ -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}` @@ -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") + } +}