DEV: Raise error when anon subscribes to PresenceChannels on login_required sites

DEV: Raise error when anon subscribes to PresenceChannels on login_required sites

In this situation, messagebus and the server-side Presence endpoints are unavailable, so it’s better to quit early in the JS

diff --git a/app/assets/javascripts/discourse/app/services/presence.js b/app/assets/javascripts/discourse/app/services/presence.js
index da639f1..d628603 100644
--- a/app/assets/javascripts/discourse/app/services/presence.js
+++ b/app/assets/javascripts/discourse/app/services/presence.js
@@ -389,6 +389,10 @@ export default class PresenceService extends Service {
   }
 
   async _subscribe(channelProxy, initialData = null) {
+    if (this.siteSettings.login_required && !this.currentUser) {
+      throw "Presence is only available to authenticated users on login-required sites";
+    }
+
     this._addSubscribed(channelProxy);
     const channelName = channelProxy.name;
     let state = this._presenceChannelStates[channelName];

GitHub sha: edc1378aed64ad2104e3f3b8393f294495b3fbd9

This commit appears in #14718 which was approved by markvanlan. It was merged by davidtaylorhq.