git » sdk » commit b72f25c

Allow JS to access new snikket.ChatAttachment(...)

author Stephen Paul Weber
2024-09-18 16:13:15 UTC
committer Stephen Paul Weber
2024-09-18 16:13:15 UTC
parent 50e0ef0dad6f76b9065000be71aa161d824bbf44

Allow JS to access new snikket.ChatAttachment(...)

Since JS can understand all these types it's ok for now, and this allows
crafting custom attachments for URLs.

Maybe we want a higher-level helper for that eventually too?
Unfortunately from browser there is no generic way to get the blob data
of an image by URL (due to CORS) so type, size, hash may all be unknown.

snikket/ChatMessage.hx +6 -1

diff --git a/snikket/ChatMessage.hx b/snikket/ChatMessage.hx
index 1b16b40..11e7112 100644
--- a/snikket/ChatMessage.hx
+++ b/snikket/ChatMessage.hx
@@ -31,8 +31,13 @@ class ChatAttachment {
 	@HaxeCBridge.noemit
 	public final hashes: Array<{algo:String, hash:BytesData}>;
 
+	#if cpp
 	@:allow(snikket)
-	private function new(name: Null<String>, mime: String, size: Null<Int>, uris: Array<String>, hashes: Array<{algo:String, hash:BytesData}>) {
+	private
+	#else
+	public
+	#end
+	function new(name: Null<String>, mime: String, size: Null<Int>, uris: Array<String>, hashes: Array<{algo:String, hash:BytesData}>) {
 		this.name = name;
 		this.mime = mime;
 		this.size = size;