mattermost-community / mattermost-plugin-autolink

Automatically rewrite text matching a regular expression into a markdown link.
Apache License 2.0
131 stars 57 forks source link

When editing a Post, display the "pre-autolink'd" version of the message, then re-run the rules #90

Open aaronrothschild opened 4 years ago

aaronrothschild commented 4 years ago

Issue: When editing a post that has been modified by autolink, the user may need to do additional work to fix an error because of the modifications.

Request: A customer has requested the ability to see the "original unmodified" message before autolink touched it. Then when the edits are made, the autolink rules are re-applied on save.

From Customer:

Interesting, thanks for pointing me at the pull request. It looks like it will allow an individual auto-link rule to indicate that it should be re-run on edit, and assumes that most auto-link rules are idempotent. I'm not sure if mine are, but perhaps I can make them work correctly on re-run.

However, even if I can make it work I'm not sure it's exactly what users would expect. For example, suppose I have a ticketing system auto-link that converts something like GHS-5432 into GHS-5432. If I meant to link to GHS-54321, then when I edit I need to modify the link and the link text. Ideally, editing a post that's been auto-linked would show up as the pre-auto-linked text ("GHS-5432") when editing and then have the auto-link re-applied.

levb commented 4 years ago

cc @grundleborg @lieut-data - I can't imagine that storing 2 versions of the Post (if modified by the plugins from the original) is acceptable overhead, but I may be wrong if all we need is the text.

Something else to consider, probably even less imaginable in our current architecture would be a PostWillBeServed (BeforeGetPost?) hook, and then GetPostUnprocessed for editing the original contents.

lieut-data commented 4 years ago

I can sort of see an argument to treat the MessageWillBePosted as an edit event, not unlike if the user had edited their own post. This would store the "original message" in a referenced, deleted post, and make it accessible with somewhat minimal overhead. It's not quite the right paradigm, of course, but in terms of overhead, it's at least a familiar model.

I can also see the flip side, though, of letting autolink run, and then being able to always edit /that/ text without being forever frustrated by some rule that didn't consider your use case. Needs a ton of design to figure this out: no obvious next steps here for me.