-
Notifications
You must be signed in to change notification settings - Fork 92
feat(message): support refer msg #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduce support for referencing messages within the message payload structure by adding a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Message
participant MessagePayloadBase
participant ReferMessagePayload
User->>Message: Call ReferMessage()
Message->>MessagePayloadBase: Access ReferMessage field
alt ReferMessage is not nil
MessagePayloadBase->>ReferMessagePayload: Provide referenced message details
Message-->>User: Return copy of ReferMessagePayload
else ReferMessage is nil
Message-->>User: Return nil
end
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Changes requested ❌
Reviewed everything up to 6c6405c in 1 minute and 22 seconds. Click for details.
- Reviewed
52lines of code in3files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. wechaty-puppet/schemas/message.go:100
- Draft comment:
Ensure the TODO about ReferMessagePayload.Type is resolved: Verify if it should match MessageType exactly. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%<= threshold50%The comment is asking the author to ensure that a TODO is resolved and to verify if a certain type should match another exactly. This is asking the author to double-check something, which violates the rules.
Workflow ID: wflow_Jk1vXcp1xicLl9Uk
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
wechaty/user/message.go
Outdated
| } | ||
|
|
||
| func (m *Message) ReferMessage() *schemas.ReferMessagePayload { | ||
| return &(*m.payload.ReferMessage) // 不希望能被修改原数据 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dereferencing m.payload.ReferMessage without a nil check may cause a panic, and using &(*x) doesn't create a defensive copy. Consider checking for nil and returning a copy to prevent external modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
wechaty-puppet/puppet.go(1 hunks)wechaty-puppet/schemas/message.go(1 hunks)wechaty/user/message.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
wechaty/user/message.go (1)
wechaty-puppet/schemas/message.go (1)
ReferMessagePayload(100-108)
🪛 golangci-lint (1.64.8)
wechaty/user/message.go
151-151: SA4001: &*x will be simplified to x. It will not copy x.
(staticcheck)
🔇 Additional comments (2)
wechaty-puppet/puppet.go (1)
6-8: Whitespace changes are consistent with code style.The added blank lines around the third-party import create better visual organization by separating standard library imports from external packages.
wechaty-puppet/schemas/message.go (1)
97-97: LGTM: Good addition of reference message support.Adding the ReferMessage field enables important functionality for referencing or quoting previous messages in conversations.
| type ReferMessagePayload struct { | ||
| Type MessageType // TODO: 确认是否和 MessageType 一致 | ||
| SourceMsgId string | ||
| TalkerId string | ||
| RoomId string | ||
| DisplayName string | ||
| Content string | ||
| Timestamp time.Time | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Resolve TODO comment before finalizing.
The payload structure looks good, but there's a TODO comment about confirming whether the Type field uses the same MessageType enum that should be addressed.
Please verify if the MessageType enum is appropriate for the Type field in ReferMessagePayload and update or remove the TODO comment accordingly.
🏁 Script executed:
#!/bin/bash
# Check where MessageType is used to confirm consistent usage
rg -l "MessageType" --type goLength of output: 332
🏁 Script executed:
#!/bin/bash
# Display the MessageType type declaration and its constants to confirm coverage for refer messages
rg -n "type MessageType" -A 10 wechaty-puppet/schemas/messagetype_string.go
rg -n "const (" -A 200 wechaty-puppet/schemas/messagetype_string.goLength of output: 212
🏁 Script executed:
#!/bin/bash
# Correctly search for MessageType declaration and its constants
rg -F -n "type MessageType" -A 50 wechaty-puppet/schemas/messagetype_string.go
rg -F -n "const (" -A 200 wechaty-puppet/schemas/messagetype_string.go
# Check if a Refer-related constant exists
rg -i -n "refer" wechaty-puppet/schemas/messagetype_string.goLength of output: 215
🏁 Script executed:
#!/bin/bash
# List Go files in schemas directory to locate the MessageType file
find wechaty-puppet/schemas -maxdepth 1 -type f -name "*.go"
# Search for the MessageType declaration across all Go files
rg -n --type go "type MessageType" -A 20
# If found, list the surrounding constants for MessageType
rg -n --type go "^const \\(" -A 200 $(rg -l --type go "type MessageType")Length of output: 7562
Remove the outdated TODO in ReferMessagePayload
The Type MessageType field already uses the central MessageType enum as intended—no separate enum is needed. Please delete the // TODO: 确认是否和 MessageType 一致 comment.
• File: wechaty-puppet/schemas/message.go
• Line: 101
🤖 Prompt for AI Agents
In wechaty-puppet/schemas/message.go around lines 100 to 108, remove the
outdated TODO comment on line 101 that questions whether the Type field uses the
correct MessageType enum. The Type field is already correctly using the central
MessageType enum, so simply delete the comment "// TODO: 确认是否和 MessageType 一致"
to finalize the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed c47fe4f in 1 minute and 7 seconds. Click for details.
- Reviewed
36lines of code in2files - Skipped
0files when reviewing. - Skipped posting
3draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. wechaty-puppet/schemas/message.go:101
- Draft comment:
Renamed 'SourceMsgId' to 'SourceMsgID' for proper Go naming convention. Ensure downstream serialization (if any) is updated accordingly. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. wechaty/user/message.go:151
- Draft comment:
Good update: The nil check and copying of ReferMessage ensure caller does not modify original data. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%<= threshold50%This comment is purely informative, explaining what the code does without suggesting any changes or improvements. It doesn't align with the rules for useful comments in a pull request review.
3. wechaty/user/message.go:150
- Draft comment:
The comment seems to have a grammatical issue: 'ReferMessage get the refer message' might be better phrased as 'ReferMessage gets the refer message' or 'Gets the refer message.' Consider revising for clarity. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While the comment is technically correct about the grammar, it's an extremely minor documentation change that doesn't affect functionality. The meaning is clear either way. Our rules say not to make purely informative comments that don't require code changes. Documentation nitpicks like this don't add enough value to justify the comment. The grammar correction would make the documentation slightly more professional. Poor documentation can make code harder to maintain long-term. While good documentation is important, this tiny grammar fix is too minor to be worth a PR comment. The meaning is perfectly clear either way. Delete this comment as it's a minor documentation nitpick that doesn't meaningfully improve the code.
Workflow ID: wflow_oS4i4qxvL2aGZZXs
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Important
Added support for message referencing in Wechaty, allowing retrieval of referenced message details via new
ReferMessagefield and method.ReferMessagefield toMessagePayloadBaseinschemas/message.goto support message referencing.ReferMessagePayloadstruct inschemas/message.goto store referenced message details.ReferMessage()method toMessageclass inuser/message.goto retrieve referenced message details.This description was created by
for c47fe4f. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit