-
Notifications
You must be signed in to change notification settings - Fork 227
fix(milky): friend_nudge user_id is zero #677
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
审阅者指南(在小型 PR 上折叠)审阅者指南调整 friend_nudge 事件的转换逻辑,当 在 transformPrivateMessageEvent 中解析 friend_nudge 的 user_id 的时序图sequenceDiagram
participant EventSource
participant transformPrivateMessageEvent
participant NTUserApi as ntUserApi
participant EventConsumer
EventSource->>transformPrivateMessageEvent: message, ctx, selfInfo
transformPrivateMessageEvent->>transformPrivateMessageEvent: check elements for busiId 1061
alt peerUin is non zero
transformPrivateMessageEvent->>transformPrivateMessageEvent: userId = +message.peerUin
else peerUin is zero or missing
transformPrivateMessageEvent->>NTUserApi: getUinByUid(message.peerUid)
NTUserApi-->>transformPrivateMessageEvent: resolvedUin
transformPrivateMessageEvent->>transformPrivateMessageEvent: userId = +resolvedUin
end
transformPrivateMessageEvent-->>EventConsumer: event { eventType friend_nudge, data.user_id = userId }
friend_nudge 的 user_id 回退逻辑流程图flowchart TD
A[Start: friend_nudge element detected] --> B[Read message.peerUin]
B --> C{Is +message.peerUin truthy?}
C -- Yes --> D[Set userId = +message.peerUin]
C -- No --> E["Call ctx.ntUserApi.getUinByUid(message.peerUid)"]
E --> F[Set userId = +returnedUin]
D --> G[Set data.user_id = userId]
F --> G[Set data.user_id = userId]
G --> H[Return friend_nudge event with non zero user_id]
H --> I[End]
文件级变更
提示与命令与 Sourcery 交互
自定义使用体验前往你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the friend_nudge event transformation to correctly derive a non-zero user_id by falling back to a UID-to-UIN lookup when peerUin is missing or zero. Sequence diagram for friend_nudge user_id resolution in transformPrivateMessageEventsequenceDiagram
participant EventSource
participant transformPrivateMessageEvent
participant NTUserApi as ntUserApi
participant EventConsumer
EventSource->>transformPrivateMessageEvent: message, ctx, selfInfo
transformPrivateMessageEvent->>transformPrivateMessageEvent: check elements for busiId 1061
alt peerUin is non zero
transformPrivateMessageEvent->>transformPrivateMessageEvent: userId = +message.peerUin
else peerUin is zero or missing
transformPrivateMessageEvent->>NTUserApi: getUinByUid(message.peerUid)
NTUserApi-->>transformPrivateMessageEvent: resolvedUin
transformPrivateMessageEvent->>transformPrivateMessageEvent: userId = +resolvedUin
end
transformPrivateMessageEvent-->>EventConsumer: event { eventType friend_nudge, data.user_id = userId }
Flow diagram for friend_nudge user_id fallback logicflowchart TD
A[Start: friend_nudge element detected] --> B[Read message.peerUin]
B --> C{Is +message.peerUin truthy?}
C -- Yes --> D[Set userId = +message.peerUin]
C -- No --> E["Call ctx.ntUserApi.getUinByUid(message.peerUid)"]
E --> F[Set userId = +returnedUin]
D --> G[Set data.user_id = userId]
F --> G[Set data.user_id = userId]
G --> H[Return friend_nudge event with non zero user_id]
H --> I[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey - 我在这里给出了一些总体反馈:
- 建议处理这样一种情况:当
peerUin和getUinByUid(peerUid)的结果同时缺失或无效时,+message.peerUin || +(...)可能会返回NaN,但当前没有任何后备逻辑或错误处理。
面向 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where both `peerUin` and the result of `getUinByUid(peerUid)` are missing or invalid, since `+message.peerUin || +(...)` could yield `NaN` without any fallback or error handling.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- Consider handling the case where both
peerUinand the result ofgetUinByUid(peerUid)are missing or invalid, since+message.peerUin || +(...)could yieldNaNwithout any fallback or error handling.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where both `peerUin` and the result of `getUinByUid(peerUid)` are missing or invalid, since `+message.peerUin || +(...)` could yield `NaN` without any fallback or error handling.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
onebot 也是这么修的,napcat 也是这么修的 |
Summary by Sourcery
Bug Fixes:
peerUin或其值为 0 时,friend_nudge事件会回退为通过peerUid解析user_id。Original summary in English
Summary by Sourcery
Bug Fixes: