I think this should do it:
https://github.com/discourse/discourse-chat-integration/commit/945c0a6e4f2a844ce66be711d6342ef982541206
Let me know if it works for you