-
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 command to edit configuration #71
Conversation
- Using `\b` instead of a homebrewed word separator list - Since `\b` does not consume, removed the second pass ReplaceAll - Made tests more realistic by running MessageWillBePosted, to cover markdown inspection - Added word boundary tests - Cleanup
…link into lev-MM-15965-boundaries
…link into lev-command-config
Also - fixed the help message - fixed incorrect parsing of "false" - moved command [un-]registration OnConfigurationChanged
*conf = c | ||
}) | ||
|
||
go func() { |
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.
The go func() {}
here is a suggestion to work around mattermost/mattermost#11780 which may not be available until mattermost-server 5.15 or later. Thanks @lieut-data for the suggestion.
server/link.go
Outdated
|
||
pattern := l.Pattern | ||
template := l.Template | ||
multipass := false |
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.
This (multipass
) probably warrants a comment. Previously, word boundaries were defined as custom regexp's. These patterns consume characters, so they can not be used with ReplaceAll
functions. Example, if the pattern is defined as "X"
, "foo X bar"
the X will match, but in "foo X X bar"
only the first X matches, the match consumes the subsequent space, and then the second X doesn't match.
see the Replace()
method for 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.
Can this be a comment in the code?
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.
With better naming, didn't need to comment as much
func saveConfigLinks(p *Plugin, links []Link) error { | ||
conf := p.getConfig() | ||
conf.Links = links | ||
appErr := p.API.SavePluginConfig(conf.ToConfig()) |
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.
.ToConfig()
here converts the Link
structs into a tree of map[string]interface{}
and []interface{}
for GOB/RPC compatibility.
@levb I'm surprised there's no interactive regex editor. ;) Is there a spinmint or test server I can try this code out on interactively? |
@aaronrothschild I spun one up on the related PR, mattermost/mattermost#11780 |
@levb some questions/comments:
|
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.
Once @aaronrothschild is stratified please merge, I can test this post merge.
it kind of does, the disabled links are crossed out
Uses the more standard
The name of the field. Like, for |
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.
A big improvement in the UX of the plugin, great job @levb 👍
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 nit.
server/link.go
Outdated
|
||
pattern := l.Pattern | ||
template := l.Template | ||
multipass := false |
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.
Can this be a comment in the code?
@levb or @aaronrothschild I see that this PR is still open. Can you please advise if we intend to package this for the 5.14 Release? |
This is for after 5.14 @DHaussermann, but I am merging this now, and will cut a release shortly. I'd like to deploy it onto community this week, once we confirm it on ci-extensions. |
This PR was prompted by a plethora of tickets for autolink config changes on the community servers. Since there is no UI in the foreseeable future, and modifying configuration otherwise is difficult, I figured these would be useful tools for the more advanced administrators.
The command can be turned off entirely with a config setting in the system console.
/autolink help
output:Mattermost Autolink Plugin Administration
is either the Name of a link, or its number in the /autolink list output. A partial Name can be specified, but some commands require it to be uniquely resolved.
/autolink list
- list all configured links./autolink list <linkref>
- list a specific link./autolink test <linkref> test-text...
- test a link on a sample./autolink enable <linkref>
- enable a link./autolink disable <linkref>
- disable a link./autolink add <name>
- add a new link, named ./autolink delete <linkref>
- delete a link./autolink set <linkref> <field> value...
- sets a link's field to a value. The entire command line - after is used for the value, unescaped, leading/trailing whitespace trimmed.Example: