-
Notifications
You must be signed in to change notification settings - Fork 1
fix: resolve 10 port bugs found by systematic scan #16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,7 +62,11 @@ def to_ast(self, platform_text: str) -> Root: | |||||||||||
| return parse_markdown(markdown) | ||||||||||||
|
|
||||||||||||
| def render_postable(self, message: object) -> str: | ||||||||||||
| """Override renderPostable to convert @mentions in plain strings.""" | ||||||||||||
| """Override renderPostable to convert @mentions in plain strings. | ||||||||||||
|
|
||||||||||||
| Extends the base implementation with Discord mention conversion | ||||||||||||
| and dataclass-style message support. | ||||||||||||
| """ | ||||||||||||
| if isinstance(message, str): | ||||||||||||
| return self._convert_mentions_to_discord(message) | ||||||||||||
| if isinstance(message, dict): | ||||||||||||
|
|
@@ -72,7 +76,18 @@ def render_postable(self, message: object) -> str: | |||||||||||
| return self.from_ast(parse_markdown(message["markdown"])) | ||||||||||||
| if "ast" in message: | ||||||||||||
| return self.from_ast(message["ast"]) | ||||||||||||
| return "" | ||||||||||||
| if "card" in message or message.get("type") == "card": | ||||||||||||
| return super().render_postable(message) | ||||||||||||
| return "" | ||||||||||||
| # Dataclass / object-style messages | ||||||||||||
| if hasattr(message, "raw"): | ||||||||||||
| return self._convert_mentions_to_discord(message.raw) | ||||||||||||
| if hasattr(message, "markdown"): | ||||||||||||
| return self.from_ast(parse_markdown(message.markdown)) | ||||||||||||
| if hasattr(message, "ast"): | ||||||||||||
| return self.from_ast(message.ast) | ||||||||||||
| # Fall back to base implementation for remaining cases (e.g. card objects) | ||||||||||||
| return super().render_postable(message) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For object-style messages containing a card, use the Discord-specific fallback logic to ensure that emojis and mentions are correctly processed for the platform.
Suggested change
|
||||||||||||
|
|
||||||||||||
| def _convert_mentions_to_discord(self, text: str) -> str: | ||||||||||||
| """Convert @mentions to Discord format: @name -> <@name>.""" | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,7 +94,11 @@ def to_ast(self, platform_text: str) -> Root: | |||||||||||
| return parse_markdown(markdown) | ||||||||||||
|
|
||||||||||||
| def render_postable(self, message: object) -> str: | ||||||||||||
| """Override renderPostable to convert @mentions in plain strings.""" | ||||||||||||
| """Override renderPostable to convert @mentions in plain strings. | ||||||||||||
|
|
||||||||||||
| Extends the base implementation with Teams mention conversion | ||||||||||||
| and dataclass-style message support. | ||||||||||||
| """ | ||||||||||||
| if isinstance(message, str): | ||||||||||||
| return self._convert_mentions_to_teams(message) | ||||||||||||
| if isinstance(message, dict): | ||||||||||||
|
|
@@ -104,7 +108,18 @@ def render_postable(self, message: object) -> str: | |||||||||||
| return self.from_ast(parse_markdown(message["markdown"])) | ||||||||||||
| if "ast" in message: | ||||||||||||
| return self.from_ast(message["ast"]) | ||||||||||||
| return "" | ||||||||||||
| if "card" in message or message.get("type") == "card": | ||||||||||||
| return super().render_postable(message) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delegating to
Suggested change
|
||||||||||||
| return "" | ||||||||||||
| # Dataclass / object-style messages | ||||||||||||
| if hasattr(message, "raw"): | ||||||||||||
| return self._convert_mentions_to_teams(message.raw) | ||||||||||||
| if hasattr(message, "markdown"): | ||||||||||||
| return self.from_ast(parse_markdown(message.markdown)) | ||||||||||||
| if hasattr(message, "ast"): | ||||||||||||
| return self.from_ast(message.ast) | ||||||||||||
| # Fall back to base implementation for remaining cases (e.g. card objects) | ||||||||||||
| return super().render_postable(message) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply Teams-specific card fallback and mention conversion for object-style messages to maintain consistency with other message types.
Suggested change
|
||||||||||||
|
|
||||||||||||
| def _convert_mentions_to_teams(self, text: str) -> str: | ||||||||||||
| """Convert @mentions to Teams format: @name -> <at>name</at>.""" | ||||||||||||
|
|
||||||||||||
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.
Instead of delegating to the generic base implementation, use the Discord-specific
card_to_fallback_textand ensure mentions are converted. The base implementation uses a generic fallback that lacks emoji conversion and Discord-specific mention formatting.