♻️(backend) annotate mentioned user roles in mention validation

Signed-off-by: BOUKERFA Mohamed El Amine <boukerfa.ma@gmail.com>
This commit is contained in:
BOUKERFA Mohamed El Amine
2026-09-29 17:40:39 +02:00
committed by Manuel Raynaud
parent b9d41e6a6d
commit 108c24eefb
+3 -1
View File
@@ -1027,7 +1027,9 @@ class MentionSerializer(serializers.ModelSerializer):
def validate_mentioned_user_id(self, user):
"""Ensure the mentioned user has access to the document."""
document = models.Document.objects.get(pk=self.context["document"].pk)
document = models.Document.objects.annotate_user_roles(user).get(
pk=self.context["document"].pk
)
if document.get_role(user) is None:
raise serializers.ValidationError(
"This user does not have access to the document."