-
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
Autolink should ignore bot posts. (was: Commit notifications trigger unexpected link preview) #94
Comments
(at a superficial glance) - review and add tests for https://github.com/mattermost/mattermost-plugin-github/blob/23f77f082659e78f1d519eb3aacb0ceb94a3cc21/server/plugin.go#L57? |
I'll like to take this one. |
Thanks, @vespian! |
Short update - the problem occurs due to other users doing @mentions of the given user in the commit message. We would need to adjust the regex as pointed out in [2] and adjust the current code [1] to handle rewriting the raw link to the commit (i.e. do not always assume a file/blob) to a nice markdown link. Will try to prepare a patch. [1] https://github.com/mattermost/mattermost-plugin-github/blob/ab7832c593851ce7b55882a1325e6e64bf933bc1/server/permalinks.go#L113-L117 |
I was playing with the code rewriting the raw link to the commit [4] and realized that I may not have all the data yet. The ToDo text you included in the issue description one can trigger by sending a command directly to the bot ( Another option is while connecting/disconnecting to github[5] the todo list also gets displayed, but I guess this is not the case here. The third option is the API call via I wonder if I misconfigured somehow my dev instance. How can I recreate it reliably? I was using latest Also, I wonder why the Thanks in advance for any information. [2] https://community.mattermost.com/core/pl/n8rzet9gfjgyfr9kgcafh7xnfy |
@vespian, re: the GitHub bot and |
RE: Github credentials - I have prepared a simple patch: mattermost/mattermost-plugin-github#191 It does not solve the main issue though, just fixes the thing that most likely is a different bug. Please check the PR description for details. |
I am so very confused (and apologies for my ignorance about how the plugin works). This is a message that is generated by the plugin itself, do we really use MessageWillBePosted to rewrite it? Seems illogical, why not compose correctly to start with? Also, FWIW, if we are setting up regex link rewrites from the GitHub plugin, perhaps we should be promoting the autolink plugin, and programmatically set it up from GitHub, like we are doing with Jira now? |
Please bear with me, I still had no luck in recreating the error, even with mattermost/mattermost-plugin-github#191. Is it possible that the previews you mentioned are done through autolinks plugin? Could you please post the output of The regexp for the Github's plugin preview [1] would not match the commit link you posted, so I am wondering if there is something more at play here. Thanks in advance! |
@vespian, ahh, perhaps it is autolink that's at play here, and not GitHub at all. That makes a lot more sense: and thank you for digging to the bottom of this. @levb, would it makes sense to guard autolink with ShouldProcessMessage? |
@lieut-data Yes, I think so. Do you think we should expose the options in the Config? Do we have common code to do that? Separately, I also think we should work on removing link substitution from GitHub and delegate it all to Autolink, programmatically, like Jira does now. This would be better for performance, and promote plugin usage. cc @aaronrothschild @jfrerich. Now, what do we do with this issue then, close it? |
@levb, I'd be happy to move this issue over to the autolink repository to keep the history. Agreed re: investigating programmatically managing link substitution, but as a separate issue? |
I think the issue should stay here, and be repurposed if the history is important. Autolink will already expose the link config APIs in the next release, no special work needed there AFAIU. We just need to add the code on the GiitHub side to manage the links, and probably a config/feature flag to use this new capability instead of the current in-plugin substitution. cc @jfrerich |
(closed by mistake, reopened) |
I think there's two separate issues here:
One reason to keep this in the GitHub plugin is to solve the second issue, which I guess also solves the first issue? One concern is that this means the GitHub plugin, out of the box, isn't as fully-featured as GitHub + AutoLink, and I have no idea of the lifecycle of these plugin-to-plugin registrations. Seems like a thorny problem and worthy of design + investigation, as compared to solving the original report. Thoughts on this interpretation? |
@lieut-data I'd argue against this complexity. Autolink should already ignore substituting links in markdown; Bots should be aware of the markdown nature of the contents and properly encode links in the message bodies if they come from external systems as raw text or other formats. Ditto for the messages that the bots generate.
2 motives I can think of:
So I'd advocate that we |
I think this adds more complexity since it requires bots/plugins to artificially encode their payload to avoid some other event they might not have been able to predict. Maybe I want a /real/ link without such a preview, because I'm doing something else, but along comes autolink and decides better for me. In fact, the simplest model might be to disallow bot rewriting of other bot's posts at the server level: if GitHub wants autolink post-processing, maybe it can opportunistically call out to the autolink API and ask for a payload to be rewritten. Only humans get autolinked. |
What happens when the rewrite requires metadata? I think |
It is a 180 from how I was thinking of it, but I am fully persuaded that it is a simple and consistent policy. |
@lieut-data hopefully we don't invoke GitHub APIs in MessageWillBePosted - that'd seem inefficient. And if the metadata is cached, I'd argue it should be submitted to Autolink APIs when it changes. |
@vespian are you interested in finishing this? |
Yep. |
Let me know if this is something we are after: #98 I did not make it optional to keep it simple, both when it comes to code complexity and the plugin configuration for users. It would be nice to doublecheck with the Product Manager though. |
@levb, in the GitHub use case we're talking about, it exactly does require a GitHub API call on |
To avoid clashes with bot-formatted links, Autolink should (optionally?) ignore bot posts.
1/5 recommend adding an "Process posts from Bots", default
false
to the plugin config.Original description:
I recently received a notification in the message of a commit:
In my summary, this then resulted in a perhaps unexpected link preview compared to all the other links in the message:
The text was updated successfully, but these errors were encountered: