message: Treat the master push rule as authoritative
  Previously the push rule was ignored, leading to all kinds of interesting issues regarding notifications. This fixes those issues by giving the master push rule the authority it deserves for reasonable defaults.
  Part 2 of the fix for:
  *
  *
diff: @@ -15,12 +15,36 @@ limitations under the License.
  */
  import SettingController from "./SettingController";
  +import MatrixClientPeg from '../../MatrixClientPeg';
  +
  +// XXX: This feels wrong.
  +import PushProcessor from "matrix-js-sdk/lib/pushprocessor";
  +
  +function isMasterRuleEnabled() {
  + // Return the value of the master push rule as a default
  + const processor = new PushProcessor(MatrixClientPeg.get());
  + const masterRule = processor.getPushRuleById(".m.rule.master");
  +
  + if (!masterRule) {
  + console.warn("No master push rule! Notifications are disabled for this user.");
  + return false;
  + }
  +
  + // Why enabled == false means "enabled" is beyond me.
  + return !masterRule.enabled;
  +}
  export class NotificationsEnabledController extends SettingController {
  getValueOverride(level, roomId, calculatedValue) {
  const Notifier = require('../../Notifier'); // avoids cyclical references
  + if (!Notifier.isPossible()) return false;
  +
  + if (calculatedValue === null) {
  + console.log(isMasterRuleEnabled());
  + return isMasterRuleEnabled();
  + }
  - return calculatedValue && Notifier.isPossible();
  + return calculatedValue;
  }
  onChange(level, roomId, newValue) {
  @@ -35,15 +59,22 @@ export class NotificationsEnabledController extends SettingController {
  export class NotificationBodyEnabledController extends SettingController {
  getValueOverride(level, roomId, calculatedValue) {
  const Notifier = require('../../Notifier'); // avoids cyclical references
  + if (!Notifier.isPossible()) return false;
  +
  + if (calculatedValue === null) {
  + return isMasterRuleEnabled();
  + }
  - return calculatedValue && Notifier.isEnabled();
  + return calculatedValue;
  }
  }
  export class AudioNotificationsEnabledController extends SettingController {
  getValueOverride(level, roomId, calculatedValue) {
  const Notifier = require('../../Notifier'); // avoids cyclical references
  + if (!Notifier.isPossible()) return false;
  - return calculatedValue && Notifier.isEnabled();
  + // Note: Audio notifications are *not* enabled by default.
  + return calculatedValue;
  }
  }
  