fix(line): use stable source id for session identity - #2398
Open
leonoxo wants to merge 1 commit into
Open
Conversation
LINEEventConverter.target2yiri() built Friend.id/Group.id from event.message.id, which is unique per message. Every incoming message therefore mapped to a new session key, so LINE users and groups lost conversation context on every turn. Use event.source.user_id/group_id/room_id instead, matching the stable identifiers other adapters (e.g. Telegram) use for session identity. Falls back to the group/room id when user_id is absent, per LINE's documented behavior for some group/room members.
Contributor
|
All contributors have signed the CLA. ✅ 所有贡献者均已签署 CLA。 |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Member
|
Hi @leonoxo , would you provide some screenshots to prove the changes work? |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LINEEventConverter.target2yiri()builtFriend.id/Group.id(and theGroupMembersender id) fromevent.message.id, which is unique per message — every incoming message therefore mapped to a different session key, so LINE users and groups lost conversation context on every single turn.event.source.user_id/.group_id/.room_id, the stable identifiers LINE actually provides for this purpose, matching the pattern already used by other adapters (e.g.telegram.pyusesevent.effective_chat.id).user_idis absent, per LINE's documented behavior ("Only included in message events. Only users of LINE for iOS and LINE for Android are included in userId") for some group/room members.Test plan
tests/unit_tests/platform/test_line_session_identity.pycovering: stable sender id across multiple messages from the same user, stable group id across multiple messages, and room-type fallback whenuser_idis missing.uv run pytest tests/unit_tests/platform/test_line_session_identity.py tests/unit_tests/platform/test_line_limits.py -q— 6 passeduv run ruff check/ruff format --checkon changed files