-
Notifications
You must be signed in to change notification settings - Fork 58
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
[GH-84] Do not rewrite messages from bots #98
[GH-84] Do not rewrite messages from bots #98
Conversation
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.
Thanks for also adding a test 👍
a9ce2b4
to
d0d75bc
Compare
Codecov Report
@@ Coverage Diff @@
## master #98 +/- ##
==========================================
+ Coverage 36.43% 37.47% +1.04%
==========================================
Files 6 6
Lines 538 547 +9
==========================================
+ Hits 196 205 +9
Misses 320 320
Partials 22 22
Continue to review full report at Codecov.
|
75d2539
to
34e1a57
Compare
@hanzei Ready for another pass. |
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.
One non blocking comment 👍
34e1a57
to
2c0ad05
Compare
server/autolinkplugin/plugin.go
Outdated
func (p *Plugin) ProcessPost(c *plugin.Context, post *model.Post) (*model.Post, string) { | ||
isBot, appErr := p.isBotUser(post.UserId) |
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.
It is likely considerably more expensive to go back to the server to get the user record than first evaluating to see if any links apply. 3/5 we should move this check after an applicable link is found.
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.
@levb I am curious - what does 3/5, 0/5 mean? I often see it in reviews.
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.
Wrt. your comment - we do not really have data on how big/how numerous the rules can get, and how much traffic we may need to rewrite and how the plugin system and querying the server performs under load. The rewriting rules also already call p.API.GetChannel
and p.API.GetTeam
api calls which may be heavier than the p.API.GetUser
that we are adding and actually having isBot
check early may save CPU cycles.
I believe optimizing it now is a bit early. Would you mind if we ask @hanzei to add his two cents as well?
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.
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.
(waiting for @hanzei also cc @lieut-data) A single RPC/post is too expensive, anywhere in a plugin, period. We should move the RPCs to after the match, so we only execute them when needed.
Now, I see the argument that if this PR follows the existing pattern, we should stick with it as is, and have a separate ticket to optimize. I'm 1/5 that we shouldn't - let's at least make sure this PR doesn't add overhead.
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.
@levb, based on @ali-farooq0's preliminary analysis of the RPC overhead on community, it /seems/ like RPC, itself, isn't that expensive. The real cost is borne by the database queries to resolve this information, but I'm assuming we're already doing one or more of those to post the message in the first place.
That being said, no objections to moving this check below and wrapping in a post.Message != postText
test first. Agree we should have a ticket to optimize regardless.
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.
Thanks for the discussion! Requested changes can be found in Do not rewrite messgaes from bots - review fixes #1
commit.
@levb Ready for another pass! |
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.
LGTM.
I think we should not modify the message when isBot fails.
@@ -131,7 +141,23 @@ func (p *Plugin) ProcessPost(c *plugin.Context, post *model.Post) (*model.Post, | |||
|
|||
return true | |||
}) | |||
post.Message = postText | |||
if post.Message != postText { | |||
isBot, appErr := p.isBotUser(post.UserId) |
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.
It seems that if there is a "system failure" in the process of modifying the message, the right thing to do is to pass it through as is. 0/5 if isBot || appErr != nil {...
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.
What do you mean by in the process of modifying the message
? isBotUser
does not modify the message.
@vespian, can you please merge from master and resolve the conflict in @lieut-data, gentle ping for review |
@lieut-data thanks for checking back in. I know we already have the two dev reviews and just checking you had no further comments :) |
ce6ce1d
to
222fb8f
Compare
@vespian or @lieut-data can you help me understand the scope of this change? I'm not sure how to validate this and exactly what it should do. I'm seeing the the Links are still working for posts made the Jira bot or GitHub bot which is great. |
@DHaussermann, exactly, GitHub/Jira already knows how to format its own links. The easiest way to truly verify might be to setup the conditions of #94 with an at-mention to yourself on a commit that autolink would have otherwise rewritten. Assuming that stops working, and the normal links stays in place, I think we're good. |
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.
Tested and passed.
- Ensured autolink is not formatting bot posts
- Regression tested posts made from GitHub and Jira
- Added release testing
LGTM!
Thanks @vespian for your effort on this!
@aaronrothschild, any objections to this change? |
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.
LGTM. This makes sense to me. Good addition!
Summary
This PR makes autolink plugin not rewrite messages from other bots as discussed in #94
Ticket Link
Fixes #94