refactor: enhance reply comment functionality with improved error handling and response structure
- Simplified error handling in handleReplyComment to check for both comment_id and user_id simultaneously. - Updated response message to include both Comment ID and User ID upon successful reply. - Modified ReplyCommentArgs struct to make comment_id and user_id optional. - Renamed MCP tool for replying to comments for clarity.
This commit is contained in:
14
service.go
14
service.go
@@ -443,8 +443,8 @@ func (s *XiaohongshuService) UnfavoriteFeed(ctx context.Context, feedID, xsecTok
|
||||
return &ActionResult{FeedID: feedID, Success: true, Message: "取消收藏成功或未收藏"}, nil
|
||||
}
|
||||
|
||||
// ReplyCommentToFeed 回复笔记评论
|
||||
func (s *XiaohongshuService) ReplyCommentToFeed(ctx context.Context, feedID, xsecToken, commentID, userID, content string) (*ActionResult, error) {
|
||||
// ReplyCommentToFeed 回复指定评论
|
||||
func (s *XiaohongshuService) ReplyCommentToFeed(ctx context.Context, feedID, xsecToken, commentID, userID, content string) (*ReplyCommentResponse, error) {
|
||||
b := newBrowser()
|
||||
defer b.Close()
|
||||
|
||||
@@ -452,10 +452,18 @@ func (s *XiaohongshuService) ReplyCommentToFeed(ctx context.Context, feedID, xse
|
||||
defer page.Close()
|
||||
|
||||
action := xiaohongshu.NewCommentFeedAction(page)
|
||||
|
||||
if err := action.ReplyToComment(ctx, feedID, xsecToken, commentID, userID, content); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ActionResult{FeedID: feedID, Success: true, Message: "回复评论成功"}, nil
|
||||
|
||||
return &ReplyCommentResponse{
|
||||
FeedID: feedID,
|
||||
TargetCommentID: commentID,
|
||||
TargetUserID: userID,
|
||||
Success: true,
|
||||
Message: "评论回复成功",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func newBrowser() *headless_browser.Browser {
|
||||
|
||||
Reference in New Issue
Block a user