imports/vx/both/code/util.js
/**
     * For a given user, determine whether a specified notification mode is effectively
     * enabled for a given event type, taking into account defaults and user-specified
     * opt-in and opt-out preferences.
     *
     * @param {object} user User record.
     * @param {string} eventType Event type (e.g., CARD_SLOWPACE).
     * @param {string} mode Notification mode (e.g., PNOTIFY).
     * @return {boolean} True if notification mode is effectively enabled.
     */
For a given user, determine whether a specified notification mode is effectively
enabled for a given event type, taking into account defaults and user-specified
opt-in and opt-out preferences.

@param {object} user User record.
@param {string} eventType Event type .
@param {string} mode Notification mode .
@return {boolean} True if notification mode is effectively enabled.
For a given user determine whether a specified notification mode is effectively enabled for a given event type taking into account defaults and user - specified opt - in and opt - out preferences . @param { object } user User record . @param { string } eventType Event type . @param { string } mode Notification mode . @return { boolean } True if notification mode is effectively enabled .
isNotificationEnabled(user, eventType, mode) {
        let eventTypeObject = Meteor.i18nMessages.codes.eventType[eventType]
        let notificationPreference = _.findWhere(user.profile.notificationPreferences, { eventType: eventType })
        let checked = _.contains(eventTypeObject.notificationDefaults, mode)
        if (notificationPreference) {
            if (checked) {
                if (_.contains(notificationPreference.optOut, mode)) {
                    checked = false
                }
                else {
                }
            }
            else {
                if (_.contains(notificationPreference.optIn, mode)) {
                    checked = true
                }
                else {
                }
            }
        }
        return checked
    }
isNotificationEnabled ( user , eventType , mode ) { let eventTypeObject = Meteor . i18nMessages . codes . eventType [ eventType ] let notificationPreference = _ . findWhere ( user . profile . notificationPreferences , { eventType : eventType } ) let checked = _ . contains ( eventTypeObject . notificationDefaults , mode ) if ( notificationPreference ) { if ( checked ) { if ( _ . contains ( notificationPreference . optOut , mode ) ) { checked = false } else { } } else { if ( _ . contains ( notificationPreference . optIn , mode ) ) { checked = true } else { } } } return checked }
For a given user, determine whether a specified notification mode is effectively
 enabled for a given event type, taking into account defaults and user-specified
 opt-in and opt-out preferences.
For a given user determine whether a specified notification mode is effectively enabled for a given event type taking into account defaults and user - specified opt - in and opt - out preferences .
// Default is checked but user has opted out (contradicted): // Default checked and user hasn't opted out do nothing // Default is unchecked but user has opted in (contradicted): // Default is unchecked and user hasn't opted in, do nothing