Fix post attachment author check on editing

pull/563/head
Christof Dorner 2023-05-02 17:51:48 +02:00
rodzic 7d1558a2ab
commit 099f62f859
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -72,7 +72,10 @@ def update_media(
focus: QueryOrBody[str] = "0,0",
) -> schemas.MediaAttachment:
attachment = get_object_or_404(PostAttachment, pk=id)
if attachment.post.author != request.identity:
if attachment.post:
if attachment.post.author != request.identity:
raise ApiError(401, "Not the author of this attachment")
elif attachment.author != request.identity:
raise ApiError(401, "Not the author of this attachment")
attachment.name = description or None
attachment.save()