mattermost-plugin-autolink: Autolink should ignore bot posts. (was: Commit notifications trigger unexpected link preview)
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:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (25 by maintainers)
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 [2] https://github.com/mattermost/mattermost-plugin-github/issues/179#issuecomment-578401262
Let me know if this is something we are after: https://github.com/mattermost/mattermost-plugin-autolink/pull/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.
It is a 180 from how I was thinking of it, but I am fully persuaded that it is a simple and consistent policy.
@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
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
mmctl plugin list
?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!
[1] https://github.com/vespian/mattermost-plugin-github/blob/ce0a3a6d4ed08995994702b70307270f02ac08b5/server/plugin.go#L57