ozserver
Version:
API for OZ
65 lines (53 loc) • 2.15 kB
JavaScript
var EventEmitter, Streak, exports,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
EventEmitter = require('events').EventEmitter;
Streak = (function(_super) {
__extends(Streak, _super);
function Streak() {}
Streak.prototype.isSocketReady = function(socket) {
var _ref;
if ((socket != null ? (_ref = socket._session) != null ? _ref.readyState : void 0 : void 0) != null) {
if (socket._session.readyState === 1) {
return true;
}
}
return false;
};
Streak.prototype.isRegionRight = function(client, data) {
var _ref, _ref1, _ref2;
if (((client != null ? (_ref = client.region) != null ? _ref.name : void 0 : void 0) != null) && ((data != null ? (_ref1 = data.post) != null ? (_ref2 = _ref1.region) != null ? _ref2.name : void 0 : void 0 : void 0) != null)) {
if (client.region.name === data.post.region.name) {
return true;
}
}
return false;
};
Streak.prototype.isClientIsAuthorOfPost = function(client, data) {
var _ref;
if (((client != null ? client.user_id : void 0) != null) && ((data != null ? (_ref = data.user) != null ? _ref.id : void 0 : void 0) != null)) {
if (client.user_id.toString() === data.user.id.toString()) {
if ((client.sessid != null) && ((data != null ? data.sessid : void 0) != null)) {
if (client.sessid.toString() === data.sessid.toString()) {
return true;
}
}
}
}
return false;
};
Streak.prototype.isPostedSuccess = function(data) {
var _ref;
if ((data != null ? (_ref = data.model) != null ? _ref.success : void 0 : void 0) != null) {
if (data.model.success === true) {
return true;
}
}
return false;
};
return Streak;
})(EventEmitter);
exports = module.exports = function() {
return new Streak();
};
exports.Streak = Streak;