* fix: Use proper mentionsUsers serializer
The only reason we haven't seen any issues with this up until now is because we have not has to include the relationship in any responses.
* fix: User/Post mentions showing as deleted after saving
The reason this happens is because the modified relationship is not refreshed, so the formatter doesn't recognize the new mentions as valid.
* perf: Eager load related mentions from the extender
These missing relations caused more queries to be called, the more mentions posts have the more queries produced.
* perf: Eager load models in show endpoints
Can't use the extender for that
* Convert user mentions to new `@"Display Name"#ID` format
* Handle deleted user's mentions
* Convert post mentions to `@"Display Name"#pID` format
* Handle deleted user's post mentions and deleted posts mentions
* Clean display name of `"#{letters}{numbers}` (replace with underscore _)
* Adapt integration tests to new mention formats
* Use a deleted attribute for user mentions
* Introduce cleanDisplayName util
* Detect new format with autocomplete
* Slug needed on rendering only
* Invalidate user mention tag when ID is invalid
This used to be implicitly done, when there was a username attribute configured, formatter would check that all attributes are available and if not invalidate.
since we now only have `displayname` and `id` attributes which are both available from the regex matching, formatter doesn't implicitly invalidate anymore and therefore validates ANY matches. So we explicitly invalidate the tag when the ID does not match a user.
* Allow username mention format with a setting
* Add tests for turning setting on/off
* Move setting check to tag filter
Because the configurator caches, changing the setting only takes effect after the cache is cleared.
* fix: showing autocomplete at the right moment
* Add dockblocks to explain unparsing process
Fixes#1956 - ErrorException: Trying to get property 'display_name' of
non-object. ConfigureMentions::addPostId method set mention details
based on if there was an existing post. This caused an error if there
was an existing post, but the user who posted had been deleted. The
mention details are now only set if there is a user associated with the
post being mentioned.
This also improves the behaviour of mentions in the JS preview (no more
broken links, mention is only picked up if corresponding user/post is
found).
See flarum/core#1246Closesflarum/core#315