| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-09-01 13:52:56 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-09-01 13:53:46 UTC |
| parent | fb6af897f7e05bdc3ad18fa8258982c80993f53d |
| borogove/Client.hx | +5 | -3 |
| test/TestClient.hx | +15 | -0 |
diff --git a/borogove/Client.hx b/borogove/Client.hx index 879a568..43c584e 100644 --- a/borogove/Client.hx +++ b/borogove/Client.hx @@ -1157,9 +1157,11 @@ class Client extends EventEmitter { // We already have it if (attachment.cachedAt != null) return Promise.resolve(attachment); - return fetchUris( attachment.uris.copy()).then(r -> { - attachment.cachedAt = r.id; - if (attachment.hashes.length < 1) attachment.hashes.push(r.hash); + return fetchUris(attachment.uris.copy()).then(r -> { + if (r != null) { + attachment.cachedAt = r.id; + if (attachment.hashes.length < 1) attachment.hashes.push(r.hash); + } return attachment; }); } diff --git a/test/TestClient.hx b/test/TestClient.hx index ab07140..882d50a 100644 --- a/test/TestClient.hx +++ b/test/TestClient.hx @@ -210,6 +210,21 @@ class TestClient extends utest.Test { }); } + public function testFetchAttachmentNullResult(async: Async) { + final client = new Client("test@example.com", new Dummy()); + final attachment = new borogove.ChatMessage.ChatAttachment("file.txt", "text/plain", 10, [], []); + client.fetchAttachment(attachment).then(r -> { + Assert.equals(attachment, r); + Assert.isNull(r.cachedAt); + async.done(); + return null; + }, e -> { + Assert.fail(Std.string(e)); + async.done(); + return null; + }); + } + #if !NO_OMEMO @:timeout(3000) public function testEncryptedAttachmentPreservesUploadError(async: Async) {