[18.0][FIX] ai_oca_bridge_chatter: post AI replies as Discuss comments - #112
marcelsavegnago wants to merge 1 commit into
Conversation
|
ping @etobella |
| response["author_id"] = self.chatter_user_id.partner_id.id | ||
| response["message_type"] = "comment" | ||
| body = response.get("body") or "" | ||
| body_is_html = bool(response.pop("body_is_html", False)) |
There was a problem hiding this comment.
This might break previous installations....
I mean, imagine I was responding with HTML 🤔
There was a problem hiding this comment.
Good point. This should be covered now.
Existing bridges that already return HTML as a plain str are detected and converted to Markup before posting, so the HTML is not escaped or wrapped again. Bridges can also explicitly set body_is_html=True.
Plain-text responses remain unchanged, while the message is still posted as mail.mt_comment so Discuss renders it as a chat bubble.
Could you please check the latest changes?
f539a0a to
a0c2f60
Compare
| # <p><p>...</p></p>. body_is_html=True also warns for | ||
| # internal users, so convert HTML to Markup instead of rewriting. | ||
| body = response.get("body") | ||
| body_is_html = bool(response.pop("body_is_html", False)) |
There was a problem hiding this comment.
For me, by default we should assume that it was html, at least in this version
e784ce1 to
ba09707
Compare
etobella
left a comment
There was a problem hiding this comment.
I don' t get it. According to the message,of the PR we should be modifying the subtype. However, you are adding also the markdown functionality (not a problem for me, but it should be documented in the PR description at least).
Also, as this is already in production, we shouldn't change anything in previous messages, so no markdown transformation should happen if the new parameter is not set.
| # rewriting. Assume HTML by default; body_is_html=False opts out. | ||
| body = response.get("body") or "" | ||
| body_is_html = bool(response.pop("body_is_html", True)) | ||
| if body_is_html and not isinstance(body, Markup): |
There was a problem hiding this comment.
if not body_is_html, isn't it?
There was a problem hiding this comment.
If we invert it, HTML (the 18.0 default) stays as str and message_post
escapes it again, which is the original bug.
Odoo 18 treats Markup as trusted HTML and escapes a plain str, so we
wrap only when body_is_html is true (the default). body_is_html=False
is just an opt-out.
Happy to drop the flag and always convert to Markup if you prefer that
for this version.
Discuss only draws chat bubbles for mail.mt_comment. Bridge replies defaulted to mail.mt_note, so AI messages rendered as plain text while manually typed bot messages appeared in bubbles.