From 6a5d7e986445c2d9ad1acc4b336bebc8be879a84 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Mon, 30 Aug 2021 18:23:59 +0100 Subject: [PATCH] Fix unrecognised user/post mentions (#71) * 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. --- .../mentions/src/Listener/UpdateMentionsMetadataWhenVisible.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/mentions/src/Listener/UpdateMentionsMetadataWhenVisible.php b/extensions/mentions/src/Listener/UpdateMentionsMetadataWhenVisible.php index 67900b3ed..a2d01f521 100755 --- a/extensions/mentions/src/Listener/UpdateMentionsMetadataWhenVisible.php +++ b/extensions/mentions/src/Listener/UpdateMentionsMetadataWhenVisible.php @@ -55,6 +55,7 @@ class UpdateMentionsMetadataWhenVisible protected function syncUserMentions(Post $post, array $mentioned) { $post->mentionsUsers()->sync($mentioned); + $post->unsetRelation('mentionsUsers'); $users = User::whereIn('id', $mentioned) ->get() @@ -69,6 +70,7 @@ class UpdateMentionsMetadataWhenVisible protected function syncPostMentions(Post $reply, array $mentioned) { $reply->mentionsPosts()->sync($mentioned); + $reply->unsetRelation('mentionsPosts'); $posts = Post::with('user') ->whereIn('id', $mentioned)