@devchitchat/chat 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -145,8 +145,15 @@ export function handleAdminBotTokenRevoke(ws, msg, ctx) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export function handleAdminBotSetChannels(ws, msg, ctx) {
|
|
148
|
-
const { botService, sendWs } = ctx
|
|
148
|
+
const { botService, sendWs, connections } = ctx
|
|
149
149
|
const { user_id, channel_ids } = msg.body || {}
|
|
150
150
|
botService.setBotChannels({ userId: user_id, channelIds: channel_ids, requestingUserId: ws.data.userId })
|
|
151
151
|
sendWs(ws, { t: 'admin.bot_updated', reply_to: msg.id, ok: true, body: { user_id } })
|
|
152
|
+
|
|
153
|
+
// Notify the bot's active WebSocket connection so it can re-join channels.
|
|
154
|
+
for (const [, conn] of connections) {
|
|
155
|
+
if (conn.data.userId === user_id) {
|
|
156
|
+
sendWs(conn, { t: 'bot.channels_updated', body: { user_id } })
|
|
157
|
+
}
|
|
158
|
+
}
|
|
152
159
|
}
|