git » sdk » commit d4b04f1

Use trusted bit to control if we should allow subscription

author Stephen Paul Weber
2024-11-27 18:35:00 UTC
committer Stephen Paul Weber
2024-11-27 18:35:00 UTC
parent 7350a86b201895c9edab42aee3d069965f9c10c3

Use trusted bit to control if we should allow subscription

snikket/Chat.hx +2 -3

diff --git a/snikket/Chat.hx b/snikket/Chat.hx
index 5373a75..ea9efdd 100644
--- a/snikket/Chat.hx
+++ b/snikket/Chat.hx
@@ -467,8 +467,7 @@ abstract class Chat {
 		this.avatarSha1 = sha1;
 	}
 
-	@:allow(snikket)
-	private function setTrusted(trusted:Bool) {
+	public function setTrusted(trusted:Bool) {
 		this.trusted = trusted;
 	}
 
@@ -850,7 +849,7 @@ class DirectChat extends Chat {
 			(response) -> {
 				if (response.attr.get("type") == "error") return;
 				stream.sendStanza(new Stanza("presence", { to: chatId, type: "subscribe", id: ID.short() }));
-				stream.sendStanza(new Stanza("presence", { to: chatId, type: "subscribed", id: ID.short() }));
+				if (isTrusted()) stream.sendStanza(new Stanza("presence", { to: chatId, type: "subscribed", id: ID.short() }));
 			}
 		);
 	}