podchat-browser
Version:
Javascript SDK to use POD's Chat Service - Browser Only
57 lines (46 loc) • 2.19 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var Validation = /*#__PURE__*/function () {
function Validation(thread) {
(0, _classCallCheck2["default"])(this, Validation);
this.thread = thread;
}
(0, _createClass2["default"])(Validation, [{
key: "checkTypeCodeIsValid",
value: function checkTypeCodeIsValid(params) {
var _this$_app$typeCodes, _this$_app$typeCodes$;
if (!(params !== null && params !== void 0 && params.typeCode)) {
return true;
}
return (params === null || params === void 0 ? void 0 : params.typeCode) === ((_this$_app$typeCodes = this._app.typeCodes) === null || _this$_app$typeCodes === void 0 ? void 0 : (_this$_app$typeCodes$ = _this$_app$typeCodes.getActiveTypeCode()) === null || _this$_app$typeCodes$ === void 0 ? void 0 : _this$_app$typeCodes$.typeCode);
}
}, {
key: "checkParameterIsValid",
value: function checkParameterIsValid(params) {
if (!(params !== null && params !== void 0 && params.cache) || params !== null && params !== void 0 && params.archived) {
return false;
}
if (!this.checkTypeCodeIsValid()) {
return false;
}
var invalidParams = ['query', 'name', 'username', 'cellphoneNumber', 'new', 'creatorCoreUserId', 'partnerCoreUserId', 'partnerCoreContactId', 'fromTime', 'toTime', 'isGroup', 'type'];
var hasForbiddenKeys = invalidParams.some(function (key) {
return Object.keys(params).includes(key);
});
return !hasForbiddenKeys;
}
}, {
key: "checkDataIsValid",
value: function checkDataIsValid(params, threads) {
return (threads === null || threads === void 0 ? void 0 : threads.length) >= params.count && !(threads !== null && threads !== void 0 && threads.includes(null));
}
}]);
return Validation;
}();
exports["default"] = Validation;