fix: return 204 instead of 404#49839
Conversation
|
/backport to stable30 |
|
/backport to stable29 |
7db5fc3 to
8c05904
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
Eventhough this fix solves the issue of having a lot of 404-responses - the root cause is still in place: instead of checking, if there is an image at all and not requesting it, the contacts app still tries to load an image for each contact. There will still be a lot of exceptions which trigger the 204-response. It would be better, if a contact had a flag, that there is no image, so the frontend won't even try to load it. |
|
We rejected similar "don't use 404 for fail2ban" requests in the past. I think using 204 is a good choice. As written by Arno, changing the response code is a workaround for those fail2ban users. The underlying problem is that those requests are happening. The response for the address book contains a has-photo attribute (empty/1). <?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:response>
<d:href>
/remote.php/dav/addressbooks/users/admin/contacts/F1D36433-6CC3-48B9-942F-8E7E12A69D4E.vcf
</d:href>
<d:propstat>
<d:prop>
<d:getetag>"4e748fcff71af1c2a024fb19b9a3812e"</d:getetag>
<d:getcontenttype>text/vcard; charset=utf-8</d:getcontenttype>
<d:resourcetype/>
<card:address-data>BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 4.5.6//EN
UID:58236d02-66e5-4374-bdaa-5d4f04ce29f4
FN:Test 1000
EMAIL;TYPE=HOME:
END:VCARD
</card:address-data>
<x1:has-photo xmlns:x1="http://nextcloud.com/ns"></x1:has-photo>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>The following change for contacts should take the hasPhotos property into account: Index: src/models/contact.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/models/contact.js b/src/models/contact.js
--- a/src/models/contact.js (revision b91012f60c1b011a3ce173c8613b05a221646ae4)
+++ b/src/models/contact.js (date 1734087428669)
@@ -119,6 +119,16 @@
return ''
}
+ /**
+ * Return whether a photo is available
+ *
+ * @readonly
+ * @memberof Contact
+ */
+ get hasPhoto() {
+ return this.dav && this.dav.hasphoto
+ }
+
/**
* Return the version
*
Index: src/components/ContactsList/ContactsListItem.vue
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/components/ContactsList/ContactsListItem.vue b/src/components/ContactsList/ContactsListItem.vue
--- a/src/components/ContactsList/ContactsListItem.vue (revision b91012f60c1b011a3ce173c8613b05a221646ae4)
+++ b/src/components/ContactsList/ContactsListItem.vue (date 1734087333973)
@@ -141,7 +141,7 @@
return
}
this.avatarUrl = photoUrl
- } else if (this.source.url) {
+ } else if (this.source.hasPhoto && this.source.url) {
this.avatarUrl = `${this.source.url}?photo`
}
}, |
Sure, we can add this also, makes sense. |
oleksandr-nc
left a comment
There was a problem hiding this comment.
really good changes
No worries, ill cancel the 28 backport. FYI, a EOL date not just the month would be a good idea. This can be interpreted as Dec 31st instead of Dec 1st |
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
0d8d3b1 to
0628eb6
Compare

Summary
Changed status return to 204 "no content" instead of 404 when a photo does not exist
204 make more sense as it signals that there was no image, instead that a error occurred.
Checklist