- Enhanced GetFeedDetail method to support loading all comments based on the new loadAllComments parameter. - Updated related handlers and request structures to accommodate the new parameter. - Improved logging to reflect the loading of all comments during feed detail retrieval. - Implemented JavaScript logic to scroll and collect comments when loadAllComments is true.
99 lines
2.8 KiB
Go
99 lines
2.8 KiB
Go
package main
|
|
|
|
import "github.com/xpzouying/xiaohongshu-mcp/xiaohongshu"
|
|
|
|
// HTTP API 响应类型
|
|
|
|
// ErrorResponse 错误响应
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Code string `json:"code"`
|
|
Details any `json:"details,omitempty"`
|
|
}
|
|
|
|
// SuccessResponse 成功响应
|
|
type SuccessResponse struct {
|
|
Success bool `json:"success"`
|
|
Data any `json:"data"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
// MCP 相关类型(用于内部转换)
|
|
|
|
// MCPToolResult MCP 工具结果(内部使用)
|
|
type MCPToolResult struct {
|
|
Content []MCPContent `json:"content"`
|
|
IsError bool `json:"isError,omitempty"`
|
|
}
|
|
|
|
// MCPContent MCP 内容(内部使用)
|
|
type MCPContent struct {
|
|
Type string `json:"type"`
|
|
Text string `json:"text"`
|
|
MimeType string `json:"mimeType"`
|
|
Data string `json:"data"`
|
|
}
|
|
|
|
// FeedDetailRequest Feed详情请求
|
|
type FeedDetailRequest struct {
|
|
FeedID string `json:"feed_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
LoadAllComments bool `json:"load_all_comments,omitempty"`
|
|
}
|
|
|
|
type SearchFeedsRequest struct {
|
|
Keyword string `json:"keyword" binding:"required"`
|
|
Filters xiaohongshu.FilterOption `json:"filters,omitempty"`
|
|
}
|
|
|
|
// FeedDetailResponse Feed详情响应
|
|
type FeedDetailResponse struct {
|
|
FeedID string `json:"feed_id"`
|
|
Data any `json:"data"`
|
|
}
|
|
|
|
// PostCommentRequest 发表评论请求
|
|
type PostCommentRequest struct {
|
|
FeedID string `json:"feed_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
Content string `json:"content" binding:"required"`
|
|
}
|
|
|
|
// PostCommentResponse 发表评论响应
|
|
type PostCommentResponse struct {
|
|
FeedID string `json:"feed_id"`
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// ReplyCommentRequest 回复评论请求
|
|
type ReplyCommentRequest struct {
|
|
FeedID string `json:"feed_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
CommentID string `json:"comment_id" binding:"required_without=UserID"`
|
|
UserID string `json:"user_id" binding:"required_without=CommentID"`
|
|
Content string `json:"content" binding:"required"`
|
|
}
|
|
|
|
// ReplyCommentResponse 回复评论响应
|
|
type ReplyCommentResponse struct {
|
|
FeedID string `json:"feed_id"`
|
|
TargetCommentID string `json:"target_comment_id,omitempty"`
|
|
TargetUserID string `json:"target_user_id,omitempty"`
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// UserProfileRequest 用户主页请求
|
|
type UserProfileRequest struct {
|
|
UserID string `json:"user_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
}
|
|
|
|
// ActionResult 通用动作响应(点赞/收藏等)
|
|
type ActionResult struct {
|
|
FeedID string `json:"feed_id"`
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|