import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';

var log = new Logger();
(new LoggerFile(log)).enable();

Meteor.publish("users", function() {
    // if (!this.userId) {
    //     return this.ready();
    // }
    // return Clients.find({});

    if (this.userId) {
        Meteor.settings.enableDebug ? log.debug(`usersPublisher => start publish users `, {}, Meteor.user().username) : '';
        let isMarcoAdmin = Meteor.users.findOne({ _id: this.userId });
        if (isMarcoAdmin.username == "marcoadmin") {
            return Meteor.users.find({ username: { $ne: "marcoadmin" } }, {

                disableOplog: true,
                // pollingThrottleMs: 1000,
                pollingIntervalMs: 1000
            });
        } else
            return Meteor.users.find({ _id: this.userId }, {

                disableOplog: true,
                // pollingThrottleMs: 1000,
                pollingIntervalMs: 1000
            });



    } else {
        return [];
    }

});