From f0bfbd8d3b8522ca355444280b52855e73561fc7 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 12 Mar 2026 11:15:37 +0100 Subject: [PATCH] fix: add missing error message --- lib/hk-util.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/hk-util.js b/lib/hk-util.js index bc2c39f35..4dab6cafc 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -1028,6 +1028,17 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { if (!_metadata) { return; } metadata = _metadata; + if (metadata?.restricted) { + const userId = msgStruct[1]; + // If userId is defined (not a private message) and the user + // is not a member of this restricted channel, prevent them + // from broadcasting to the pad until they have joined it + if (userId && !Server.channelContainsUser(channel.id, userId)) { + cb('EFORBIDDEN'); + return void w.abort(); + } + } + // don't write messages to expired channels if (checkExpired(Env, Server, channel)) { cb('EEXPIRED');