Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- (window.webpackJsonp = window.webpackJsonp || []).push([["vendors~Chat~RedesignChat"], {
- "./node_modules/agentkeepalive/browser.js" : function(mixin, doPost) {
- /**
- * @return {undefined}
- */
- function storeMixin() {
- }
- /** @type {function(): undefined} */
- mixin.exports = storeMixin;
- /** @type {function(): undefined} */
- mixin.exports.HttpsAgent = storeMixin;
- },
- "./node_modules/form-data/lib/browser.js" : function(mixin, doPost) {
- mixin.exports = "object" == typeof self ? self.FormData : window.FormData;
- },
- "./node_modules/lodash/_arrayAggregator.js" : function(mixin, doPost) {
- /**
- * @param {string} o
- * @param {?} h
- * @param {?} t
- * @param {?} c
- * @return {?}
- */
- mixin.exports = function(o, h, t, c) {
- /** @type {number} */
- var x = -1;
- var end = null == o ? 0 : o.length;
- for (; ++x < end;) {
- var i = o[x];
- h(c, i, t(i), o);
- }
- return c;
- };
- },
- "./node_modules/lodash/_arrayIncludesWith.js" : function(mixin, doPost) {
- /**
- * @param {string} o
- * @param {?} value
- * @param {?} process
- * @return {?}
- */
- mixin.exports = function(o, value, process) {
- /** @type {number} */
- var k = -1;
- var kl = null == o ? 0 : o.length;
- for (; ++k < kl;) {
- if (process(value, o[k])) {
- return true;
- }
- }
- return false;
- };
- },
- "./node_modules/lodash/_baseAggregator.js" : function(moduleDef, opts, validateCallback) {
- var callback = validateCallback("./node_modules/lodash/_baseEach.js");
- /**
- * @param {?} obj
- * @param {?} h
- * @param {?} t
- * @param {?} value
- * @return {?}
- */
- moduleDef.exports = function(obj, h, t, value) {
- return callback(obj, function(label, s, e) {
- h(value, label, t(label), e);
- }), value;
- };
- },
- "./node_modules/lodash/_baseDelay.js" : function(mixin, doPost) {
- /** @type {string} */
- var ERR_ACCESSORS_NOT_SUPPORTED = "Expected a function";
- /**
- * @param {!Function} a
- * @param {?} n
- * @param {?} s
- * @return {?}
- */
- mixin.exports = function(a, n, s) {
- if ("function" != typeof a) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- return setTimeout(function() {
- a.apply(void 0, s);
- }, n);
- };
- },
- "./node_modules/lodash/_baseDifference.js" : function(blob, id, require) {
- var User = require("./node_modules/lodash/_SetCache.js");
- var fn = require("./node_modules/lodash/_arrayIncludes.js");
- var sh = require("./node_modules/lodash/_arrayIncludesWith.js");
- var callback = require("./node_modules/lodash/_arrayMap.js");
- var $ = require("./node_modules/lodash/_baseUnary.js");
- var max = require("./node_modules/lodash/_cacheHas.js");
- /** @type {number} */
- var requiredLength = 200;
- /**
- * @param {!NodeList} e
- * @param {?} value
- * @param {string} d
- * @param {string} key
- * @return {?}
- */
- blob.exports = function(e, value, d, key) {
- /** @type {number} */
- var s = -1;
- var h = fn;
- /** @type {boolean} */
- var honorSkips = true;
- var p = e.length;
- /** @type {!Array} */
- var dimsWithHiers = [];
- var calls = value.length;
- if (!p) {
- return dimsWithHiers;
- }
- if (d) {
- value = callback(value, $(d));
- }
- if (key) {
- h = sh;
- /** @type {boolean} */
- honorSkips = false;
- } else {
- if (value.length >= requiredLength) {
- h = max;
- /** @type {boolean} */
- honorSkips = false;
- value = new User(value);
- }
- }
- e: for (; ++s < p;) {
- var f = e[s];
- var x = null == d ? f : d(f);
- if (f = key || 0 !== f ? f : 0, honorSkips && x == x) {
- var i = calls;
- for (; i--;) {
- if (value[i] === x) {
- continue e;
- }
- }
- dimsWithHiers.push(f);
- } else {
- if (!h(value, x, key)) {
- dimsWithHiers.push(f);
- }
- }
- }
- return dimsWithHiers;
- };
- },
- "./node_modules/lodash/_baseOrderBy.js" : function(blob, id, require) {
- var max = require("./node_modules/lodash/_arrayMap.js");
- var saturation = require("./node_modules/lodash/_baseIteratee.js");
- var karmaConfigModule = require("./node_modules/lodash/_baseMap.js");
- var sparqlQuery = require("./node_modules/lodash/_baseSortBy.js");
- var min = require("./node_modules/lodash/_baseUnary.js");
- var nest = require("./node_modules/lodash/_compareMultiple.js");
- var layer = require("./node_modules/lodash/identity.js");
- /**
- * @param {?} config
- * @param {string} value
- * @param {?} data
- * @return {?}
- */
- blob.exports = function(config, value, data) {
- /** @type {number} */
- var index = -1;
- value = max(value.length ? value : [layer], min(saturation));
- var aconf = karmaConfigModule(config, function(appid, canCreateDiscussions, isSlidingUp) {
- return {
- criteria : max(value, function(t) {
- return t(appid);
- }),
- index : ++index,
- value : appid
- };
- });
- return sparqlQuery(aconf, function(results, elem) {
- return nest(results, elem, data);
- });
- };
- },
- "./node_modules/lodash/_baseReduce.js" : function(mixin, doPost) {
- /**
- * @param {?} names
- * @param {?} callback
- * @param {?} accumulator
- * @param {number} initAccum
- * @param {?} req
- * @return {?}
- */
- mixin.exports = function(names, callback, accumulator, initAccum, req) {
- return req(names, function(value, index, collection) {
- accumulator = initAccum ? (initAccum = false, value) : callback(accumulator, value, index, collection);
- }), accumulator;
- };
- },
- "./node_modules/lodash/_baseSortBy.js" : function(mixin, doPost) {
- /**
- * @param {?} array
- * @param {?} sortFn
- * @return {?}
- */
- mixin.exports = function(array, sortFn) {
- var i = array.length;
- array.sort(sortFn);
- for (; i--;) {
- array[i] = array[i].value;
- }
- return array;
- };
- },
- "./node_modules/lodash/_baseUniq.js" : function(blob, id, require) {
- var ElementCreator = require("./node_modules/lodash/_SetCache.js");
- var DateTime = require("./node_modules/lodash/_arrayIncludes.js");
- var diff = require("./node_modules/lodash/_arrayIncludesWith.js");
- var a2 = require("./node_modules/lodash/_cacheHas.js");
- var resolve = require("./node_modules/lodash/_createSet.js");
- var error = require("./node_modules/lodash/_setToArray.js");
- /** @type {number} */
- var maxNodes = 200;
- /**
- * @param {!NodeList} data
- * @param {boolean} err
- * @param {string} r
- * @return {?}
- */
- blob.exports = function(data, err, r) {
- /** @type {number} */
- var n = -1;
- var d = DateTime;
- var nodeCount = data.length;
- /** @type {boolean} */
- var nodes = true;
- /** @type {!Array} */
- var body = [];
- /** @type {!Array} */
- var result = body;
- if (r) {
- /** @type {boolean} */
- nodes = false;
- d = diff;
- } else {
- if (nodeCount >= maxNodes) {
- var statusCode = err ? null : resolve(data);
- if (statusCode) {
- return error(statusCode);
- }
- /** @type {boolean} */
- nodes = false;
- d = a2;
- result = new ElementCreator;
- } else {
- /** @type {!Array} */
- result = err ? [] : body;
- }
- }
- e: for (; ++n < nodeCount;) {
- var id = data[n];
- var key = err ? err(id) : id;
- if (id = r || 0 !== id ? id : 0, nodes && key == key) {
- var index = result.length;
- for (; index--;) {
- if (result[index] === key) {
- continue e;
- }
- }
- if (err) {
- result.push(key);
- }
- body.push(id);
- } else {
- if (!d(result, key, r)) {
- if (result !== body) {
- result.push(key);
- }
- body.push(id);
- }
- }
- }
- return body;
- };
- },
- "./node_modules/lodash/_compareAscending.js" : function(blob, type, exclude) {
- var extend = exclude("./node_modules/lodash/isSymbol.js");
- /**
- * @param {number} obj
- * @param {number} value
- * @return {?}
- */
- blob.exports = function(obj, value) {
- if (obj !== value) {
- /** @type {boolean} */
- var t = void 0 !== obj;
- /** @type {boolean} */
- var reverseIsSingle = null === obj;
- /** @type {boolean} */
- var xy = obj == obj;
- var props = extend(obj);
- /** @type {boolean} */
- var reverseValue = void 0 !== value;
- /** @type {boolean} */
- var isTranslucent = null === value;
- /** @type {boolean} */
- var fallback = value == value;
- var f = extend(value);
- if (!isTranslucent && !f && !props && obj > value || props && reverseValue && fallback && !isTranslucent && !f || reverseIsSingle && reverseValue && fallback || !t && fallback || !xy) {
- return 1;
- }
- if (!reverseIsSingle && !props && !f && obj < value || f && t && xy && !reverseIsSingle && !props || isTranslucent && t && xy || !reverseValue && xy || !fallback) {
- return -1;
- }
- }
- return 0;
- };
- },
- "./node_modules/lodash/_compareMultiple.js" : function(blob, options, seriesStackIndexCallback) {
- var compareFunction = seriesStackIndexCallback("./node_modules/lodash/_compareAscending.js");
- /**
- * @param {!Object} left
- * @param {!Object} right
- * @param {!NodeList} result
- * @return {?}
- */
- blob.exports = function(left, right, result) {
- /** @type {number} */
- var i = -1;
- var a = left.criteria;
- var b = right.criteria;
- var l = a.length;
- var goal = result.length;
- for (; ++i < l;) {
- var WBP_EOT = compareFunction(a[i], b[i]);
- if (WBP_EOT) {
- return i >= goal ? WBP_EOT : WBP_EOT * ("desc" == result[i] ? -1 : 1);
- }
- }
- return left.index - right.index;
- };
- },
- "./node_modules/lodash/_createAggregator.js" : function(blob, id, require) {
- var b = require("./node_modules/lodash/_arrayAggregator.js");
- var forIn = require("./node_modules/lodash/_baseAggregator.js");
- var f = require("./node_modules/lodash/_baseIteratee.js");
- var isArray = require("./node_modules/lodash/isArray.js");
- /**
- * @param {?} query
- * @param {boolean} select
- * @return {?}
- */
- blob.exports = function(query, select) {
- return function(a, val) {
- var merge = isArray(a) ? b : forIn;
- var start = select ? select() : {};
- return merge(a, query, f(val, 2), start);
- };
- };
- },
- "./node_modules/lodash/_createSet.js" : function(module, exports, __webpack_require__) {
- var Date = __webpack_require__("./node_modules/lodash/_Set.js");
- var _bling = __webpack_require__("./node_modules/lodash/noop.js");
- var isSameMinute = __webpack_require__("./node_modules/lodash/_setToArray.js");
- var storeMixin = Date && 1 / isSameMinute(new Date([, -0]))[1] == 1 / 0 ? function(expiredTo) {
- return new Date(expiredTo);
- } : _bling;
- module.exports = storeMixin;
- },
- "./node_modules/lodash/_iteratorToArray.js" : function(mixin, doPost) {
- /**
- * @param {!Node} e
- * @return {?}
- */
- mixin.exports = function(e) {
- var _s;
- /** @type {!Array} */
- var _arr = [];
- for (; !(_s = e.next()).done;) {
- _arr.push(_s.value);
- }
- return _arr;
- };
- },
- "./node_modules/lodash/chunk.js" : function(blob, callback, jQuery) {
- var set = jQuery("./node_modules/lodash/_baseSlice.js");
- var next = jQuery("./node_modules/lodash/_isIterateeCall.js");
- var map = jQuery("./node_modules/lodash/toInteger.js");
- /** @type {function(?): number} */
- var nativeCeil = Math.ceil;
- /** @type {function(...?): number} */
- var max = Math.max;
- /**
- * @param {string} name
- * @param {number} size
- * @param {boolean} err
- * @return {?}
- */
- blob.exports = function(name, size, err) {
- /** @type {number} */
- size = (err ? next(name, size, err) : void 0 === size) ? 1 : max(map(size), 0);
- var length = null == name ? 0 : name.length;
- if (!length || size < 1) {
- return [];
- }
- /** @type {number} */
- var value = 0;
- /** @type {number} */
- var off = 0;
- /** @type {!Array} */
- var data = Array(nativeCeil(length / size));
- for (; value < length;) {
- data[off++] = set(name, value, value = value + size);
- }
- return data;
- };
- },
- "./node_modules/lodash/defer.js" : function(module, metadata, packageSuccess) {
- var isCommercial = packageSuccess("./node_modules/lodash/_baseDelay.js");
- var storeMixin = packageSuccess("./node_modules/lodash/_baseRest.js")(function(tile, leftFence) {
- return isCommercial(tile, 1, leftFence);
- });
- module.exports = storeMixin;
- },
- "./node_modules/lodash/difference.js" : function(mixin, doPost, __webpack_require__) {
- var normalise = __webpack_require__("./node_modules/lodash/_baseDifference.js");
- var parse = __webpack_require__("./node_modules/lodash/_baseFlatten.js");
- var createBracketMap = __webpack_require__("./node_modules/lodash/_baseRest.js");
- var isArray = __webpack_require__("./node_modules/lodash/isArrayLikeObject.js");
- var m = createBracketMap(function(e, argvString) {
- return isArray(e) ? normalise(e, parse(argvString, 1, isArray, true)) : [];
- });
- mixin.exports = m;
- },
- "./node_modules/lodash/first.js" : function(module, object, instantiate) {
- module.exports = instantiate("./node_modules/lodash/head.js");
- },
- "./node_modules/lodash/head.js" : function(mixin, doPost) {
- /**
- * @param {!Array} value
- * @return {?}
- */
- mixin.exports = function(value) {
- return value && value.length ? value[0] : void 0;
- };
- },
- "./node_modules/lodash/keyBy.js" : function(module, metadata, packageSuccess) {
- var updateSiteUsage = packageSuccess("./node_modules/lodash/_baseAssignValue.js");
- var storeMixin = packageSuccess("./node_modules/lodash/_createAggregator.js")(function(siteData, leftFence, size) {
- updateSiteUsage(siteData, size, leftFence);
- });
- module.exports = storeMixin;
- },
- "./node_modules/lodash/reduce.js" : function(blob, id, require) {
- var str = require("./node_modules/lodash/_arrayReduce.js");
- var CheckDailyStat = require("./node_modules/lodash/_baseEach.js");
- var $ = require("./node_modules/lodash/_baseIteratee.js");
- var model = require("./node_modules/lodash/_baseReduce.js");
- var isArray = require("./node_modules/lodash/isArray.js");
- /**
- * @param {?} val
- * @param {?} el
- * @param {?} data
- * @return {?}
- */
- blob.exports = function(val, el, data) {
- var value = isArray(val) ? str : model;
- /** @type {boolean} */
- var transformValue = arguments.length < 3;
- return value(val, $(el, 4), data, transformValue, CheckDailyStat);
- };
- },
- "./node_modules/lodash/sortBy.js" : function(mixin, data, filter) {
- var even = filter("./node_modules/lodash/_baseFlatten.js");
- var fn = filter("./node_modules/lodash/_baseOrderBy.js");
- var isMatch = filter("./node_modules/lodash/_baseRest.js");
- var drawCorners = filter("./node_modules/lodash/_isIterateeCall.js");
- var m = isMatch(function(params, n) {
- if (null == params) {
- return [];
- }
- var argl = n.length;
- return argl > 1 && drawCorners(params, n[0], n[1]) ? n = [] : argl > 2 && drawCorners(n[0], n[1], n[2]) && (n = [n[0]]), fn(params, even(n, 1), []);
- });
- mixin.exports = m;
- },
- "./node_modules/lodash/toArray.js" : function(blob, id, require) {
- var component = require("./node_modules/lodash/_Symbol.js");
- var extend = require("./node_modules/lodash/_copyArray.js");
- var toInteger = require("./node_modules/lodash/_getTag.js");
- var sphereKnn = require("./node_modules/lodash/isArrayLike.js");
- var isArray = require("./node_modules/lodash/isString.js");
- var sparqlQuery = require("./node_modules/lodash/_iteratorToArray.js");
- var type = require("./node_modules/lodash/_mapToArray.js");
- var x_rbtn_last = require("./node_modules/lodash/_setToArray.js");
- var flatten = require("./node_modules/lodash/_stringToArray.js");
- var x_rbtn_item = require("./node_modules/lodash/values.js");
- /** @type {string} */
- var color = "[object Map]";
- /** @type {string} */
- var last = "[object Set]";
- var iteratorSymbol = component ? component.iterator : void 0;
- /**
- * @param {?} value
- * @return {?}
- */
- blob.exports = function(value) {
- if (!value) {
- return [];
- }
- if (sphereKnn(value)) {
- return isArray(value) ? flatten(value) : extend(value);
- }
- if (iteratorSymbol && value[iteratorSymbol]) {
- return sparqlQuery(value[iteratorSymbol]());
- }
- var i = toInteger(value);
- return (i == color ? type : i == last ? x_rbtn_last : x_rbtn_item)(value);
- };
- },
- "./node_modules/lodash/uniq.js" : function(moduleDef, fn, after) {
- var cb = after("./node_modules/lodash/_baseUniq.js");
- /**
- * @param {!Array} data
- * @return {?}
- */
- moduleDef.exports = function(data) {
- return data && data.length ? cb(data) : [];
- };
- },
- "./node_modules/lodash/uniqBy.js" : function(moduleDef, opts, require) {
- var render = require("./node_modules/lodash/_baseIteratee.js");
- var cb = require("./node_modules/lodash/_baseUniq.js");
- /**
- * @param {!Array} data
- * @param {?} outFile
- * @return {?}
- */
- moduleDef.exports = function(data, outFile) {
- return data && data.length ? cb(data, render(outFile, 2)) : [];
- };
- },
- "./node_modules/sendbird/SendBird.min.js" : function(blob, id, require) {
- if ("undefined" != typeof self) {
- self;
- }
- blob.exports = function() {
- /**
- * @return {undefined}
- */
- function FormData() {
- /** @type {boolean} */
- this.oldIE = true;
- /** @type {string} */
- this.boundary = "--------FormData" + Math.random();
- /** @type {!Array} */
- this._fields = [];
- }
- var console;
- /** @type {boolean} */
- var t = false;
- /** @type {string} */
- var ref1 = "wss://ws.sendbird.com";
- /** @type {string} */
- var combined = "https://api.sendbird.com";
- try {
- /** @type {!Console} */
- console = window.console || {
- log : function() {
- }
- };
- } catch (e) {
- console = {
- log : function() {
- }
- };
- }
- /** @type {string} */
- var i = "undefined";
- try {
- /** @type {string} */
- i = navigator.userAgent.replace(/,/g, ".");
- } catch (e) {
- /** @type {string} */
- i = "undefined";
- }
- var Model;
- /** @type {string} */
- var spec = "JS," + i + ",3.0.69,";
- var b = function() {
- try {
- if (document && 9 === document.documentMode) {
- return true;
- }
- } catch (e) {
- return false;
- }
- return false;
- }();
- var c = function() {
- try {
- if (document && document.documentMode <= 8) {
- return true;
- }
- } catch (e) {
- return false;
- }
- return false;
- }();
- if (b || c) {
- if ("function" != typeof String.prototype.trim) {
- /**
- * @return {string}
- * @this {!String}
- */
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/g, "");
- };
- }
- if ("function" != typeof Array.prototype.forEach) {
- /**
- * @param {(function(this:S, T, number, !Array<T>): ?|null)} callback
- * @param {(S|null)=} p1
- * @return {undefined}
- * @template T,S
- */
- Array.prototype.forEach = function(callback) {
- /** @type {number} */
- var i = 0;
- for (; i < this.length; i++) {
- callback.apply(this, [this[i], i, this]);
- }
- };
- }
- /**
- * @param {string} key
- * @param {!Object} value
- * @return {undefined}
- */
- FormData.prototype.append = function(key, value) {
- this._fields.push([key, value]);
- };
- /**
- * @return {?}
- */
- FormData.prototype.toString = function() {
- var boundary = this.boundary;
- /** @type {string} */
- var body = "";
- return this._fields.forEach(function(running) {
- if (body = body + ("--" + boundary + "\r\n"), running[1].name) {
- var storage = running[1];
- /** @type {string} */
- body = body + ('Content-Disposition: form-data; name="' + running[0] + '"; filename="' + storage.name + '"\r\n');
- /** @type {string} */
- body = body + "Content-Transfer-Encoding: base64\r\n";
- /** @type {string} */
- body = body + ("Content-Type: " + storage.type + "\r\n\r\n");
- /** @type {string} */
- body = body + (storage.base64 + "\r\n");
- } else {
- /** @type {string} */
- body = body + ('Content-Disposition: form-data; name="' + running[0] + '";\r\n\r\n');
- /** @type {string} */
- body = body + (running[1] + "\r\n");
- }
- }), body = body + ("--" + boundary + "--");
- };
- Model = FormData;
- } else {
- if ("undefined" == typeof window && "undefined" == typeof FormData) {
- try {
- Model = require("./node_modules/form-data/lib/browser.js");
- } catch (e) {
- }
- }
- }
- /**
- * @param {!Object} chunk
- * @param {!Object} output
- * @param {!Function} callback
- * @return {undefined}
- */
- var callback = function(chunk, output, callback) {
- if (callback && "function" == typeof callback) {
- if (chunk) {
- /** @type {null} */
- var internalError = null;
- try {
- /** @type {*} */
- internalError = JSON.parse(chunk.response);
- } catch (e) {
- }
- var stdout = internalError ? internalError.message : null;
- var mm2 = internalError ? internalError.code : null;
- callback(output, new Date(stdout, mm2));
- } else {
- callback(output, null);
- }
- }
- };
- /**
- * @param {!Object} obj
- * @return {?}
- */
- var check = function(obj) {
- var i;
- for (i in obj) {
- if (obj.hasOwnProperty(i)) {
- return false;
- }
- }
- return Array.isArray(obj) ? JSON.stringify(obj) === JSON.stringify([]) : JSON.stringify(obj) === JSON.stringify({});
- };
- /**
- * @param {number} val
- * @return {?}
- */
- var cb = function(val) {
- try {
- if ("number" == typeof val) {
- return true;
- }
- if ("string" == typeof val) {
- return /^\d+$/.test(val);
- }
- } catch (e) {
- return t && console.error(e), false;
- }
- };
- var fn = function() {
- /**
- * @return {undefined}
- */
- var subclass = function() {
- };
- return function(parentClass, childClass) {
- subclass.prototype = new parentClass;
- childClass.prototype = new subclass;
- childClass.super = parentClass.prototype;
- /** @type {!Function} */
- childClass.prototype.constructor = childClass;
- };
- }();
- /**
- * @param {string} a
- * @param {number} m
- * @return {?}
- */
- var Date = function(a, m) {
- return this.name = "SendBirdException", this.code = m || 0, this.message = a, this;
- };
- fn(Error, Date);
- var R = {
- MessageTypeFilter : {
- ALL : 0,
- USER : 1,
- FILE : 2,
- ADMIN : 3
- }
- };
- /**
- * @param {!Array} a
- * @return {?}
- */
- var f = function(a) {
- return Object.keys(a).forEach(function(i) {
- if (null !== a[i] && void 0 !== a[i] && "object" == typeof a[i]) {
- a[i] = f(a[i]);
- }
- }), Object.freeze(a);
- };
- /**
- * @param {?} obj
- * @return {?}
- */
- var $ = function(obj) {
- return JSON.parse(JSON.stringify(obj));
- };
- /**
- * @param {!Object} self
- * @param {number} index
- * @param {number} v
- * @return {undefined}
- */
- var log = function(self, index, v) {
- try {
- if ("number" == typeof index && index >= 0) {
- if ("all" === self.myCountPreference || "unread_message_count_only" === self.myCountPreference) {
- if (self.isSuper) {
- /** @type {number} */
- self.unreadMessageCount = index >= 1 ? 1 : 0;
- } else {
- /** @type {number} */
- self.unreadMessageCount = index;
- }
- } else {
- /** @type {number} */
- self.unreadMessageCount = 0;
- }
- }
- if ("number" == typeof v && v >= 0) {
- if ("all" === self.myCountPreference || "unread_mention_count_only" === self.myCountPreference) {
- /** @type {number} */
- self.unreadMentionCount = v;
- } else {
- /** @type {number} */
- self.unreadMentionCount = 0;
- }
- }
- } catch (e) {
- }
- };
- /**
- * @return {?}
- */
- var init = function() {
- var inputData;
- var crawler = {};
- try {
- inputData = "undefined" == typeof window ? require("./node_modules/xhr2/lib/browser.js") : null;
- } catch (n) {
- /** @type {null} */
- inputData = null;
- }
- if (inputData) {
- try {
- var Sia = require("./node_modules/agentkeepalive/browser.js");
- var Worker = require("./node_modules/agentkeepalive/browser.js").HttpsAgent;
- var timeStart = new Sia({
- keepAlive : true,
- timeout : 6e4,
- keepAliveTimeout : 6e4
- });
- crawler.httpAgent = timeStart;
- var sanitise = new Worker({
- keepAlive : true,
- timeout : 6e4,
- keepAliveTimeout : 6e4
- });
- crawler.httpsAgent = sanitise;
- } catch (e) {
- }
- }
- /**
- * @return {?}
- */
- var cb = function() {
- var result;
- return inputData ? (result = new inputData).nodejsSet(crawler) : result = new XMLHttpRequest, result;
- };
- /**
- * @param {string} e
- * @param {?} data
- * @param {string} method
- * @param {!Object} values
- * @param {!Function} doc
- * @return {undefined}
- */
- var get = function(e, data, method, values, doc) {
- var xhr = cb();
- xhr.open(method, e);
- /**
- * @return {undefined}
- */
- xhr.onload = function() {
- if (xhr.status >= 200 && xhr.status < 400) {
- /** @type {boolean} */
- var e = false;
- /** @type {null} */
- var stderr = null;
- try {
- /** @type {*} */
- stderr = JSON.parse(xhr.responseText);
- } catch (n) {
- /** @type {boolean} */
- e = true;
- }
- if (e) {
- callback(new Date("Request failed.", concat.REQUEST_FAILED), null, doc);
- } else {
- callback(null, stderr, doc);
- }
- } else {
- callback({
- status : xhr.status,
- statusText : xhr.statusText,
- response : xhr.responseText
- }, null, doc);
- }
- };
- /**
- * @return {undefined}
- */
- xhr.onerror = function() {
- callback({
- status : 404,
- statusText : "There was a connection error",
- response : JSON.stringify({
- message : "There was a connection error",
- code : concat.NETWORK_ERROR
- })
- }, null, doc);
- };
- try {
- var i;
- for (i in values) {
- xhr.setRequestHeader(i, values[i] ? values[i] : "sendbird");
- }
- } catch (e) {
- }
- try {
- switch(method) {
- case "get":
- case "GET":
- xhr.send();
- break;
- default:
- if ("undefined" != typeof FormData && FormData && data instanceof FormData || void 0 !== Model && Model && data instanceof Model) {
- if (data.oldIE) {
- xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + data.boundary);
- xhr.send(data.toString());
- } else {
- xhr.send(data);
- }
- } else {
- xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
- xhr.send(JSON.stringify(data));
- }
- }
- } catch (size_buffer) {
- if (t) {
- console.log("request.send() fail: ", size_buffer);
- }
- }
- };
- /** @type {boolean} */
- var lastTrackInfoUrl = false;
- /**
- * @param {?} key
- * @param {?} name
- * @param {string} value
- * @return {undefined}
- */
- var callback = function(key, name, value) {
- if (value && "function" == typeof value) {
- if (void 0 === name) {
- /** @type {null} */
- name = null;
- }
- if (void 0 === key) {
- /** @type {null} */
- key = null;
- }
- if (lastTrackInfoUrl) {
- value(name, key);
- } else {
- value(key, name);
- }
- }
- };
- /** @type {string} */
- var path = "";
- /** @type {number} */
- var retries = 0;
- /** @type {number} */
- var ms = 0;
- /**
- * @param {!Object} result
- * @return {undefined}
- */
- var $ = function(result) {
- /**
- * @return {?}
- */
- this.isOpenChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_OPEN;
- };
- /**
- * @return {?}
- */
- this.isGroupChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_GROUP;
- };
- /**
- * @return {?}
- */
- this.isUserMessage = function() {
- return this.messageType === $.MESSAGE_TYPE_USER;
- };
- /**
- * @return {?}
- */
- this.isAdminMessage = function() {
- return this.messageType === $.MESSAGE_TYPE_ADMIN;
- };
- /**
- * @return {?}
- */
- this.isFileMessage = function() {
- return this.messageType === $.MESSAGE_TYPE_FILE;
- };
- /**
- * @param {!Object} res
- * @return {undefined}
- */
- this._update = function(res) {
- /** @type {number} */
- this.messageId = res.hasOwnProperty("msg_id") ? parseInt(res.msg_id) : 0;
- /** @type {string} */
- this.channelUrl = res.hasOwnProperty("channel_url") ? String(res.channel_url) : "";
- /** @type {number} */
- this.createdAt = res.hasOwnProperty("ts") ? parseInt(res.ts) : 0;
- /** @type {number} */
- this.updatedAt = res.hasOwnProperty("updated_at") ? parseInt(res.updated_at) : 0;
- /** @type {string} */
- this.channelType = res.hasOwnProperty("channel_type") ? String(res.channel_type) : update.CHANNEL_TYPE_GROUP;
- this.mentionType = res.hasOwnProperty("mention_type") ? res.mention_type : UserService.MentionType.USERS;
- var $scope = this;
- /** @type {!Array} */
- $scope.mentionedUsers = [];
- if (res.hasOwnProperty("mentioned_users")) {
- res.mentioned_users.forEach(function(options) {
- var c = new client(options);
- $scope.mentionedUsers.push(c);
- });
- }
- };
- /**
- * @return {?}
- */
- this.serialize = function() {
- /** @type {*} */
- var params = JSON.parse(JSON.stringify(this));
- return params.hasOwnProperty("_sender") && (params.sender = params._sender, delete params._sender), f(params);
- };
- /** @type {string} */
- this.messageType = $.MESSAGE_TYPE_BASE;
- if (result) {
- this._update(result);
- }
- };
- /**
- * @param {!Object} data
- * @param {?} input
- * @return {?}
- */
- $.build = function(data, input) {
- if (!data) {
- return null;
- }
- var d;
- var e;
- var n;
- var type;
- var options;
- var h;
- var callback;
- var version;
- var id;
- var title;
- switch(data.type) {
- case "MESG":
- return d = new client(data.user), e = parseInt(data.message_id), n = String(data.message), type = String(data.data), options = parseInt(data.created_at), h = parseInt(data.updated_at), callback = data.hasOwnProperty("custom_type") ? String(data.custom_type) : "", version = data.hasOwnProperty("translations") ? data.translations : {}, id = data.hasOwnProperty("mention_type") ? data.mention_type : UserService.MentionType.USERS, title = data.mentioned_users, new self(self.build("", e,
- d, input, n, type, callback, version, options, h, id, title));
- case "FILE":
- d = new client(data.user);
- /** @type {number} */
- e = parseInt(data.message_id);
- /** @type {string} */
- n = String(data.message);
- /** @type {number} */
- options = parseInt(data.created_at);
- /** @type {number} */
- h = parseInt(data.updated_at);
- /** @type {string} */
- callback = data.hasOwnProperty("custom_type") ? String(data.custom_type) : "";
- id = data.hasOwnProperty("mention_type") ? data.mention_type : UserService.MentionType.USERS;
- title = data.mentioned_users;
- var file = data.file;
- /** @type {string} */
- var key = String(file.url);
- /** @type {string} */
- var result = String(file.name);
- /** @type {string} */
- var NINETY_EIGHT_HOURS = String(file.type);
- /** @type {number} */
- var clientApiUrl = parseInt(file.size) || 0;
- /** @type {string} */
- type = String(file.data);
- var interceptedDescriptors = data.hasOwnProperty("thumbnails") ? data.thumbnails : [];
- var TMP_FILENAME = !!data.hasOwnProperty("require_auth") && data.require_auth;
- return new test(test.build("", e, d, input, key, result, NINETY_EIGHT_HOURS, clientApiUrl, type, callback, options, interceptedDescriptors, TMP_FILENAME, h, id, title));
- case "BRDM":
- case "ADMM":
- return e = parseInt(data.message_id), n = String(data.message), type = String(data.data), options = parseInt(data.created_at), h = parseInt(data.updated_at), callback = data.hasOwnProperty("custom_type") ? String(data.custom_type) : "", version = data.hasOwnProperty("translations") ? data.translations : {}, id = data.hasOwnProperty("mention_type") ? data.mention_type : UserService.MentionType.USERS, title = data.mentioned_users, new logger(logger.build(e, input, n, type, callback, version,
- options, h, id, title));
- }
- return null;
- };
- /** @type {string} */
- $.MESSAGE_TYPE_BASE = "base";
- /** @type {string} */
- $.MESSAGE_TYPE_ADMIN = "admin";
- /** @type {string} */
- $.MESSAGE_TYPE_USER = "user";
- /** @type {string} */
- $.MESSAGE_TYPE_FILE = "file";
- /**
- * @param {string} options
- * @return {undefined}
- */
- var logger = function(options) {
- /** @type {string} */
- this.messageType = $.MESSAGE_TYPE_ADMIN;
- if (options) {
- this._update(options);
- /** @type {string} */
- this.message = String(options.message);
- /** @type {string} */
- this.data = options.hasOwnProperty("data") ? String(options.data) : "";
- /** @type {string} */
- this.customType = options.hasOwnProperty("custom_type") ? String(options.custom_type) : "";
- this.translations = options.hasOwnProperty("translations") ? options.translations : {};
- }
- };
- fn($, logger);
- /**
- * @param {string} e
- * @param {!Object} value
- * @param {string} p
- * @param {!Object} id
- * @param {string} n
- * @param {string} a
- * @param {number} i
- * @param {number} url
- * @param {number} key
- * @param {!Object} type
- * @return {?}
- */
- logger.build = function(e, value, p, id, n, a, i, url, key, type) {
- var data = {
- msg_id : e,
- channel_url : value.url,
- channel_type : value.channelType === update.CHANNEL_TYPE_OPEN ? update.CHANNEL_TYPE_OPEN : update.CHANNEL_TYPE_GROUP,
- ts : i,
- updated_at : url,
- message : p,
- data : id
- };
- return n && (data.custom_type = n), a && (data.translations = a), data.mention_type = key, data.mentioned_users = [], type && (data.mentioned_users = type), data;
- };
- /**
- * @param {?} window
- * @return {?}
- */
- logger.buildFromSerializedData = function(window) {
- var self = $(window);
- /** @type {!Array} */
- var signal = [];
- return self.mentionedUsers.forEach(function($scope) {
- signal.push(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName));
- }), new logger(logger.build(self.messageId, {
- url : self.channelUrl,
- channelType : self.channelType
- }, self.message, self.data, self.customType, self.translations, self.createdAt, self.updatedAt, self.mentionType, signal));
- };
- /**
- * @param {!Object} options
- * @return {undefined}
- */
- var self = function(options) {
- /** @type {string} */
- this.messageType = $.MESSAGE_TYPE_USER;
- if (options) {
- this._update(options);
- /** @type {string} */
- this.message = String(options.message);
- /** @type {string} */
- this.data = options.hasOwnProperty("data") ? String(options.data) : "";
- this._sender = new client(options.user);
- if (c) {
- this.sender = this._sender;
- } else {
- Object.defineProperty(this, "sender", {
- get : function() {
- if (setup.getInstance().Options.useMemberAsMessageSender && this.isGroupChannel()) {
- var self = link.cachedChannels[this.channelUrl];
- if (self) {
- var data = self.memberMap[this._sender.userId];
- if (data) {
- if (this._sender.nickname !== data.nickname) {
- this._sender.nickname = data.nickname;
- }
- if (this._sender.profileUrl !== data.profileUrl) {
- this._sender.profileUrl = data.profileUrl;
- }
- if (this._sender.metaData !== data.metaData) {
- this._sender.metaData = data.metaData;
- }
- }
- }
- }
- return this._sender;
- },
- set : function(sender) {
- /** @type {string} */
- this._sender = sender;
- }
- });
- }
- /** @type {string} */
- this.reqId = options.hasOwnProperty("req_id") ? String(options.req_id) : "";
- /** @type {string} */
- this.customType = options.hasOwnProperty("custom_type") ? String(options.custom_type) : "";
- this.translations = options.hasOwnProperty("translations") ? options.translations : {};
- }
- };
- fn($, self);
- /**
- * @param {string} e
- * @param {?} id
- * @param {!Object} data
- * @param {!Object} value
- * @param {string} name
- * @param {string} event
- * @param {string} i
- * @param {number} url
- * @param {number} type
- * @param {!Object} key
- * @param {string} obj
- * @param {!Object} args
- * @param {string} path
- * @return {?}
- */
- self.build = function(e, id, data, value, name, event, i, url, type, key, obj, args, path) {
- var params = {};
- /** @type {string} */
- params.req_id = e;
- params.msg_id = id;
- params.channel_url = value.url;
- /** @type {string} */
- params.channel_type = value.channelType === update.CHANNEL_TYPE_OPEN ? update.CHANNEL_TYPE_OPEN : update.CHANNEL_TYPE_GROUP;
- /** @type {number} */
- params.ts = type;
- /** @type {!Object} */
- params.updated_at = key;
- /** @type {string} */
- params.message = name;
- if (event) {
- /** @type {string} */
- params.data = event;
- }
- if (i) {
- /** @type {string} */
- params.custom_type = i;
- }
- if (url) {
- /** @type {number} */
- params.translations = url;
- }
- var user = {};
- user.user_id = data.userId;
- user.nickname = data.nickname;
- user.profile_url = data.profileUrl;
- try {
- /** @type {*} */
- user.metadata = "string" == typeof data.metaData ? JSON.parse(data.metaData) : data.metaData;
- } catch (e) {
- user.metadata = {};
- }
- return params.user = user, params.mention_type = UserService.MentionType.USERS, obj && (params.mention_type = obj), params.mentioned_users = [], args && (params.mentioned_users = args), path && (params.mentioned_user_ids = path), params;
- };
- /**
- * @param {?} e
- * @return {?}
- */
- self.buildFromSerializedData = function(e) {
- var data = $(e);
- /** @type {!Array} */
- var title = [];
- return data.mentionedUsers.forEach(function($scope) {
- title.push(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName));
- }), new self(self.build(data.reqId, data.messageId, data.sender, {
- url : data.channelUrl,
- channelType : data.channelType
- }, data.message, data.data, data.customType, data.translations, data.createdAt, data.updatedAt, data.mentionType, title));
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- var test = function(data) {
- if (this.messageType = $.MESSAGE_TYPE_FILE, data && (this._update(data), this._sender = new client(data.user), c ? this.sender = this._sender : Object.defineProperty(this, "sender", {
- get : function() {
- if (setup.getInstance().Options.useMemberAsMessageSender && this.isGroupChannel()) {
- var self = link.cachedChannels[this.channelUrl];
- if (self) {
- var data = self.memberMap[this._sender.userId];
- if (data) {
- if (this._sender.nickname !== data.nickname) {
- this._sender.nickname = data.nickname;
- }
- if (this._sender.profileUrl !== data.profileUrl) {
- this._sender.profileUrl = data.profileUrl;
- }
- if (this._sender.metaData !== data.metaData) {
- this._sender.metaData = data.metaData;
- }
- }
- }
- }
- return this._sender;
- },
- set : function(sender) {
- /** @type {string} */
- this._sender = sender;
- }
- }), this.requireAuth = !!data.hasOwnProperty("require_auth") && data.require_auth, this.url = this.requireAuth ? String(data.url).split("?auth=")[0] + "?auth=" + exports.getInstance().ekey : String(data.url).split("?auth=")[0], this.name = data.hasOwnProperty("name") ? data.name : "File", this.size = parseInt(data.size) || 0, this.type = String(data.type), this.data = data.hasOwnProperty("custom") ? String(data.custom) : "", this.reqId = data.hasOwnProperty("req_id") ? String(data.req_id) :
- "", this.customType = data.hasOwnProperty("custom_type") ? String(data.custom_type) : "", this.thumbnails = data.hasOwnProperty("thumbnails") ? data.thumbnails : [], this.requireAuth)) {
- var i;
- for (i in this.thumbnails) {
- /** @type {string} */
- this.thumbnails[i].url = String(this.thumbnails[i].url).split("?auth=")[0] + "?auth=" + exports.getInstance().ekey;
- }
- }
- };
- fn($, test);
- /**
- * @param {string} e
- * @param {?} id
- * @param {!Object} data
- * @param {!Object} options
- * @param {string} a
- * @param {string} x
- * @param {string} i
- * @param {string} url
- * @param {string} f
- * @param {!Object} name
- * @param {number} arr
- * @param {!Object} value
- * @param {boolean} path
- * @param {!Object} text
- * @param {string} type
- * @param {!Object} n
- * @param {string} err
- * @return {?}
- */
- test.build = function(e, id, data, options, a, x, i, url, f, name, arr, value, path, text, type, n, err) {
- var item = {};
- /** @type {string} */
- item.req_id = e;
- item.msg_id = id;
- item.channel_url = options.url;
- /** @type {string} */
- item.channel_type = options.channelType === update.CHANNEL_TYPE_OPEN ? update.CHANNEL_TYPE_OPEN : update.CHANNEL_TYPE_GROUP;
- /** @type {number} */
- item.ts = arr;
- /** @type {!Object} */
- item.updated_at = text;
- /** @type {string} */
- item.url = a;
- /** @type {string} */
- item.name = x;
- /** @type {string} */
- item.type = i;
- /** @type {string} */
- item.size = url;
- /** @type {string} */
- item.custom = f;
- var user = {};
- user.user_id = data.userId;
- user.nickname = data.nickname;
- user.profile_url = data.profileUrl;
- try {
- /** @type {*} */
- user.metadata = JSON.parse(data.metaData);
- } catch (e) {
- user.metadata = {};
- }
- return item.user = user, name && (item.custom_type = name), path && (item.require_auth = path), value && (item.thumbnails = value), item.mention_type = type, item.mentioned_users = [], n && (item.mentioned_users = n), err && (item.mentioned_user_ids = err), item;
- };
- /**
- * @param {?} window
- * @return {?}
- */
- test.buildFromSerializedData = function(window) {
- var self = $(window);
- /** @type {!Array} */
- var dnorm = [];
- return self.mentionedUsers.forEach(function($scope) {
- dnorm.push(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName));
- }), new test(test.build(self.reqId, self.messageId, self.sender, {
- url : self.channelUrl,
- channelType : self.channelType
- }, self.url, self.name, self.type, self.size, self.data, self.customType, self.createdAt, self.thumbnails, self.requireAuth, self.updatedAt, self.mentionType, dnorm));
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- var update = function(data) {
- /**
- * @param {!Object} user
- * @return {undefined}
- */
- this._update = function(user) {
- /** @type {string} */
- this.url = user.hasOwnProperty("channel_url") ? String(user.channel_url) : "";
- /** @type {string} */
- this.name = user.hasOwnProperty("name") ? String(user.name) : "";
- /** @type {string} */
- this.coverUrl = user.hasOwnProperty("cover_url") ? String(user.cover_url) : "";
- /** @type {number} */
- this.createdAt = user.hasOwnProperty("created_at") ? 1e3 * user.created_at : 0;
- /** @type {string} */
- this.data = user.hasOwnProperty("data") ? String(user.data) : "";
- this.customType = user.hasOwnProperty("custom_type") ? user.custom_type : "";
- this.isFrozen = !!user.hasOwnProperty("freeze") && user.freeze;
- this.isEphemeral = !!user.hasOwnProperty("is_ephemeral") && user.is_ephemeral;
- this.fileUploadRequest = {};
- };
- /**
- * @return {?}
- */
- this.serialize = function() {
- /** @type {*} */
- var item = JSON.parse(JSON.stringify(this));
- if (item.hasOwnProperty("lastMessage") && null !== item.lastMessage && void 0 !== item.lastMessage && "object" == typeof item.lastMessage) {
- var message = item.lastMessage;
- if (message.hasOwnProperty("_sender")) {
- message.sender = message._sender;
- delete message._sender;
- item.lastMessage = message;
- }
- }
- return f(item);
- };
- /**
- * @return {?}
- */
- this.isGroupChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_GROUP;
- };
- /**
- * @return {?}
- */
- this.isOpenChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_OPEN;
- };
- /**
- * @param {string} n
- * @param {string} c
- * @return {?}
- */
- this.getMessageChangeLogsByToken = function(n, c) {
- if ("function" == typeof n && (c = n, n = null), "function" != typeof c) {
- return null;
- }
- exports.getInstance().getMessageChangeLogsByToken(this.isOpenChannel(), this.url, n, function(result, exisObj) {
- if (exisObj) {
- callback(null, exisObj, c);
- } else {
- var s = result.updated.map(function(e) {
- return $.build(e, this);
- });
- var deletedMessageIds = result.deleted.map(function(context) {
- return context.message_id;
- });
- var courseSections = result.has_more;
- var token = result.next;
- callback({
- updatedMessages : s,
- deletedMessageIds : deletedMessageIds,
- hasMore : courseSections,
- token : token
- }, null, c);
- }
- });
- };
- /**
- * @return {?}
- */
- this.createOperatorListQuery = function() {
- return new postLink(this);
- };
- /**
- * @return {?}
- */
- this.createPreviousMessageListQuery = function() {
- return new Assets(this);
- };
- /**
- * @return {?}
- */
- this.createMessageListQuery = function() {
- return new initialize(this);
- };
- /**
- * @param {(Object|string)} e
- * @param {number} result
- * @param {boolean} x
- * @param {number} name
- * @param {number} callback
- * @param {?} obj
- * @param {string} type
- * @param {string} s
- * @param {!Array} args
- * @param {!Function} key
- * @return {?}
- */
- var handleError = function(e, result, x, name, callback, obj, type, s, args, key) {
- if (type === R.MessageTypeFilter.ADMIN ? type = "ADMM" : type === R.MessageTypeFilter.USER ? type = "MESG" : type === R.MessageTypeFilter.FILE ? type = "FILE" : type === R.MessageTypeFilter.ALL && (type = ""), cb(result) && "boolean" == typeof x && cb(name) && cb(callback) && "boolean" == typeof obj && "string" == typeof type && "string" == typeof s && Array.isArray(args)) {
- /** @type {number} */
- var i = 0;
- for (; i < args.length; i++) {
- if ("string" != typeof args[i]) {
- return void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- }
- exports.getInstance().messageList(e.isOpenChannel(), e.url, result, name, callback, x, obj, type, s, args, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, key);
- } else {
- var msgs = data.messages;
- /** @type {!Array} */
- var bounds = [];
- var i;
- for (i in msgs) {
- var ne = $.build(msgs[i], e);
- if (ne) {
- bounds.push(ne);
- }
- }
- callback(bounds, null, key);
- }
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- };
- /**
- * @param {(Object|string)} e
- * @param {number} d
- * @param {boolean} x
- * @param {number} n
- * @param {number} r
- * @param {?} path
- * @param {string} type
- * @param {?} value
- * @param {!Array} doc
- * @param {!Function} key
- * @return {?}
- */
- var add = function(e, d, x, n, r, path, type, value, doc, key) {
- if (type === R.MessageTypeFilter.ADMIN ? type = "ADMM" : type === R.MessageTypeFilter.USER ? type = "MESG" : type === R.MessageTypeFilter.FILE ? type = "FILE" : type === R.MessageTypeFilter.ALL && (type = ""), cb(d) && "boolean" == typeof x && cb(n) && cb(r) && "boolean" == typeof path && "string" == typeof type && "string" == typeof value && Array.isArray(doc)) {
- /** @type {number} */
- var firstPart = 0;
- for (; firstPart < doc.length; firstPart++) {
- if ("string" != typeof doc[firstPart]) {
- return void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- }
- exports.getInstance().messageListByID(e.isOpenChannel(), e.url, d, n, r, x, path, type, value, doc, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, key);
- } else {
- var msgs = data.messages;
- /** @type {!Array} */
- var bounds = [];
- var i;
- for (i in msgs) {
- var ne = $.build(msgs[i], e);
- if (ne) {
- bounds.push(ne);
- }
- }
- callback(bounds, null, key);
- }
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- };
- /**
- * @param {undefined} error
- * @param {boolean} response
- * @param {undefined} session
- * @param {?} resp
- * @param {string} i
- * @param {string} wildcard
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getNextMessagesByTimestamp = function(error, response, session, resp, i, wildcard, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), handleError(this, error, response, 0, session, resp, i, wildcard, callback, thisArg);
- };
- /**
- * @param {undefined} err
- * @param {boolean} res
- * @param {undefined} error
- * @param {?} resp
- * @param {string} i
- * @param {string} wildcard
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getPreviousMessagesByTimestamp = function(err, res, error, resp, i, wildcard, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), handleError(this, err, res, error, 0, resp, i, wildcard, callback, thisArg);
- };
- /**
- * @param {undefined} res
- * @param {undefined} error
- * @param {undefined} session
- * @param {?} resp
- * @param {string} i
- * @param {string} wildcard
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getPreviousAndNextMessagesByTimestamp = function(res, error, session, resp, i, wildcard, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), handleError(this, res, true, error, session, resp, i, wildcard, callback, thisArg);
- };
- /**
- * @param {undefined} right
- * @param {boolean} n
- * @param {undefined} selector
- * @param {?} capture
- * @param {string} i
- * @param {?} howmany
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getNextMessagesByID = function(right, n, selector, capture, i, howmany, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), add(this, right, n, 0, selector, capture, i, howmany, callback, thisArg);
- };
- /**
- * @param {undefined} obj
- * @param {boolean} h
- * @param {undefined} pos
- * @param {?} z
- * @param {string} app
- * @param {?} layoutPath
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getPreviousMessagesByID = function(obj, h, pos, z, app, layoutPath, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), add(this, obj, h, pos, 0, z, app, layoutPath, callback, thisArg);
- };
- /**
- * @param {undefined} right
- * @param {undefined} n
- * @param {undefined} selector
- * @param {?} capture
- * @param {string} i
- * @param {?} howmany
- * @param {!Array} callback
- * @param {!Object} thisArg
- * @return {?}
- */
- this.getPreviousAndNextMessagesByID = function(right, n, selector, capture, i, howmany, callback, thisArg) {
- return "function" != typeof callback || thisArg || (thisArg = callback, callback = []), add(this, right, true, n, selector, capture, i, howmany, callback, thisArg);
- };
- /**
- * @param {?} id
- * @param {string} type
- * @param {undefined} result
- * @param {undefined} title
- * @param {undefined} status
- * @param {undefined} options
- * @param {undefined} e
- * @param {!Array} fn
- * @param {string} target
- * @param {string} date
- * @param {string} duration
- * @param {string} el
- * @param {string} out
- * @param {!Object} src
- * @return {?}
- */
- this._sendFileCommand = function(id, type, result, title, status, options, e, fn, target, date, duration, el, out, src) {
- var key;
- var data = this;
- key = src ? src.reqId : init.generateRequestId();
- var message = init.bFile(key, id, type, result, title, status, options, e, fn, target, date, duration, el);
- var scriptPubKey = test.build(message.requestId, 0, setup.getInstance().currentUser, this, "string" == typeof type ? type : "", result, title, status, options, e, null, null, false, null, date, null, duration);
- var scriptPubKeyBuffer = new test(scriptPubKey);
- return "string" == typeof type && setup.getInstance().sendCommand(message, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), out);
- } else {
- var req = new test(canCreateDiscussions.getJsonElement());
- var user = setup.getInstance().currentUser;
- if (user && req._sender && user.userId === req._sender.userId) {
- if (user.nickname !== req._sender.nickname) {
- user.nickname = req._sender.nickname;
- }
- if (user.profileUrl !== req._sender.profileUrl) {
- user.profileUrl = req._sender.profileUrl;
- }
- }
- if (data.isGroupChannel()) {
- link.getChannel(data.url, function(_this, value) {
- if (lastTrackInfoUrl) {
- var p = _this;
- _this = value;
- value = p;
- }
- if (value) {
- callback(null, value, out);
- } else {
- var indexLookupKey;
- for (indexLookupKey in _this.lastMessage = req, setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onChannelChanged(_this);
- }
- }
- });
- }
- callback(req, null, out);
- }
- }), scriptPubKeyBuffer;
- };
- /**
- * @param {!Array} data
- * @return {?}
- */
- this._getSendFileMessageParamInfo = function(data) {
- var file = {
- file : null,
- name : null,
- type : null,
- size : null,
- data : "",
- customType : "",
- thumbnailSizes : [],
- callback : null,
- progressHandler : null,
- mentionType : UserService.MentionType.USERS,
- mentionedUserIds : [],
- pushNotificationDeliveryOption : set.PushNotificationDeliveryOption.DEFAULT
- };
- switch("function" == typeof data.slice(-1)[0] && (file.callback = data.pop()), "function" == typeof data.slice(-1)[0] && (file.progressHandler = data.pop()), data.length) {
- case 1:
- if (data[0] instanceof set) {
- var self = data[0];
- file.file = self.file ? self.file : self.fileUrl;
- file.name = self.fileName;
- file.type = self.mimeType;
- file.size = self.fileSize;
- file.data = self.data;
- file.customType = self.customType;
- file.thumbnailSizes = self.thumbnailSizes;
- file.mentionType = self._mentionType;
- file.mentionedUserIds = self._mentionedIds;
- file.pushNotificationDeliveryOption = self.pushNotificationDeliveryOption ? self.pushNotificationDeliveryOption : set.PushNotificationDeliveryOption.DEFAULT;
- } else {
- file.file = data[0];
- }
- break;
- case 2:
- file.file = data[0];
- file.data = data[1];
- break;
- case 3:
- file.file = data[0];
- file.data = data[1];
- file.customType = data[2];
- break;
- case 4:
- file.file = data[0];
- file.data = data[1];
- file.customType = data[2];
- file.thumbnailSizes = data[3];
- break;
- case 5:
- file.file = data[0];
- file.name = data[1];
- file.type = data[2];
- file.size = data[3];
- file.data = data[4];
- break;
- case 6:
- file.file = data[0];
- file.name = data[1];
- file.type = data[2];
- file.size = data[3];
- file.data = data[4];
- file.customType = data[5];
- break;
- case 7:
- file.file = data[0];
- file.name = data[1];
- file.type = data[2];
- file.size = data[3];
- file.data = data[4];
- file.customType = data[5];
- file.thumbnailSizes = data[6];
- }
- return "string" != typeof file.file && null !== file.file && (null !== file.name && void 0 !== file.name && file.name || (file.name = file.file.name), null !== file.type && void 0 !== file.type && file.type || (file.type = file.file.type), null !== file.size && void 0 !== file.size || (file.size = file.file.size)), null !== file.name && void 0 !== file.name || (file.name = ""), null !== file.type && void 0 !== file.type || (file.type = ""), null !== file.size && void 0 !== file.size ||
- (file.size = 0), file;
- };
- /**
- * @return {?}
- */
- this.sendFileMessage = function() {
- var self = this;
- var options = this._getSendFileMessageParamInfo(Array.prototype.slice.call(arguments));
- var item = options.file;
- var val = options.name;
- var value = options.type;
- var number = options.size;
- var i = options.data;
- var e = options.customType;
- var filename = options.thumbnailSizes;
- var scale = options.callback;
- var handlers = options.progressHandler;
- var h = options.mentionType;
- var isYTime = options.mentionedUserIds;
- var title = options.pushNotificationDeliveryOption;
- if (null !== filename && void 0 !== filename || (filename = []), setup.getInstance().hasLoggedIn()) {
- if (!(null === item || void 0 === item || null !== val && void 0 !== val && "string" != typeof val || null !== value && void 0 !== value && "string" != typeof value || null !== number && void 0 !== number && (!cb(number) || parseInt(number) < 0) || null !== i && void 0 !== i && "string" != typeof i || null !== e && void 0 !== e && "string" != typeof e || !Array.isArray(filename) || [set.PushNotificationDeliveryOption.DEFAULT, set.PushNotificationDeliveryOption.SUPPRESS].indexOf(title) <
- 0)) {
- var content = self.url;
- /** @type {null} */
- var result = null;
- return "string" == typeof item ? result = self._sendFileCommand(content, item, val, value, number, i, e, [], false, h, isYTime, title, scale) : (result = self._sendFileCommand(content, item, val, value, number, i, e, [], false, h, isYTime, title, scale), exports.getInstance().uploadFile(item, value, filename, content, function(d, exisObj) {
- if (exisObj) {
- callback(null, exisObj, scale);
- } else {
- /** @type {*} */
- var data = "object" == typeof d ? d : JSON.parse(d);
- var c = data.url;
- var mouseOut = data.hasOwnProperty("thumbnails") ? data.thumbnails : [];
- var t = !!data.hasOwnProperty("require_auth") && data.require_auth;
- self._sendFileCommand(content, c, val, value, number, i, e, mouseOut, t, h, isYTime, title, scale, result);
- }
- }, handlers, this.fileUploadRequest, result.reqId)), result;
- }
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), scale);
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), scale);
- }
- };
- /**
- * @param {undefined} i
- * @param {string} productInfo
- * @return {?}
- */
- this.cancelUploadingFileMessage = function(i, productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- if (cb(i)) {
- var resizedObj = this;
- var xhr = resizedObj.fileUploadRequest[i];
- return xhr ? (xhr.upload.onabort = function() {
- delete resizedObj.fileUploadRequest[i];
- callback(true, null, productInfo);
- }, xhr.abort(), true) : (callback(false, new Date("Uploading has been completed or cancelled.", concat.FILE_UPLOAD_CANCEL_FAILED), productInfo), false);
- }
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo);
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {string} name
- * @param {string} options
- * @param {string} y
- * @param {number} t
- * @param {undefined} x
- * @return {?}
- */
- this.sendUserMessage = function(name, options, y, t, x) {
- var data = this;
- /** @type {string} */
- var version = UserService.MentionType.USERS;
- /** @type {!Array} */
- var val = [];
- /** @type {string} */
- var type = next.PushNotificationDeliveryOption.DEFAULT;
- if ("function" == typeof options && (x = options, options = "", y = "", t = [], name instanceof next)) {
- /** @type {string} */
- var data = name;
- name = data.message;
- options = data.data;
- y = data.customType;
- t = data.targetLanguages;
- version = data._mentionType;
- val = data._mentionedIds;
- type = data.pushNotificationDeliveryOption ? data.pushNotificationDeliveryOption : next.PushNotificationDeliveryOption.DEFAULT;
- }
- if ("function" == typeof y && (x = y, y = "", t = []), "function" == typeof t && (x = t, t = []), t || (t = []), "string" == typeof t && (t = [t]), null === options && (options = ""), null === y && (y = ""), setup.getInstance().hasLoggedIn()) {
- if ("string" == typeof name && "string" == typeof options && "string" == typeof y && Array.isArray(t) && !([next.PushNotificationDeliveryOption.DEFAULT, next.PushNotificationDeliveryOption.SUPPRESS].indexOf(type) < 0)) {
- var cmd = init.bMessage(this.url, name, options, y, version, val, t, type);
- var node = self.build(cmd.requestId, 0, setup.getInstance().currentUser, this, name, options, y, t, (new Date).getTime(), null, version, null, val);
- var doc = new self(node);
- return setup.getInstance().sendCommand(cmd, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), x);
- } else {
- var req = new self(canCreateDiscussions.getJsonElement());
- var user = setup.getInstance().currentUser;
- if (user && req._sender && user.userId === req._sender.userId) {
- if (user.nickname !== req._sender.nickname) {
- user.nickname = req._sender.nickname;
- }
- if (user.profileUrl !== req._sender.profileUrl) {
- user.profileUrl = req._sender.profileUrl;
- }
- }
- if (data.isGroupChannel()) {
- link.getChannel(data.url, function(_this, value) {
- if (lastTrackInfoUrl) {
- var p = _this;
- _this = value;
- value = p;
- }
- if (value) {
- callback(null, value, x);
- } else {
- var indexLookupKey;
- for (indexLookupKey in _this.lastMessage = req, setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onChannelChanged(_this);
- }
- }
- });
- }
- callback(req, null, x);
- }
- }), doc;
- }
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), x);
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), x);
- }
- };
- /**
- * @param {undefined} id
- * @param {number} name
- * @param {number} options
- * @param {number} x
- * @param {string} local
- * @return {?}
- */
- this.updateUserMessage = function(id, name, options, x, local) {
- /** @type {!Array<?>} */
- var a = Array.prototype.slice.call(arguments);
- if (5 !== a.length) {
- return "function" == typeof a.slice(-1)[0] && (local = a.pop()), void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), local);
- }
- if (setup.getInstance().hasLoggedIn()) {
- if (cb(id)) {
- if ("string" != typeof name && null !== name && void 0 !== name || "string" != typeof options && null !== options && void 0 !== options || "string" != typeof x && null !== x && void 0 !== x) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), local);
- } else {
- var message = init.bUpdateUserMessage(this.url, id, name, options, x);
- setup.getInstance().sendCommand(message, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), local);
- } else {
- var plugin = new self(canCreateDiscussions.getJsonElement());
- callback(plugin, null, local);
- }
- });
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), local);
- }
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), local);
- }
- };
- /**
- * @param {undefined} id
- * @param {number} name
- * @param {number} options
- * @param {string} childCompute
- * @return {?}
- */
- this.updateFileMessage = function(id, name, options, childCompute) {
- /** @type {!Array<?>} */
- var r = Array.prototype.slice.call(arguments);
- if (4 !== r.length) {
- return "function" == typeof r.slice(-1)[0] && (childCompute = r.pop()), void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), childCompute);
- }
- if (setup.getInstance().hasLoggedIn()) {
- if (cb(id)) {
- if ("string" != typeof name && null !== name && void 0 !== name || "string" != typeof options && null !== options && void 0 !== options) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), childCompute);
- } else {
- var url = init.bUpdateFileMessage(this.url, id, name, options);
- setup.getInstance().sendCommand(url, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), childCompute);
- } else {
- var identifierPositions = new test(canCreateDiscussions.getJsonElement());
- callback(identifierPositions, null, childCompute);
- }
- });
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), childCompute);
- }
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), childCompute);
- }
- };
- /**
- * @param {!Object} obj
- * @param {string} delimiter
- * @return {?}
- */
- this.createMetaCounters = function(obj, delimiter) {
- return setup.getInstance().hasLoggedIn() ? null == obj || "object" != typeof obj || Array.isArray(obj) || check(obj) ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), delimiter) : void exports.getInstance().createMetaCounters(this.isOpenChannel(), this.url, obj, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, delimiter);
- } else {
- callback(identifierPositions, null, delimiter);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), delimiter);
- };
- /**
- * @param {?} obj
- * @param {string} n
- * @param {?} t
- * @return {?}
- */
- this.updateMetaCounters = function(obj, n, t) {
- return setup.getInstance().hasLoggedIn() ? ("function" != typeof n && void 0 !== t || (t = n, n = false), null == obj || "object" != typeof obj || Array.isArray(obj) || check(obj) || "boolean" != typeof n ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), t) : void exports.getInstance().updateMetaCounters(this.isOpenChannel(), this.url, obj, n, exports.UPDATE_META_COUNTER_MODE_SET, function(identifierPositions, n) {
- if (n) {
- callback(null, n, t);
- } else {
- callback(identifierPositions, null, t);
- }
- })) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), t);
- };
- /**
- * @param {?} obj
- * @param {string} delimiter
- * @return {?}
- */
- this.increaseMetaCounters = function(obj, delimiter) {
- return setup.getInstance().hasLoggedIn() ? null == obj || "object" != typeof obj || Array.isArray(obj) || check(obj) ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), delimiter) : void exports.getInstance().updateMetaCounters(this.isOpenChannel(), this.url, obj, false, exports.UPDATE_META_COUNTER_MODE_INC, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, delimiter);
- } else {
- callback(identifierPositions, null, delimiter);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), delimiter);
- };
- /**
- * @param {?} obj
- * @param {string} delimiter
- * @return {?}
- */
- this.decreaseMetaCounters = function(obj, delimiter) {
- return setup.getInstance().hasLoggedIn() ? null == obj || "object" != typeof obj || Array.isArray(obj) || check(obj) ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), delimiter) : void exports.getInstance().updateMetaCounters(this.isOpenChannel(), this.url, obj, false, exports.UPDATE_META_COUNTER_MODE_DEC, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, delimiter);
- } else {
- var bufferObj = canCreateDiscussions;
- var data = {};
- var prop;
- for (prop in bufferObj) {
- var buffer = bufferObj[prop];
- data[prop] = buffer;
- }
- callback(data, null, delimiter);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), delimiter);
- };
- /**
- * @param {!Object} tree
- * @param {string} addr
- * @return {?}
- */
- this.getMetaCounters = function(tree, addr) {
- return setup.getInstance().hasLoggedIn() ? Array.isArray(tree) ? void exports.getInstance().getMetaCounters(this.isOpenChannel(), this.url, tree, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, addr);
- } else {
- callback(identifierPositions, null, addr);
- }
- }) : void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), addr) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), addr);
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getAllMetaCounters = function(productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().getAllMetaCounters(this.isOpenChannel(), this.url, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {?} data
- * @param {string} productInfo
- * @return {?}
- */
- this.deleteMetaCounter = function(data, productInfo) {
- return setup.getInstance().hasLoggedIn() ? "string" != typeof data ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo) : void exports.getInstance().deleteMetaCounter(this.isOpenChannel(), this.url, data, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback(identifierPositions, null, productInfo);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.deleteAllMetaCounters = function(productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().deleteAllMetaCounters(this.isOpenChannel(), this.url, function(identifierPositions, exisObj) {
- if (exisObj) {
- if (productInfo) {
- callback(null, exisObj, productInfo);
- }
- } else {
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {!Object} obj
- * @param {string} index
- * @return {?}
- */
- this.createMetaData = function(obj, index) {
- return setup.getInstance().hasLoggedIn() ? null == obj || "object" != typeof obj || Array.isArray(obj) || check(obj) ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), index) : void exports.getInstance().createMetaData(this.isOpenChannel(), this.url, obj, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, index);
- } else {
- callback(identifierPositions, null, index);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), index);
- };
- /**
- * @param {?} data
- * @param {string} t
- * @param {?} type
- * @return {?}
- */
- this.updateMetaData = function(data, t, type) {
- return setup.getInstance().hasLoggedIn() ? ("function" != typeof t && void 0 !== type || (type = t, t = false), null == data || "object" != typeof data || Array.isArray(data) || check(data) || "boolean" != typeof t ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), type) : void exports.getInstance().updateMetaData(this.isOpenChannel(), this.url, data, t, function(identifierPositions, n) {
- if (n) {
- callback(null, n, type);
- } else {
- callback(identifierPositions, null, type);
- }
- })) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), type);
- };
- /**
- * @param {!Object} text
- * @param {string} user
- * @return {?}
- */
- this.getMetaData = function(text, user) {
- return setup.getInstance().hasLoggedIn() ? Array.isArray(text) ? void exports.getInstance().getMetaData(this.isOpenChannel(), this.url, text, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, user);
- } else {
- callback(identifierPositions, null, user);
- }
- }) : void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), user) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), user);
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getAllMetaData = function(productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().getAllMetaData(this.isOpenChannel(), this.url, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {?} data
- * @param {string} productInfo
- * @return {?}
- */
- this.deleteMetaData = function(data, productInfo) {
- return setup.getInstance().hasLoggedIn() ? "string" != typeof data ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo) : void exports.getInstance().deleteMetaData(this.isOpenChannel(), this.url, data, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback(identifierPositions, null, productInfo);
- }
- }) : void callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.deleteAllMetaData = function(productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().deleteAllMetaData(this.isOpenChannel(), this.url, function(identifierPositions, exisObj) {
- if (exisObj) {
- if (productInfo) {
- callback(null, exisObj, productInfo);
- }
- } else {
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {!Object} obj
- * @param {string} user
- * @return {?}
- */
- this.deleteMessage = function(obj, user) {
- /** @type {!Array<?>} */
- var t = Array.prototype.slice.call(arguments);
- if (2 !== t.length) {
- return "function" == typeof t.slice(-1)[0] && (user = t.pop()), void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), user);
- }
- if (setup.getInstance().hasLoggedIn()) {
- if ("object" != typeof obj || check(obj) || Array.isArray(obj) || Object.keys(obj).indexOf("messageId") < 0 || !obj) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), user);
- } else {
- exports.getInstance().deleteMessage(this.isOpenChannel(), this.url, obj.messageId, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, user);
- });
- }
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), user);
- }
- };
- /** @type {string} */
- this.channelType = update.CHANNEL_TYPE_BASE;
- if (data) {
- this._update(data);
- }
- };
- /** @type {string} */
- update.CHANNEL_TYPE_OPEN = "open";
- /** @type {string} */
- update.CHANNEL_TYPE_GROUP = "group";
- /** @type {string} */
- update.CHANNEL_TYPE_BASE = "base";
- /**
- * @param {undefined} data
- * @return {undefined}
- */
- var Model = function(data) {
- /**
- * @param {!Object} info
- * @return {undefined}
- */
- this.parse = function(info) {
- if (info.hasOwnProperty("participant_count") && (this.participantCount = parseInt(info.participant_count)), info.hasOwnProperty("operators") && info.operators) {
- var type;
- for (type in this.operators = [], info.operators) {
- var new_client = new client(info.operators[type]);
- this.operators.push(new_client);
- }
- }
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- this.refresh = function(e) {
- Model.getChannelWithoutCache(this.url, function(newPath, path) {
- if (lastTrackInfoUrl) {
- var title = newPath;
- newPath = path;
- path = title;
- }
- if (path) {
- callback(null, path, e);
- } else {
- callback(newPath, null, e);
- }
- });
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this.update = function(data) {
- this._update(data);
- this.parse(data);
- };
- /**
- * @param {string} filename
- * @return {undefined}
- */
- this.delete = function(filename) {
- var url = this.url;
- exports.getInstance().deleteOpenChannel(url, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, filename);
- } else {
- delete Model.cachedChannels[url];
- callback(identifierPositions, null, filename);
- }
- });
- };
- /**
- * @param {string} end
- * @return {undefined}
- */
- this.enter = function(end) {
- var validator = this;
- var newCommand = init.bEnter(validator.url);
- setup.getInstance().sendCommand(newCommand, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), end);
- } else {
- Model.enteredChannels[validator.url] = validator;
- callback(null, null, end);
- }
- });
- };
- /**
- * @param {string} status
- * @return {undefined}
- */
- this.exit = function(status) {
- var validator = this;
- var newCommand = init.bExit(validator.url);
- setup.getInstance().sendCommand(newCommand, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), status);
- } else {
- delete Model.enteredChannels[validator.url];
- callback(null, null, status);
- }
- });
- };
- /**
- * @return {?}
- */
- this.createParticipantListQuery = function() {
- return new load(load.PARTICIPANT, this);
- };
- /**
- * @return {?}
- */
- this.createMutedUserListQuery = function() {
- return new load(load.MUTED_USER, this);
- };
- /**
- * @return {?}
- */
- this.createBannedUserListQuery = function() {
- return new load(load.BANNED_USER, this);
- };
- /**
- * @return {?}
- */
- this.updateChannel = function() {
- /** @type {!Array<?>} */
- var e = Array.prototype.slice.call(arguments);
- /** @type {null} */
- var S = null;
- /** @type {null} */
- var message = null;
- /** @type {null} */
- var currentMenu = null;
- /** @type {null} */
- var rel = null;
- /** @type {null} */
- var u = null;
- /** @type {null} */
- var i = null;
- switch("function" == typeof e.slice(-1)[0] && (i = e.pop()), e.length) {
- case 3:
- S = e[0];
- message = e[1];
- currentMenu = e[2];
- break;
- case 4:
- S = e[0];
- message = e[1];
- currentMenu = e[2];
- rel = e[3];
- break;
- case 5:
- S = e[0];
- message = e[1];
- currentMenu = e[2];
- rel = e[3];
- u = e[4];
- break;
- default:
- return void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), i);
- }
- this.updateChannelWithOperatorUserIds(S, message, currentMenu, rel, u, i);
- };
- /**
- * @param {?} token
- * @param {?} data
- * @param {?} val
- * @param {?} name
- * @param {?} a
- * @param {string} b
- * @return {undefined}
- */
- this.updateChannelWithOperatorUserIds = function(token, data, val, name, a, b) {
- if ("function" == typeof a) {
- /** @type {!Function} */
- b = a;
- /** @type {null} */
- a = null;
- }
- if ("string" != typeof token && null !== token && void 0 !== token || "string" != typeof data && check(data) && null !== data && void 0 !== data || "string" != typeof val && null !== val && void 0 !== val || "string" != typeof name && !Array.isArray(name) && null !== name && void 0 !== name || "string" != typeof a && null !== a && void 0 !== a) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), b);
- } else {
- exports.getInstance().updateOpenChannel(this.url, token, data, val, name, a, function(item, n) {
- if (n) {
- callback(null, n, b);
- } else {
- var t = Model.upsert(item);
- callback(t, null, b);
- }
- });
- }
- };
- /**
- * @param {!Object} user
- * @param {number} n
- * @param {!Function} e
- * @return {undefined}
- */
- this.banUser = function(user, n, e) {
- if ("function" == typeof n && 3 !== arguments.length) {
- /** @type {number} */
- e = n;
- /** @type {number} */
- n = -1;
- }
- if (!user || "number" != typeof n || parseInt(n) < 0 && -1 !== parseInt(n)) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- } else {
- this.banUserWithUserId(user.userId, n, e);
- }
- };
- /**
- * @param {undefined} uid
- * @param {number} value
- * @param {!Function} width
- * @return {undefined}
- */
- this.banUserWithUserId = function(uid, value, width) {
- if ("function" == typeof value && 3 !== arguments.length) {
- /** @type {number} */
- width = value;
- /** @type {number} */
- value = -1;
- }
- if (!uid || parseInt(value) < 0 && -1 !== parseInt(value)) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), width);
- } else {
- exports.getInstance().banUser(this.url, uid, null, value, false, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, width);
- });
- }
- };
- /**
- * @param {!Object} user
- * @param {string} subreddit
- * @return {undefined}
- */
- this.unbanUser = function(user, subreddit) {
- if (user) {
- this.unbanUserWithUserId(user.userId, subreddit);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), subreddit);
- }
- };
- /**
- * @param {boolean} sub
- * @param {string} channel
- * @return {undefined}
- */
- this.unbanUserWithUserId = function(sub, channel) {
- if (sub) {
- exports.getInstance().unbanUser(this.url, sub, false, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, channel);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), channel);
- }
- };
- /**
- * @param {!Object} data
- * @param {string} id
- * @return {undefined}
- */
- this.muteUser = function(data, id) {
- if (data) {
- this.muteUserWithUserId(data.userId, id);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), id);
- }
- };
- /**
- * @param {string} cards
- * @param {string} key
- * @return {undefined}
- */
- this.muteUserWithUserId = function(cards, key) {
- if (cards) {
- exports.getInstance().muteUser(this.url, cards, false, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, key);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- };
- /**
- * @param {!Object} accessToken
- * @param {string} id
- * @return {undefined}
- */
- this.unmuteUser = function(accessToken, id) {
- if (accessToken) {
- this.unmuteUserWithUserId(accessToken.userId, id);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), id);
- }
- };
- /**
- * @param {boolean} cards
- * @param {string} key
- * @return {undefined}
- */
- this.unmuteUserWithUserId = function(cards, key) {
- if (cards) {
- exports.getInstance().unmuteUser(this.url, cards, false, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, key);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), key);
- }
- };
- /**
- * @param {!Object} token
- * @return {?}
- */
- this.isOperator = function(token) {
- return !!token && this.isOperatorWithUserId(token.userId);
- };
- /**
- * @param {?} userId
- * @return {?}
- */
- this.isOperatorWithUserId = function(userId) {
- var index;
- for (index in this.operators) {
- if (this.operators[index].userId === userId) {
- return true;
- }
- }
- return false;
- };
- /** @type {string} */
- this.channelType = update.CHANNEL_TYPE_OPEN;
- /** @type {number} */
- this.participantCount = 0;
- /** @type {!Array} */
- this.operators = [];
- if (data) {
- this._update(data);
- this.parse(data);
- }
- };
- fn(update, Model);
- Model.enteredChannels = {};
- /**
- * @return {undefined}
- */
- Model.clearEnteredChannels = function() {
- Model.enteredChannels = {};
- };
- /**
- * @return {?}
- */
- Model.createOpenChannelListQuery = function() {
- return new Controller;
- };
- /**
- * @param {?} e
- * @return {?}
- */
- Model.buildFromSerializedData = function(e) {
- var data = $(e);
- return new Model({
- channel_url : data.url,
- name : data.name,
- cover_url : data.coverUrl,
- data : data.data,
- custom_type : data.customType,
- created_at : data.createdAt / 1e3,
- freeze : data.isFrozen,
- is_ephemeral : data.isEphemeral,
- participant_count : data.participantCount,
- operators : data.operators.map(function($scope) {
- return client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName);
- })
- });
- };
- /**
- * @return {undefined}
- */
- Model.createChannel = function() {
- var e;
- var body;
- var method;
- var value;
- var db;
- var a;
- switch(arguments.length) {
- case 1:
- a = arguments[0];
- break;
- case 4:
- e = arguments[0];
- body = arguments[1];
- method = arguments[2];
- a = arguments[3];
- break;
- case 5:
- e = arguments[0];
- body = arguments[1];
- method = arguments[2];
- value = arguments[3];
- a = arguments[4];
- break;
- case 6:
- e = arguments[0];
- body = arguments[1];
- method = arguments[2];
- value = arguments[3];
- db = arguments[4];
- a = arguments[5];
- }
- Model.createChannelWithOperatorUserIds(e, body, method, value, db, a);
- };
- /**
- * @param {?} data
- * @return {?}
- */
- Model.upsert = function(data) {
- var model = new Model(data);
- return Model.cachedChannels.hasOwnProperty(model.url) ? Model.cachedChannels[model.url].update(data) : Model.cachedChannels[model.url] = model, Model.cachedChannels[model.url];
- };
- /**
- * @param {number} e
- * @param {?} lang
- * @param {number} name
- * @param {number} data
- * @param {number} a
- * @param {!Object} b
- * @return {undefined}
- */
- Model.createChannelWithOperatorUserIds = function(e, lang, name, data, a, b) {
- if ("function" == typeof a) {
- /** @type {number} */
- b = a;
- /** @type {string} */
- a = "";
- }
- if ("string" != typeof e && null !== e && void 0 !== e || "string" != typeof lang && check(lang) && null !== lang && void 0 !== lang || "string" != typeof name && null !== name && void 0 !== name || "string" != typeof data && !Array.isArray(data) && null !== data && void 0 !== data || "string" != typeof a && null !== a && void 0 !== a) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), b);
- } else {
- exports.getInstance().createOpenChannel(e, lang, name, data, a, function(item, n) {
- if (n) {
- callback(null, n, b);
- } else {
- var t = Model.upsert(item);
- callback(t, null, b);
- }
- });
- }
- };
- Model.cachedChannels = {};
- /**
- * @return {undefined}
- */
- Model.clearCache = function() {
- Model.cachedChannels = {};
- };
- /**
- * @param {?} joinModel
- * @return {undefined}
- */
- Model.removeCachedChannel = function(joinModel) {
- delete Model.cachedChannels[joinModel];
- };
- /**
- * @param {string} name
- * @param {!Function} value
- * @return {undefined}
- */
- Model.getChannel = function(name, value) {
- if (name) {
- if (Model.cachedChannels.hasOwnProperty(name)) {
- callback(Model.cachedChannels[name], null, value);
- } else {
- Model.getChannelWithoutCache(name, value);
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), value);
- }
- };
- /**
- * @param {string} k
- * @param {!Function} array
- * @return {undefined}
- */
- Model.getChannelWithoutCache = function(k, array) {
- if (k) {
- exports.getInstance().getOpenChannel(k, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, array);
- } else {
- Model.upsert(data);
- callback(Model.cachedChannels[k], null, array);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), array);
- }
- };
- /**
- * @return {undefined}
- */
- var B = function() {
- /** @type {!Array} */
- this.channelCustomTypesFilter = [];
- /** @type {string} */
- this.superChannelFilter = link.superChannelFilter.ALL;
- };
- /**
- * @param {undefined} data
- * @return {undefined}
- */
- var link = function(data) {
- var users = {};
- /** @type {number} */
- var type = 0;
- /** @type {number} */
- var x = 0;
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this.parse = function(data) {
- var self = this;
- if (self.isDistinct = !!data.is_distinct && data.is_distinct, self.isPushEnabled = !!data.is_push_enabled && data.is_push_enabled, self.isHidden = !!data.hasOwnProperty("is_hidden") && data.is_hidden, self.myCountPreference = data.hasOwnProperty("count_preference") ? data.count_preference : link.CountPreference.ALL, self.unreadMessageCount = 0, self.unreadMentionCount = 0, log(self, parseInt(data.unread_message_count), parseInt(data.unread_mention_count)), data.hasOwnProperty("read_receipt")) {
- var container;
- for (container in self.cachedReadReceiptStatus = {}, data.read_receipt) {
- var s = data.read_receipt[container];
- self.updateReadReceipt(container, parseInt(s));
- }
- }
- if (data.hasOwnProperty("members")) {
- /** @type {!Array} */
- self.members = [];
- self.memberMap = {};
- data.members.forEach(function(doc) {
- var result = new _this(doc);
- self.members.push(result);
- self.memberMap[result.userId] = result;
- });
- }
- if (data.hasOwnProperty("member_state")) {
- self.myMemberState = data.member_state;
- } else {
- /** @type {string} */
- self.myMemberState = "none";
- }
- if (data.hasOwnProperty("my_role")) {
- self.myRole = data.my_role || link.Role.NONE;
- } else {
- /** @type {string} */
- self.myRole = link.Role.NONE;
- }
- if (data.hasOwnProperty("is_muted")) {
- if ("string" == typeof data.is_muted) {
- /** @type {string} */
- self.myMutedState = data.is_muted;
- } else {
- if ("boolean" == typeof data.is_muted) {
- /** @type {string} */
- self.myMutedState = data.is_muted ? "muted" : "unmuted";
- }
- }
- } else {
- /** @type {string} */
- self.myMutedState = "unmuted";
- }
- if (data.hasOwnProperty("member_count")) {
- /** @type {number} */
- self.memberCount = parseInt(data.member_count);
- }
- if (data.hasOwnProperty("joined_member_count")) {
- /** @type {number} */
- self.joinedMemberCount = parseInt(data.joined_member_count);
- }
- if (data.hasOwnProperty("last_message") && "object" == typeof data.last_message && data.last_message) {
- if (data.last_message instanceof $) {
- self.lastMessage = data.last_message;
- } else {
- self.lastMessage = $.build(data.last_message, self);
- }
- } else {
- /** @type {null} */
- self.lastMessage = null;
- }
- if (data.hasOwnProperty("inviter") && null !== data.inviter && "object" == typeof data.inviter && !check(data.inviter)) {
- self.inviter = new client(data.inviter);
- } else {
- /** @type {null} */
- self.inviter = null;
- }
- if (data.hasOwnProperty("is_super") && null !== data.is_super && "boolean" == typeof data.is_super) {
- /** @type {boolean} */
- self.isSuper = data.is_super;
- } else {
- /** @type {boolean} */
- self.isSuper = false;
- }
- if (data.hasOwnProperty("is_public") && null !== data.is_public && "boolean" == typeof data.is_public) {
- /** @type {boolean} */
- self.isPublic = data.is_public;
- } else {
- /** @type {boolean} */
- self.isPublic = false;
- }
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- this.refresh = function(e) {
- link.getChannelWithoutCache(this.url, function(newPath, path) {
- if (lastTrackInfoUrl) {
- var title = newPath;
- newPath = path;
- path = title;
- }
- if (path) {
- callback(null, path, e);
- } else {
- callback(newPath, null, e);
- }
- });
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this.update = function(data) {
- this._update(data);
- this.parse(data);
- };
- /**
- * @return {?}
- */
- this.updateChannel = function() {
- /** @type {!Array<?>} */
- var a = Array.prototype.slice.call(arguments);
- /** @type {null} */
- var t = null;
- /** @type {null} */
- var name = null;
- /** @type {null} */
- var val = null;
- /** @type {null} */
- var data = null;
- /** @type {null} */
- var value = null;
- /** @type {null} */
- var productInfo = null;
- /** @type {null} */
- var result = null;
- switch("function" == typeof a.slice(-1)[0] && (productInfo = a.pop()), a.length) {
- case 1:
- if (!(a[0] instanceof render)) {
- return void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo);
- }
- var el = a[0];
- t = el.isDistinct;
- name = el.name;
- val = el.channelCover;
- data = el.data;
- value = el.customType;
- result = el.isPublic;
- break;
- case 3:
- t = this.isDistinct;
- name = a[0];
- val = a[1];
- data = a[2];
- break;
- case 4:
- t = a[0];
- name = a[1];
- val = a[2];
- data = a[3];
- break;
- case 5:
- t = a[0];
- name = a[1];
- val = a[2];
- data = a[3];
- value = a[4];
- break;
- default:
- return void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo);
- }
- if ("string" != typeof name && null !== name && void 0 !== name || "string" != typeof val && check(val) && null !== val && void 0 !== val || "string" != typeof data && null !== data && void 0 !== data || "boolean" != typeof t && null !== t || "boolean" != typeof result && null !== result || "string" != typeof value && null !== value && void 0 !== value) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo);
- } else {
- exports.getInstance().updateGroupChannel(this.url, t, name, val, data, value, result, function(item, n) {
- if (n) {
- callback(null, n, productInfo);
- } else {
- var t = link.upsert(item);
- callback(t, null, productInfo);
- }
- });
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.resetMyHistory = function(productInfo) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().resetMyHistory(this.url, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {string} user
- * @param {string} request
- * @return {undefined}
- */
- this.invite = function(user, request) {
- if ("string" == typeof user && (user = [{
- userId : user
- }]), Array.isArray(user) && !check(user)) {
- /** @type {!Array} */
- var todos = [];
- var i;
- for (i in user) {
- if ("object" != typeof user[i] || check(user[i])) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), request);
- break;
- }
- todos.push(user[i].userId);
- }
- this.inviteWithUserIds(todos, request);
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), request);
- }
- };
- /**
- * @param {!Object} value
- * @param {string} username
- * @return {undefined}
- */
- this.inviteWithUserIds = function(value, username) {
- if (Array.isArray(value) && !check(value)) {
- exports.getInstance().groupChannelInvite(this.url, value, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, username);
- } else {
- var s = link.upsert(data);
- callback(s, null, username);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), username);
- }
- };
- /**
- * @param {string} token
- * @return {undefined}
- */
- this.acceptInvitation = function(token) {
- exports.getInstance().acceptInvitation(this.url, setup.getInstance().getCurrentUserId(), function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, token);
- } else {
- var opts = link.upsert(data);
- /** @type {string} */
- opts.myMemberState = "joined";
- link.cachedChannels[opts.url] = opts;
- callback(opts, null, token);
- }
- });
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.declineInvitation = function(productInfo) {
- var options = this;
- exports.getInstance().declineInvitation(this.url, setup.getInstance().getCurrentUserId(), function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- /** @type {string} */
- options.myMemberState = "none";
- link.cachedChannels[options.url] = options;
- if (!options.isPublic) {
- link.removeCachedChannel(options.url);
- }
- callback(identifierPositions, null, productInfo);
- }
- });
- };
- /**
- * @param {?} e
- * @param {string} c
- * @return {undefined}
- */
- this.hide = function(e, c) {
- if (1 === arguments.length && "function" == typeof e && (c = e, e = false), null !== e && void 0 !== e || (e = false), "boolean" == typeof e) {
- var name = this.url;
- var hyperlinkTip = this;
- exports.getInstance().groupChannelHide(name, setup.getInstance().getCurrentUserId(), e, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, c);
- } else {
- /** @type {boolean} */
- hyperlinkTip.isHidden = true;
- var resource = link.cachedChannels[name];
- if (resource) {
- /** @type {boolean} */
- resource.isHidden = true;
- if (e) {
- log(resource, 0, 0);
- }
- link.cachedChannels[name] = resource;
- }
- callback(identifierPositions, null, c);
- }
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), c);
- }
- };
- /**
- * @param {string} metadata
- * @return {undefined}
- */
- this.join = function(metadata) {
- var url = this.url;
- exports.getInstance().publicGroupChannelJoin(url, setup.getInstance().getCurrentUserId(), function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, metadata);
- } else {
- var opts = link.upsert(data);
- /** @type {string} */
- opts.myMemberState = "joined";
- link.cachedChannels[opts.url] = opts;
- callback(opts, null, metadata);
- }
- });
- };
- /**
- * @param {string} username
- * @return {undefined}
- */
- this.leave = function(username) {
- var url = this.url;
- exports.getInstance().groupChannelLeave(url, setup.getInstance().getCurrentUserId(), function(n, endNow) {
- callback(null, endNow || null, username);
- });
- };
- /**
- * @return {undefined}
- */
- this.markAsRead = function() {
- this._sendMarkAsRead(null);
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- this._sendMarkAsRead = function(e) {
- var self = this;
- var newCommand = init.bRead(self.url);
- setup.getInstance().sendCommand(newCommand, function(canCreateDiscussions, options) {
- if (options) {
- callback(null, new Date(options.message, options.code), e);
- } else {
- if (self.unreadMessageCount > 0 || self.unreadMentionCount > 0) {
- var indexLookupKey;
- for (indexLookupKey in log(self, 0, 0), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onChannelChanged(self);
- }
- }
- callback(null, null, e);
- }
- });
- };
- /**
- * @param {!Object} options
- * @return {?}
- */
- this.getReadReceipt = function(options) {
- if (!(options instanceof $)) {
- return console.log("message is not BaseMessage instance"), -1;
- }
- if (options.messageType === $.MESSAGE_TYPE_ADMIN) {
- return 0;
- }
- var user = setup.getInstance().currentUser;
- /** @type {number} */
- var variable = 0;
- var date = options.createdAt;
- var members = this.members;
- var property;
- for (property in members) {
- var member = members[property];
- var id = member.userId;
- if (!(user.userId === id || options.sender && options.sender.userId === id)) {
- if (this.cachedReadReceiptStatus[id] < date) {
- variable++;
- }
- }
- }
- return this.isSuper ? 0 : variable;
- };
- /**
- * @return {?}
- */
- this.getReadStatus = function() {
- var loads = {};
- if (!setup.getInstance().currentUser) {
- return loads;
- }
- var members = this.members;
- var property;
- for (property in members) {
- var member = members[property];
- var id = member.userId;
- if (member.userId !== setup.getInstance().getCurrentUserId()) {
- var a = this.cachedReadReceiptStatus[id];
- loads[id] = {
- user : member,
- last_seen_at : parseInt(a)
- };
- }
- }
- return loads;
- };
- /**
- * @param {string} i
- * @param {number} eof
- * @return {undefined}
- */
- this.updateReadReceipt = function(i, eof) {
- /** @type {string} */
- var t = i;
- var subtreeId = this.cachedReadReceiptStatus[t];
- /** @type {number} */
- var id = eof;
- if (!subtreeId || subtreeId < id) {
- this.cachedReadReceiptStatus[t] = id;
- }
- };
- /**
- * @return {undefined}
- */
- this.startTyping = function() {
- /** @type {number} */
- var xMax = (new Date).getTime();
- var width = setup.getInstance().Options.typingIndicatorThrottle;
- if (("number" != typeof width || width < 1e3 || width > 9e3) && (width = 1e3), xMax - type >= width) {
- /** @type {number} */
- x = 0;
- /** @type {number} */
- type = xMax;
- var url = init.bTypeStart(this.url, type);
- setup.getInstance().sendCommand(url, null);
- }
- };
- /**
- * @return {undefined}
- */
- this.endTyping = function() {
- /** @type {number} */
- var prevX = (new Date).getTime();
- var right = setup.getInstance().Options.typingIndicatorThrottle;
- if (("number" != typeof right || right < 1e3 || right > 9e3) && (right = 1e3), prevX - x >= right) {
- /** @type {number} */
- type = 0;
- /** @type {number} */
- x = prevX;
- var url = init.bTypeEnd(this.url, x);
- setup.getInstance().sendCommand(url, null);
- }
- };
- /**
- * @return {?}
- */
- this.invalidateTypingStatus = function() {
- /** @type {boolean} */
- var e = false;
- /** @type {number} */
- var curt = (new Date).getTime();
- var name;
- for (name in users) {
- if (curt - users[name] >= 1e4) {
- delete users[name];
- /** @type {boolean} */
- e = true;
- }
- }
- return e;
- };
- /**
- * @param {!Object} post
- * @param {boolean} mark_deleted
- * @return {undefined}
- */
- this.updateTypingStatus = function(post, mark_deleted) {
- if (mark_deleted) {
- /** @type {number} */
- users[post.userId] = (new Date).getTime();
- } else {
- delete users[post.userId];
- }
- };
- /**
- * @return {?}
- */
- this.isTyping = function() {
- return 0 !== Object.keys(users).length;
- };
- /**
- * @return {?}
- */
- this.getTypingMembers = function() {
- /** @type {!Array} */
- var currentMaxTerms = [];
- var i;
- for (i in users) {
- var j = this.memberMap[i];
- if (this.memberMap[i]) {
- currentMaxTerms.push(j);
- }
- }
- return currentMaxTerms;
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this.addMember = function(data) {
- if (!this.isSuper) {
- var e = this.removeMember(data);
- if (e && e.state === _this.JOINED) {
- /** @type {string} */
- data.state = _this.JOINED;
- }
- /** @type {!Object} */
- this.memberMap[data.userId] = data;
- this.members.push(data);
- this.memberCount++;
- this.updateReadReceipt(data.userId, 0);
- }
- };
- /**
- * @param {!Object} message
- * @return {?}
- */
- this.removeMember = function(message) {
- /** @type {null} */
- var change = null;
- if (!this.isSuper) {
- var uid = message.userId;
- if (this.memberMap.hasOwnProperty(message.userId)) {
- var i;
- for (i in delete this.memberMap[message.userId], this.members) {
- var d = this.members[i];
- if (d.userId === uid) {
- change = d;
- this.members.splice(i, 1);
- break;
- }
- }
- this.memberCount--;
- }
- }
- return change;
- };
- /**
- * @return {undefined}
- */
- this.updateJoinedMemberCount = function() {
- if (!this.isSuper) {
- /** @type {number} */
- var e = 0;
- var length = this.members.length;
- /** @type {number} */
- var i = 0;
- for (; i < length; i++) {
- if (this.members[i].state === _this.JOINED) {
- e++;
- }
- }
- /** @type {number} */
- this.joinedMemberCount = e;
- }
- };
- /** @type {number} */
- var realWidth = 0;
- /**
- * @param {number} s
- * @param {number} index
- * @param {number} width
- * @return {undefined}
- */
- this.setLatestMemberCount = function(s, index, width) {
- if ("number" == typeof s && "number" == typeof index && "number" == typeof width && width >= realWidth) {
- /** @type {number} */
- realWidth = width;
- /** @type {number} */
- this.memberCount = s;
- /** @type {number} */
- this.joinedMemberCount = index;
- }
- };
- /**
- * @param {string} data
- * @param {string} productInfo
- * @return {undefined}
- */
- this.setPushPreference = function(data, productInfo) {
- var options = this;
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().setPushPreference(setup.getInstance().getCurrentUserId(), this.url, data, function(entry, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- options.isPushEnabled = entry.enable;
- callback(entry, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getPushPreference = function(productInfo) {
- var rayleigh = this;
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().getPushPreference(setup.getInstance().getCurrentUserId(), this.url, function(thumb, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- if (productInfo) {
- var value;
- try {
- value = thumb.enable;
- } catch (e) {
- /** @type {boolean} */
- value = false;
- }
- rayleigh.isPushEnabled = value;
- callback(value, null, productInfo);
- }
- }
- });
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {?} options
- * @param {string} childCompute
- * @return {undefined}
- */
- this.setMyCountPreference = function(options, childCompute) {
- if (setup.getInstance().hasLoggedIn()) {
- if ([link.CountPreference.ALL, link.CountPreference.UNREAD_MESSAGE_COUNT_ONLY, link.CountPreference.UNREAD_MENTION_COUNT_ONLY, link.CountPreference.OFF].indexOf(options) < 0) {
- callback(null, new Date("Invalid parameters.", concat.INVALID_PARAMETER), childCompute);
- } else {
- var self = this;
- exports.getInstance().setCountPreference(setup.getInstance().getCurrentUserId(), this.url, options, function(PeerJS, exisObj) {
- if (exisObj) {
- callback(null, exisObj, childCompute);
- } else {
- self.myCountPreference = PeerJS.count_preference;
- log(self, self.unreadMessageCount, self.unreadMentionCount);
- callback(self.myCountPreference, null, childCompute);
- }
- });
- }
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), childCompute);
- }
- };
- /**
- * @return {?}
- */
- this.createMemberListQuery = function() {
- var url = this.url;
- return new reset(url);
- };
- /**
- * @param {!Object} user
- * @param {number} callback
- * @param {!Function} data
- * @param {!Function} e
- * @return {undefined}
- */
- this.banUser = function(user, callback, data, e) {
- if (user && user.hasOwnProperty("userId") && "string" == typeof data) {
- this.banUserWithUserId(user.userId, callback, data, e);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- }
- };
- /**
- * @param {boolean} target
- * @param {number} fn
- * @param {!Function} err
- * @param {string} head
- * @return {undefined}
- */
- this.banUserWithUserId = function(target, fn, err, head) {
- if (target && "string" == typeof target && "string" == typeof err) {
- exports.getInstance().banUser(this.url, target, err, fn, true, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, head);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), head);
- }
- };
- /**
- * @param {!Object} user
- * @param {string} subject
- * @return {undefined}
- */
- this.unbanUser = function(user, subject) {
- if (user && user.hasOwnProperty("userId")) {
- this.unbanUserWithUserId(user.userId, subject);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), subject);
- }
- };
- /**
- * @param {boolean} target
- * @param {string} channel
- * @return {undefined}
- */
- this.unbanUserWithUserId = function(target, channel) {
- if (target && "string" == typeof target) {
- exports.getInstance().unbanUser(this.url, target, true, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, channel);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), channel);
- }
- };
- /**
- * @param {!Object} data
- * @param {string} id
- * @return {undefined}
- */
- this.muteUser = function(data, id) {
- if (data && data.hasOwnProperty("userId")) {
- this.muteUserWithUserId(data.userId, id);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), id);
- }
- };
- /**
- * @param {string} fn
- * @param {string} n
- * @return {undefined}
- */
- this.muteUserWithUserId = function(fn, n) {
- if (fn && "string" == typeof fn) {
- exports.getInstance().muteUser(this.url, fn, true, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, n);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), n);
- }
- };
- /**
- * @param {!Object} socket
- * @param {string} id
- * @return {undefined}
- */
- this.unmuteUser = function(socket, id) {
- if (socket && socket.hasOwnProperty("userId")) {
- this.unmuteUserWithUserId(socket.userId, id);
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), id);
- }
- };
- /**
- * @param {boolean} fn
- * @param {string} n
- * @return {undefined}
- */
- this.unmuteUserWithUserId = function(fn, n) {
- if (fn && "string" == typeof fn) {
- exports.getInstance().unmuteUser(this.url, fn, true, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, n);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), n);
- }
- };
- /**
- * @param {boolean} value
- * @return {undefined}
- */
- this.freeze = function(value) {
- exports.getInstance().freeze(this.url, true, true, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, value);
- } else {
- link.upsert(data);
- callback(null, null, value);
- }
- });
- };
- /**
- * @param {string} value
- * @return {undefined}
- */
- this.unfreeze = function(value) {
- exports.getInstance().freeze(this.url, true, false, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, value);
- } else {
- link.upsert(data);
- callback(null, null, value);
- }
- });
- };
- /**
- * @return {?}
- */
- this.createBannedUserListQuery = function() {
- return new load(load.BANNED_USER, this);
- };
- /** @type {string} */
- this.channelType = update.CHANNEL_TYPE_GROUP;
- /** @type {boolean} */
- this.isDistinct = false;
- /** @type {boolean} */
- this.isSuper = false;
- /** @type {boolean} */
- this.isPublic = false;
- /** @type {number} */
- this.unreadMessageCount = 0;
- /** @type {null} */
- this.inviter = null;
- /** @type {!Array} */
- this.members = [];
- this.memberMap = {};
- this.lastMessage = {};
- /** @type {number} */
- this.memberCount = 0;
- /** @type {number} */
- this.joinedMemberCount = 0;
- this.cachedReadReceiptStatus = {};
- this.isPushEnabled;
- /** @type {boolean} */
- this.isHidden = false;
- if (data) {
- this._update(data);
- this.parse(data);
- }
- };
- fn(update, link);
- /**
- * @param {?} window
- * @return {?}
- */
- link.buildFromSerializedData = function(window) {
- var self = $(window);
- return new link({
- channel_url : self.url,
- name : self.name,
- cover_url : self.coverUrl,
- data : self.data,
- custom_type : self.customType,
- created_at : self.createdAt / 1e3,
- is_distinct : self.isDistinct,
- is_super : self.isSuper,
- is_public : self.isPublic,
- freeze : self.isFrozen,
- is_ephemeral : self.isEphemeral,
- unread_message_count : self.unreadMessageCount,
- unread_mention_count : self.unreadMentionCount,
- is_push_enabled : self.isPushEnabled,
- count_preference : self.myCountPreference,
- is_hidden : self.isHidden,
- member_count : self.memberCount,
- joined_member_count : self.joinedMemberCount,
- member_state : self.myMemberState,
- my_role : self.myRole,
- is_muted : self.myMutedState,
- members : self.members.map(function($scope) {
- return _this.build(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName), $scope.state, $scope.isBlockedByMe, $scope.isBlockingMe);
- }),
- last_message : function(options) {
- return null !== options && void 0 !== options && "object" == typeof options ? options.messageType === $.MESSAGE_TYPE_USER ? new self(self.build(options.reqId, options.messageId, options.sender, {
- url : options.channelUrl,
- channelType : options.channelType
- }, options.message, options.data, options.customType, options.translations, options.createdAt, options.updatedAt, options.mentionType, options.mentionedUsers)) : options.messageType === $.MESSAGE_TYPE_FILE ? new test(test.build(options.reqId, options.messageId, options.sender, {
- url : options.channelUrl,
- channelType : options.channelType
- }, options.url, options.name, options.type, options.size, options.data, options.customType, options.createdAt, options.thumbnails, options.requireAuth, options.updatedAt, options.mentionType, options.mentionedUsers)) : new logger(logger.build(options.messageId, {
- url : options.channelUrl,
- channelType : options.channelType
- }, options.message, options.data, options.customType, options.translations, options.createdAt, options.updatedAt, options.mentionType, options.mentionedUsers)) : null;
- }(self.lastMessage),
- read_receipt : self.cachedReadReceiptStatus,
- inviter : null !== self.inviter && void 0 !== self.inviter && "object" == typeof self.inviter ? client.build(self.inviter.userId, self.inviter.nickname, self.inviter.profileUrl, self.inviter.connectionStatus, self.inviter.lastSeenAt, self.inviter.metaData, self.inviter.isActive, self.inviter.friendDiscoveryKey, self.inviter.friendName) : null
- });
- };
- /**
- * @return {?}
- */
- link.createMyGroupChannelListQuery = function() {
- return new Context(setup.getInstance().currentUser);
- };
- /**
- * @return {?}
- */
- link.createPublicGroupChannelListQuery = function() {
- return new iterator;
- };
- link.memberState = {
- ALL : 0,
- JOINED : 1,
- INVITED : 2,
- INVITED_BY_FRIEND : 3,
- INVITED_BY_NON_FRIEND : 4
- };
- link.memberStateFilter = {
- ALL : "all",
- JOINED : "joined_only",
- INVITED : "invited_only",
- INVITED_BY_FRIEND : "invited_by_friend",
- INVITED_BY_NON_FRIEND : "invited_by_non_friend"
- };
- link.superChannelFilter = {
- ALL : "all",
- SUPER : "super",
- NON_SUPER : "nonsuper"
- };
- link.publicChannelFilter = {
- ALL : "all",
- PUBLIC : "public",
- PRIVATE : "private"
- };
- link.Role = {
- OPERATOR : "operator",
- NONE : "none"
- };
- link.UnreadItemKey = {
- GROUP_CHANNEL_UNREAD_MENTION_COUNT : "group_channel_unread_mention_count",
- NONSUPER_UNREAD_MENTION_COUNT : "non_super_group_channel_unread_mention_count",
- SUPER_UNREAD_MENTION_COUNT : "super_group_channel_unread_mention_count",
- GROUP_CHANNEL_UNREAD_MESSAGE_COUNT : "group_channel_unread_message_count",
- NONSUPER_UNREAD_MESSAGE_COUNT : "non_super_group_channel_unread_message_count",
- SUPER_UNREAD_MESSAGE_COUNT : "super_group_channel_unread_message_count",
- GROUP_CHANNEL_INVITATION_COUNT : "group_channel_invitation_count",
- NONSUPER_INVITATION_COUNT : "non_super_group_channel_invitation_count",
- SUPER_INVITATION_COUNT : "super_group_channel_invitation_count"
- };
- link.CountPreference = {
- ALL : "all",
- UNREAD_MESSAGE_COUNT_ONLY : "unread_message_count_only",
- UNREAD_MENTION_COUNT_ONLY : "unread_mention_count_only",
- OFF : "off"
- };
- /**
- * @param {number} d
- * @param {undefined} data
- * @return {?}
- */
- link.getChannelCount = function(d, data) {
- return "function" == typeof d && 1 === arguments.length && (data = d, d = link.memberState.ALL), d !== link.memberState.ALL && d !== link.memberState.JOINED && d !== link.memberState.INVITED && d !== link.memberState.INVITED_BY_FRIEND && d !== link.memberState.INVITED_BY_NON_FRIEND ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), data) : setup.getInstance().hasLoggedIn() ? void exports.getInstance().getGroupChannelCount(setup.getInstance().getCurrentUserId(),
- d, function(mainPost, exisObj) {
- if (exisObj) {
- callback(null, exisObj, data);
- } else {
- /** @type {number} */
- var s = parseInt(mainPost.group_channel_count);
- callback(s, null, data);
- }
- }) : void(data && callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), data));
- };
- /**
- * @param {!Array} cards
- * @param {string} status
- * @return {?}
- */
- link.getUnreadItemCount = function(cards, status) {
- if (!Array.isArray(cards) || cards.length < 1) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), status);
- } else {
- /** @type {number} */
- var i = 0;
- for (; i < cards.length; i++) {
- if ([link.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT, link.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT, link.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT, link.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT, link.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT, link.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT, link.UnreadItemKey.SUPER_INVITATION_COUNT, link.UnreadItemKey.NONSUPER_INVITATION_COUNT, link.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT].indexOf(cards[i]) < 0) {
- return void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), status);
- }
- }
- var uncert = cards.filter(function(i, match) {
- return cards.indexOf(i) === match;
- });
- exports.getInstance().getUnreadItemCount(setup.getInstance().getCurrentUserId(), uncert, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, status);
- } else {
- callback(identifierPositions, null, status);
- }
- });
- }
- };
- /**
- * @param {string} c
- * @param {string} d
- * @return {undefined}
- */
- link.getTotalUnreadMessageCount = function(c, d) {
- if ("function" == typeof c) {
- /** @type {string} */
- d = c;
- /** @type {null} */
- c = null;
- }
- /** @type {string} */
- var a = c;
- /** @type {string} */
- var val = link.superChannelFilter.ALL;
- if (c instanceof B) {
- a = c.channelCustomTypesFilter;
- val = c.superChannelFilter;
- }
- if (null !== a && void 0 !== a && !Array.isArray(a) || "string" != typeof val && [link.superChannelFilter.ALL, link.superChannelFilter.SUPER, link.superChannelFilter.NON_SUPER].indexOf(val) < 0) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), d);
- } else {
- exports.getInstance().getTotalUnreadMessageCount(setup.getInstance().getCurrentUserId(), a, val, function(counter, exisObj) {
- if (exisObj) {
- callback(null, exisObj, d);
- } else {
- /** @type {number} */
- var s = parseInt(counter.unread_count);
- callback(s, null, d);
- }
- });
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- link.getTotalUnreadChannelCount = function(productInfo) {
- exports.getInstance().getTotalUnreadChannelCount(setup.getInstance().getCurrentUserId(), function(counter, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- /** @type {number} */
- var s = parseInt(counter.unread_count);
- callback(s, null, productInfo);
- }
- });
- };
- /**
- * @return {undefined}
- */
- link.createChannel = function() {
- /** @type {null} */
- var a = null;
- /** @type {!Array} */
- var module = [];
- /** @type {null} */
- var progress = null;
- /** @type {null} */
- var ghash = null;
- /** @type {null} */
- var url = null;
- /** @type {null} */
- var data = null;
- /** @type {null} */
- var str = null;
- /** @type {null} */
- var storedItem = null;
- /** @type {null} */
- var path = null;
- var settings = {
- isPublic : null,
- channelUrl : null
- };
- /** @type {!Array} */
- var restaurantId = [];
- /** @type {null} */
- var result = null;
- switch(arguments.length) {
- case 2:
- if (arguments[0] instanceof render) {
- var obj = arguments[0];
- module = obj._inviteUserIds;
- /** @type {!Array} */
- a = [];
- progress = obj.isDistinct;
- ghash = obj.isSuper;
- url = obj.name;
- data = obj.channelCover;
- str = obj.data;
- path = obj.customType;
- restaurantId = obj._operatorIds;
- settings.isPublic = obj.isPublic;
- settings.channelUrl = obj.channelUrl;
- result = obj.isEphemeral;
- storedItem = arguments[1];
- break;
- }
- a = arguments[0];
- /** @type {boolean} */
- progress = false;
- storedItem = arguments[1];
- break;
- case 3:
- a = arguments[0];
- progress = arguments[1];
- storedItem = arguments[2];
- break;
- case 4:
- a = arguments[0];
- progress = arguments[1];
- path = arguments[2];
- storedItem = arguments[3];
- break;
- case 6:
- a = arguments[0];
- progress = arguments[1];
- url = arguments[2];
- data = arguments[3];
- str = arguments[4];
- storedItem = arguments[5];
- break;
- case 7:
- a = arguments[0];
- progress = arguments[1];
- url = arguments[2];
- data = arguments[3];
- str = arguments[4];
- path = arguments[5];
- storedItem = arguments[6];
- }
- if (!Array.isArray(a) || "boolean" != typeof progress && null !== progress || "boolean" != typeof ghash && null !== ghash || "boolean" != typeof result && null !== result || "boolean" != typeof settings.isPublic && null !== settings.isPublic || "string" != typeof settings.channelUrl && null !== settings.channelUrl || "string" != typeof url && null !== url && void 0 !== url || "string" != typeof data && check(data) && null !== data && void 0 !== data || "string" != typeof str && null !==
- str && void 0 !== str || "string" != typeof path && null !== path && void 0 !== path) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), storedItem);
- } else {
- a.forEach(function(g) {
- module.push(g.userId);
- });
- link.createChannelWithUserIds(module, progress, url, data, str, path, ghash, settings, restaurantId, result, storedItem);
- }
- };
- /**
- * @return {undefined}
- */
- link.createChannelWithUserIds = function() {
- /** @type {null} */
- var data = null;
- /** @type {null} */
- var result = null;
- /** @type {null} */
- var lang = null;
- /** @type {null} */
- var val = null;
- /** @type {null} */
- var a = null;
- /** @type {null} */
- var token = null;
- /** @type {null} */
- var url = null;
- /** @type {null} */
- var c = null;
- /** @type {!Array} */
- var q = [];
- var o = {
- isPublic : null,
- channelUrl : null
- };
- /** @type {null} */
- var t = null;
- switch(arguments.length) {
- case 2:
- data = arguments[0];
- /** @type {boolean} */
- result = false;
- token = arguments[1];
- break;
- case 3:
- data = arguments[0];
- result = arguments[1];
- token = arguments[2];
- break;
- case 4:
- data = arguments[0];
- result = arguments[1];
- url = arguments[2];
- token = arguments[3];
- break;
- case 6:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- token = arguments[5];
- break;
- case 7:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- url = arguments[5];
- token = arguments[6];
- break;
- case 8:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- url = arguments[5];
- c = arguments[6];
- token = arguments[7];
- break;
- case 9:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- url = arguments[5];
- c = arguments[6];
- o.isPublic = arguments[7].isPublic;
- o.channelUrl = arguments[7].channelUrl;
- token = arguments[8];
- break;
- case 10:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- url = arguments[5];
- c = arguments[6];
- o.isPublic = arguments[7].isPublic;
- o.channelUrl = arguments[7].channelUrl;
- q = arguments[8];
- token = arguments[9];
- break;
- case 11:
- data = arguments[0];
- result = arguments[1];
- lang = arguments[2];
- val = arguments[3];
- a = arguments[4];
- url = arguments[5];
- c = arguments[6];
- o.isPublic = arguments[7].isPublic;
- o.channelUrl = arguments[7].channelUrl;
- q = arguments[8];
- t = arguments[9];
- token = arguments[10];
- }
- if (setup.getInstance().hasLoggedIn()) {
- if (!Array.isArray(data) || "boolean" != typeof result && null !== result || "boolean" != typeof c && null !== c || "boolean" != typeof t && null !== t || "boolean" != typeof o.isPublic && null !== o.isPublic || "string" != typeof o.channelUrl && null !== o.channelUrl || "string" != typeof lang && null !== lang && void 0 !== lang || "string" != typeof val && check(val) && null !== val && void 0 !== val || "string" != typeof a && null !== a && void 0 !== a || "string" != typeof url &&
- null !== url && void 0 !== url) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), token);
- } else {
- var _this = data.filter(function(sceneUid, binderProcessPid, scenes) {
- return binderProcessPid === scenes.indexOf(sceneUid);
- });
- var currentUser = setup.getInstance().currentUser;
- _this.push(currentUser.userId);
- exports.getInstance().createGroupChannel(_this, result, lang, val, a, url, c, o, q, t, function(name, n) {
- if (n) {
- callback(null, n, token);
- } else {
- var opts = new link(name);
- link.cachedChannels[opts.url] = opts;
- callback(opts, null, token);
- }
- });
- }
- } else {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), token);
- }
- };
- link.cachedChannels = {};
- /**
- * @return {undefined}
- */
- link.clearCache = function() {
- link.cachedChannels = {};
- };
- /**
- * @param {?} tag
- * @return {undefined}
- */
- link.removeCachedChannel = function(tag) {
- delete link.cachedChannels[tag];
- };
- /**
- * @param {?} item
- * @return {?}
- */
- link.upsert = function(item) {
- var data = new link(item);
- if (link.cachedChannels.hasOwnProperty(data.url)) {
- if (data.isEphemeral) {
- var self = link.cachedChannels[data.url];
- item.last_message = self.lastMessage;
- item.unread_message_count = self.unreadMessageCount;
- }
- link.cachedChannels[data.url].update(item);
- } else {
- link.cachedChannels[data.url] = data;
- }
- return link.cachedChannels[data.url];
- };
- /**
- * @param {string} c
- * @param {!Function} pos
- * @return {undefined}
- */
- link.getChannelWithoutCache = function(c, pos) {
- if (c) {
- exports.getInstance().getGroupChannel(c, true, true, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, pos);
- } else {
- var s = link.upsert(data);
- callback(s, null, pos);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), pos);
- }
- };
- /**
- * @param {string} name
- * @param {!Function} index
- * @return {undefined}
- */
- link.getChannel = function(name, index) {
- if (name) {
- if (link.cachedChannels.hasOwnProperty(name)) {
- callback(link.cachedChannels[name], null, index);
- } else {
- link.getChannelWithoutCache(name, index);
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), index);
- }
- };
- link.markAsReadAllLastSentAt;
- /**
- * @param {string} e
- * @return {undefined}
- */
- link.markAsReadAll = function(e) {
- setup.getInstance().markAsReadAll(e);
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- var read = function(data) {
- if (data) {
- /** @type {number} */
- this.category = data.hasOwnProperty("cat") ? parseInt(data.cat) : 0;
- this.data = data.hasOwnProperty("data") ? data.data : null;
- /** @type {string} */
- this.channelUrl = data.hasOwnProperty("channel_url") ? String(data.channel_url) : "";
- /** @type {string} */
- this.channelType = data.hasOwnProperty("channel_type") ? String(data.channel_type) : update.CHANNEL_TYPE_GROUP;
- }
- /**
- * @return {?}
- */
- this.isGroupChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_GROUP;
- };
- /**
- * @return {?}
- */
- this.isOpenChannel = function() {
- return this.channelType === update.CHANNEL_TYPE_OPEN;
- };
- };
- /** @type {number} */
- read.CATEGORY_NONE = 0;
- /** @type {number} */
- read.CATEGORY_CHANNEL_ENTER = 10102;
- /** @type {number} */
- read.CATEGORY_CHANNEL_EXIT = 10103;
- /** @type {number} */
- read.CATEGORY_USER_CHANNEL_MUTE = 10201;
- /** @type {number} */
- read.CATEGORY_USER_CHANNEL_UNMUTE = 10200;
- /** @type {number} */
- read.CATEGORY_USER_CHANNEL_BAN = 10601;
- /** @type {number} */
- read.CATEGORY_USER_CHANNEL_UNBAN = 10600;
- /** @type {number} */
- read.CATEGORY_CHANNEL_FREEZE = 10701;
- /** @type {number} */
- read.CATEGORY_CHANNEL_UNFREEZE = 10700;
- /** @type {number} */
- read.CATEGORY_TYPING_START = 10900;
- /** @type {number} */
- read.CATEGORY_TYPING_END = 10901;
- /** @type {number} */
- read.CATEGORY_CHANNEL_JOIN = 1e4;
- /** @type {number} */
- read.CATEGORY_CHANNEL_LEAVE = 10001;
- /** @type {number} */
- read.CATEGORY_CHANNEL_INVITE = 10020;
- /** @type {number} */
- read.CATEGORY_CHANNEL_DECLINE_INVITE = 10022;
- /** @type {number} */
- read.CATEGORY_CHANNEL_PROP_CHANGED = 11e3;
- /** @type {number} */
- read.CATEGORY_CHANNEL_DELETED = 12e3;
- /** @type {number} */
- read.CATEGORY_CHANNEL_META_DATA_CHANGED = 11100;
- /** @type {number} */
- read.CATEGORY_CHANNEL_META_COUNTERS_CHANGED = 11200;
- /** @type {number} */
- read.CATEGORY_CHANNEL_HIDE = 13e3;
- /**
- * @param {(Object|string)} context
- * @return {undefined}
- */
- var _init = function(context) {
- if (context) {
- /** @type {number} */
- this.category = context.hasOwnProperty("cat") ? parseInt(context.cat) : 0;
- }
- };
- /** @type {number} */
- _init.CATEGORY_USER_BLOCK = 20001;
- /** @type {number} */
- _init.CATEGORY_USER_UNBLOCK = 2e4;
- /** @type {number} */
- _init.CATEGORY_FRIEND_DISCOVERED = 20900;
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- var client = function(data) {
- /** @type {string} */
- this.nickname = "";
- /** @type {string} */
- this.profileUrl = "";
- /** @type {string} */
- this.userId = "";
- /** @type {string} */
- this.connectionStatus = "";
- /** @type {null} */
- this.lastSeenAt = null;
- this.metaData = {};
- /** @type {boolean} */
- this.isActive = true;
- /** @type {null} */
- this.friendDiscoveryKey = null;
- /** @type {null} */
- this.friendName = null;
- /**
- * @return {?}
- */
- this.getOriginalProfileUrl = function() {
- /** @type {string} */
- var value = "";
- if (((value = (value = this.profileUrl.indexOf("://") > -1 ? this.profileUrl.split("/")[2] : this.profileUrl.split("/")[0]).split("?")[0]).indexOf("sendbird.com") > -1 || value.indexOf("intoz.com") > -1) && this.profileUrl.indexOf(value + "/profile_images/") > -1) {
- var locationPath = this.profileUrl.replace("profile_images/", "");
- return locationPath === this.profileUrl ? "" : locationPath;
- }
- return "";
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this._update = function(data) {
- if (data.hasOwnProperty("guest_id")) {
- /** @type {string} */
- this.userId = String(data.guest_id);
- }
- if (data.hasOwnProperty("user_id")) {
- /** @type {string} */
- this.userId = String(data.user_id);
- }
- if (data.hasOwnProperty("name")) {
- /** @type {string} */
- this.nickname = String(data.name);
- }
- if (data.hasOwnProperty("nickname")) {
- /** @type {string} */
- this.nickname = String(data.nickname);
- }
- if (data.hasOwnProperty("image")) {
- /** @type {string} */
- this.profileUrl = String(data.image);
- }
- if (data.hasOwnProperty("profile_url")) {
- /** @type {string} */
- this.profileUrl = String(data.profile_url);
- }
- if (data.hasOwnProperty("is_online")) {
- if (data.is_online === client.NON_AVAILABLE) {
- /** @type {string} */
- this.connectionStatus = client.NON_AVAILABLE;
- } else {
- /** @type {string} */
- this.connectionStatus = data.is_online ? client.ONLINE : client.OFFLINE;
- }
- } else {
- /** @type {string} */
- this.connectionStatus = client.NON_AVAILABLE;
- }
- if (data.hasOwnProperty("last_seen_at")) {
- /** @type {number} */
- this.lastSeenAt = parseInt(data.last_seen_at);
- } else {
- /** @type {number} */
- this.lastSeenAt = 0;
- }
- if (data.hasOwnProperty("metadata")) {
- this.metaData = data.metadata;
- } else {
- this.metaData = {};
- }
- if (data.hasOwnProperty("is_active")) {
- this.isActive = void 0 === data.is_active || data.is_active;
- } else {
- /** @type {boolean} */
- this.isActive = true;
- }
- if (data.hasOwnProperty("friend_discovery_key")) {
- this.friendDiscoveryKey = data.friend_discovery_key;
- } else {
- /** @type {null} */
- this.friendDiscoveryKey = null;
- }
- if (data.hasOwnProperty("friend_name")) {
- this.friendName = data.friend_name;
- } else {
- /** @type {null} */
- this.friendName = null;
- }
- };
- /**
- * @param {(Object|string)} e
- * @param {boolean} islongclick
- * @return {undefined}
- */
- this._updateMetaData = function(e, islongclick) {
- var me = this;
- /** @type {!Array<string>} */
- var s = Object.keys(e);
- if (islongclick) {
- s.forEach(function(key) {
- delete me.metaData[key];
- });
- } else {
- s.forEach(function(key) {
- me.metaData[key] = e[key];
- });
- }
- };
- /**
- * @param {!Object} value
- * @param {!Function} data
- * @return {?}
- */
- this.createMetaData = function(value, data) {
- var $this = this;
- return "function" == typeof value && 1 === arguments.length && (data = value, value = {}), "object" != typeof value || check(value) || Array.isArray(value) ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), data) : setup.getInstance().hasLoggedIn() ? void exports.getInstance().createUserMetaData($this.userId, value, function(e, exisObj) {
- if (exisObj) {
- callback(null, exisObj, data);
- } else {
- $this._updateMetaData(e);
- callback(e, null, data);
- }
- }) : void(data && callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), data));
- };
- /**
- * @param {!Object} value
- * @param {!Object} type
- * @param {!Function} data
- * @return {?}
- */
- this.updateMetaData = function(value, type, data) {
- var $this = this;
- return "function" == typeof value && 1 === arguments.length && (data = value, value = {}), "function" == typeof type && 2 === arguments.length && (data = type, type = false), "object" != typeof value || check(value) || Array.isArray(value) || "boolean" != typeof type ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), data) : setup.getInstance().hasLoggedIn() ? void exports.getInstance().updateUserMetaData($this.userId, value, type, function(e, n) {
- if (n) {
- callback(null, n, data);
- } else {
- $this._updateMetaData(e);
- callback(e, null, data);
- }
- }) : void(data && callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), data));
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.deleteAllMetaData = function(productInfo) {
- var response = this;
- var result = response.metaData;
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().deleteAllUserMetaData(response.userId, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- response._updateMetaData(result, true);
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- if (productInfo) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), productInfo);
- }
- }
- };
- /**
- * @param {string} n
- * @param {string} c
- * @return {undefined}
- */
- this.deleteMetaData = function(n, c) {
- var u = this;
- if ("function" == typeof n && 1 === arguments.length && (c = n, n = null), "string" == typeof n) {
- if (setup.getInstance().hasLoggedIn()) {
- var s = {};
- /** @type {string} */
- s[n] = "";
- exports.getInstance().deleteUserMetaData(u.userId, n, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, c);
- } else {
- u._updateMetaData(s, true);
- callback(identifierPositions, null, c);
- }
- });
- } else {
- if (c) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), c);
- }
- }
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), c);
- }
- };
- /**
- * @return {?}
- */
- this.serialize = function() {
- /** @type {*} */
- var passedValue1 = JSON.parse(JSON.stringify(this));
- return f(passedValue1);
- };
- if (data) {
- this._update(data);
- }
- };
- /** @type {string} */
- client.NON_AVAILABLE = "nonavailable";
- /** @type {string} */
- client.ONLINE = "online";
- /** @type {string} */
- client.OFFLINE = "offline";
- /**
- * @param {string} res
- * @param {string} value
- * @param {!Object} p
- * @param {!Object} set
- * @param {string} fn
- * @param {!Object} data
- * @param {!Object} i
- * @param {number} url
- * @param {number} key
- * @return {?}
- */
- client.build = function(res, value, p, set, fn, data, i, url, key) {
- return {
- user_id : res,
- nickname : value,
- profile_url : p,
- is_online : set,
- last_seen_at : fn,
- metadata : data,
- is_active : i,
- friend_discovery_key : url,
- friend_name : key
- };
- };
- /**
- * @param {?} scope
- * @return {?}
- */
- client.buildFromSerializedData = function(scope) {
- var $scope = $(scope);
- return new client(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName));
- };
- /**
- * @param {undefined} data
- * @return {undefined}
- */
- var _this = function(data) {
- /** @type {string} */
- this.state = "";
- /** @type {boolean} */
- this.isBlockedByMe = false;
- /** @type {boolean} */
- this.isBlockingMe = false;
- /**
- * @param {!Object} message
- * @return {undefined}
- */
- this.parse = function(message) {
- this.state = message.state;
- if (message.hasOwnProperty("is_blocked_by_me")) {
- this.isBlockedByMe = message.is_blocked_by_me;
- }
- if (message.hasOwnProperty("is_blocking_me")) {
- this.isBlockingMe = message.is_blocking_me;
- }
- };
- if (data) {
- this._update(data);
- this.parse(data);
- }
- };
- fn(client, _this);
- /** @type {string} */
- _this.JOINED = "joined";
- /** @type {string} */
- _this.INVITED = "invited";
- /**
- * @param {string} e
- * @param {!Object} res
- * @param {boolean} format
- * @param {boolean} data
- * @return {?}
- */
- _this.build = function(e, res, format, data) {
- /** @type {string} */
- var module = e;
- return module.state = res, module.is_blocked_by_me = format, module.is_blocking_me = data, module;
- };
- /**
- * @param {?} scope
- * @return {?}
- */
- _this.buildFromSerializedData = function(scope) {
- var $scope = $(scope);
- return new _this(_this.build(client.build($scope.userId, $scope.nickname, $scope.profileUrl, $scope.connectionStatus, $scope.lastSeenAt, $scope.metaData, $scope.isActive, $scope.friendDiscoveryKey, $scope.friendName), $scope.state, $scope.isBlockedByMe, $scope.isBlockingMe));
- };
- /**
- * @param {?} flightPhase
- * @param {?} navigationLibrary
- * @param {?} airportController
- * @return {?}
- */
- var init = function(flightPhase, navigationLibrary, airportController) {
- /**
- * @return {?}
- */
- this.isAckRequired = function() {
- return "MESG" === this.command || "FILE" === this.command || "ENTR" === this.command || "EXIT" === this.command || "READ" === this.command || "MEDI" === this.command || "FEDI" === this.command;
- };
- /**
- * @return {?}
- */
- this.encode = function() {
- return this.command + this.payload + "\n";
- };
- /**
- * @param {string} a
- * @return {undefined}
- */
- this.decode = function(a) {
- a = a.trim();
- this.command = a.substring(0, 4);
- this.payload = a.substring(4);
- };
- /**
- * @return {?}
- */
- this.getJsonElement = function() {
- return JSON.parse(this.payload);
- };
- /**
- * @return {?}
- */
- this.isRequestIdCommand = function() {
- return this.isAckRequired() || "EROR" === this.command;
- };
- this.command;
- this.payload;
- this.requestId;
- var id;
- var options = this;
- if (0 !== arguments.length) {
- switch(arguments.length) {
- case 1:
- var a = arguments[0];
- if (!a || a.length <= 4) {
- return options.command = "NOOP", void(options.payload = "{}");
- }
- if (a = a.trim(), options.command = a.substring(0, 4), options.payload = a.substring(4), options.isRequestIdCommand()) {
- var req = options.getJsonElement();
- if (req) {
- options.requestId = req.hasOwnProperty("req_id") ? req.req_id : "";
- }
- }
- break;
- case 3:
- id = arguments[2];
- case 2:
- var opts = arguments[0];
- var data = arguments[1];
- id = id || "";
- options.command = opts;
- options.requestId = id;
- if (!options.requestId) {
- if (options.isRequestIdCommand()) {
- options.requestId = init.generateRequestId();
- }
- }
- data.req_id = options.requestId;
- /** @type {string} */
- options.payload = JSON.stringify(data);
- }
- }
- };
- /**
- * @param {?} l
- * @param {string} m
- * @param {string} b
- * @param {string} s
- * @param {string} topic
- * @param {!Object} value
- * @param {number} track
- * @param {string} language
- * @return {?}
- */
- init.bMessage = function(l, m, b, s, topic, value, track, language) {
- var $scope = {};
- return $scope.channel_url = l, $scope.message = m, $scope.data = b, $scope.mention_type = topic, $scope.mentioned_user_ids = [], topic === UserService.MentionType.CHANNEL ? $scope.mentioned_user_ids = [] : Array.isArray(value) && value.length > 0 && ($scope.mentioned_user_ids = value), s && ($scope.custom_type = s), track.length > 0 && ($scope.target_langs = track), language && language !== next.PushNotificationDeliveryOption.DEFAULT && ($scope.push_option = language), new init("MESG",
- $scope);
- };
- /**
- * @param {?} selectedCube
- * @return {?}
- */
- init.bRead = function(selectedCube) {
- var connections = {};
- return connections.channel_url = selectedCube, new init("READ", connections);
- };
- /**
- * @param {?} key
- * @param {number} value
- * @return {?}
- */
- init.bTypeStart = function(key, value) {
- var context = {};
- return context.channel_url = key, context.time = value, new init("TPST", context);
- };
- /**
- * @param {?} index
- * @param {number} key
- * @return {?}
- */
- init.bTypeEnd = function(index, key) {
- var context = {};
- return context.channel_url = index, context.time = key, new init("TPEN", context);
- };
- /**
- * @param {number} header
- * @param {?} w
- * @param {string} p
- * @param {string} name
- * @param {string} type
- * @param {string} label
- * @param {string} f
- * @param {string} e
- * @param {!Object} value
- * @param {string} n
- * @param {string} c
- * @param {string} val
- * @param {string} s
- * @return {?}
- */
- init.bFile = function(header, w, p, name, type, label, f, e, value, n, c, val, s) {
- var data = {};
- return data.channel_url = w, data.url = p, data.name = name || "", data.type = type || "", data.size = label || 0, data.custom = f, e && (data.custom_type = e), value && (data.thumbnails = value), n && (data.require_auth = n), data.mention_type = c, data.mentioned_user_ids = [], c === UserService.MentionType.CHANNEL ? data.mentioned_user_ids = [] : Array.isArray(val) && val.length > 0 && (data.mentioned_user_ids = val), s && s !== set.PushNotificationDeliveryOption.DEFAULT && (data.push_option =
- s), new init("FILE", data, header);
- };
- /**
- * @return {?}
- */
- init.bPing = function() {
- var context = {};
- return context.id = (new Date).getTime(), new init("PING", context);
- };
- /**
- * @param {?} selectedCube
- * @return {?}
- */
- init.bEnter = function(selectedCube) {
- var connections = {};
- return connections.channel_url = selectedCube, new init("ENTR", connections);
- };
- /**
- * @param {?} selectedCube
- * @return {?}
- */
- init.bExit = function(selectedCube) {
- var connections = {};
- return connections.channel_url = selectedCube, new init("EXIT", connections);
- };
- /**
- * @param {?} key
- * @param {!Object} index
- * @param {?} type
- * @param {?} v
- * @param {number} dimension
- * @return {?}
- */
- init.bUpdateUserMessage = function(key, index, type, v, dimension) {
- var data = {};
- return data.channel_url = key, data.msg_id = index, null != type && void 0 !== type && (data.message = type), null != v && void 0 !== v && (data.data = v), null != dimension && void 0 !== dimension && (data.custom_type = dimension), new init("MEDI", data);
- };
- /**
- * @param {?} storePage
- * @param {!Object} id
- * @param {?} bool
- * @param {number} val
- * @return {?}
- */
- init.bUpdateFileMessage = function(storePage, id, bool, val) {
- var self = {};
- return self.channel_url = storePage, self.msg_id = id, null != bool && void 0 !== bool && (self.data = bool), null != val && void 0 !== val && (self.custom_type = val), new init("FEDI", self);
- };
- /** @type {number} */
- init.requestIdSeed = (new Date).getTime();
- /**
- * @return {?}
- */
- init.generateRequestId = function() {
- return init.requestIdSeed++, String(init.requestIdSeed);
- };
- /**
- * @param {?} scope
- * @return {undefined}
- */
- var postLink = function(scope) {
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {number} */
- this.limit = 20;
- /** @type {string} */
- var n = "";
- var $scope = this;
- /**
- * @param {string} stat
- * @return {?}
- */
- this.next = function(stat) {
- return $scope.hasNext ? $scope.isLoading ? void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat) : "number" != typeof $scope.limit || $scope.limit < 1 ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat) : ($scope.isLoading = true, void exports.getInstance().loadOperatorList(scope.url, scope.isOpenChannel(), n, $scope.limit, function(status, exisObj) {
- if (exisObj) {
- return $scope.isLoading = false, void callback(null, exisObj, stat);
- }
- /** @type {string} */
- var field = status;
- if (!(n = String(field.next)) || n.length <= 0) {
- /** @type {boolean} */
- $scope.hasNext = false;
- }
- var identifierPositions = field.operators.map(function(options) {
- return new client(options);
- });
- /** @type {boolean} */
- $scope.isLoading = false;
- callback(identifierPositions, null, stat);
- })) : void callback([], null, stat);
- };
- };
- /**
- * @param {?} seen
- * @return {undefined}
- */
- var reset = function(seen) {
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {number} */
- this.limit = 20;
- /** @type {string} */
- this.mutedMemberFilter = reset.MUTED_MEMBER_FILTER.ALL;
- /** @type {string} */
- this.operatorFilter = reset.OPERATOR_FILTER.ALL;
- /** @type {string} */
- this.memberStateFilter = link.memberStateFilter.ALL;
- /** @type {null} */
- this.nicknameStartsWithFilter = null;
- /** @type {string} */
- var numAddresses = reset.Order.MEMBER_NICKNAME_ALPHABETICAL;
- /** @type {string} */
- var authToken = "";
- var $scope = this;
- /**
- * @param {string} stat
- * @return {?}
- */
- this.next = function(stat) {
- return $scope.hasNext ? $scope.isLoading ? void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat) : "number" != typeof $scope.limit || $scope.limit < 1 || "string" != typeof $scope.mutedMemberFilter || [reset.MUTED_MEMBER_FILTER.ALL, reset.MUTED_MEMBER_FILTER.MUTED, reset.MUTED_MEMBER_FILTER.UNMUTED].indexOf($scope.mutedMemberFilter.toLowerCase()) < 0 || "string" != typeof $scope.operatorFilter || [reset.OPERATOR_FILTER.ALL, reset.OPERATOR_FILTER.OPERATOR,
- reset.OPERATOR_FILTER.NONOPERATOR].indexOf($scope.operatorFilter.toLowerCase()) < 0 || "string" != typeof $scope.memberStateFilter || [link.memberStateFilter.ALL, link.memberStateFilter.JOINED, link.memberStateFilter.INVITED, link.memberStateFilter.INVITED_BY_FRIEND, link.memberStateFilter.INVITED_BY_NON_FRIEND].indexOf($scope.memberStateFilter.toLowerCase()) < 0 || null !== $scope.nicknameStartsWithFilter && "string" != typeof $scope.nicknameStartsWithFilter ? void callback(null, new Date("Invalid parameter.",
- concat.INVALID_PARAMETER), stat) : ($scope.isLoading = true, void exports.getInstance().loadGroupChannelMemberList(seen, authToken, $scope.limit, $scope.mutedMemberFilter, $scope.operatorFilter, $scope.memberStateFilter, $scope.nicknameStartsWithFilter, numAddresses, function(bruce, n) {
- if (n) {
- return $scope.isLoading = false, void callback(null, n, stat);
- }
- /** @type {!Object} */
- var a = bruce;
- if (!(authToken = String(a.next)) || authToken.length <= 0) {
- /** @type {boolean} */
- $scope.hasNext = false;
- }
- var identifierPositions = a.members.map(function(operator) {
- return new _this(operator);
- });
- /** @type {boolean} */
- $scope.isLoading = false;
- callback(identifierPositions, null, stat);
- })) : void callback([], null, stat);
- };
- };
- reset.MUTED_MEMBER_FILTER = {
- ALL : "all",
- MUTED : "muted",
- UNMUTED : "unmuted"
- };
- reset.OPERATOR_FILTER = {
- ALL : "all",
- OPERATOR : "operator",
- NONOPERATOR : "nonoperator"
- };
- reset.Order = {
- MEMBER_NICKNAME_ALPHABETICAL : "member_nickname_alphabetical"
- };
- /**
- * @param {!Function} opt_configureForTesting
- * @return {undefined}
- */
- var Context = function(opt_configureForTesting) {
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {number} */
- this.limit = 20;
- /** @type {boolean} */
- this.includeEmpty = false;
- /** @type {string} */
- this.order = Context.ORDER_LATEST_LAST_MESSAGE;
- /** @type {!Array} */
- this.userIdsFilter = [];
- /** @type {boolean} */
- this.userIdsFilterExactMatch = false;
- /** @type {string} */
- this.queryType = "AND";
- var d = {
- userIds : [],
- includeMode : true,
- queryType : iterator.USER_IDS_INCLUDE_QUERY_TYPE.AND
- };
- /** @type {!Array} */
- this._userIdsExactFilter = [];
- /** @type {!Array} */
- this._userIdsIncludeFilter = [];
- /** @type {string} */
- this._userIdsIncludeFilterQueryType = iterator.USER_IDS_INCLUDE_QUERY_TYPE.AND;
- if (c) {
- /** @type {!Array} */
- this.userIdsExactFilter = this._userIdsExactFilter;
- /** @type {!Array} */
- this.userIdsIncludeFilter = this._userIdsIncludeFilter;
- /** @type {string} */
- this.userIdsIncludeFilterQueryType = this._userIdsIncludeFilterQueryType;
- } else {
- Object.defineProperty(this, "userIdsExactFilter", {
- get : function() {
- return this._userIdsExactFilter;
- },
- set : function(e) {
- if (Array.isArray(e)) {
- /** @type {!Object} */
- this._userIdsExactFilter = e;
- /** @type {!Array} */
- this._userIdsIncludeFilter = [];
- d = {
- userIds : this._userIdsExactFilter,
- includeMode : false
- };
- }
- }
- });
- Object.defineProperty(this, "userIdsIncludeFilter", {
- get : function() {
- return this._userIdsIncludeFilter;
- },
- set : function(e) {
- if (Array.isArray(e)) {
- /** @type {!Object} */
- this._userIdsIncludeFilter = e;
- /** @type {!Array} */
- this._userIdsExactFilter = [];
- d = {
- userIds : this._userIdsIncludeFilter,
- includeMode : true
- };
- }
- }
- });
- Object.defineProperty(this, "userIdsIncludeFilterQueryType", {
- get : function() {
- return this._userIdsIncludeFilterQueryType;
- },
- set : function(mymuted) {
- /** @type {string} */
- this._userIdsIncludeFilterQueryType = mymuted;
- d = {
- queryType : this._userIdsIncludeFilterQueryType
- };
- }
- });
- }
- /** @type {string} */
- this.nicknameContainsFilter = "";
- /** @type {string} */
- this.channelNameContainsFilter = "";
- /** @type {string} */
- this.memberStateFilter = link.memberStateFilter.ALL;
- /** @type {string} */
- this.customTypeFilter = "";
- /** @type {!Array} */
- this.customTypesFilter = [];
- /** @type {!Array} */
- this.channelUrlsFilter = [];
- /** @type {string} */
- this.superChannelFilter = link.superChannelFilter.ALL;
- /** @type {string} */
- this.publicChannelFilter = link.publicChannelFilter.ALL;
- /** @type {null} */
- this.customTypeStartsWithFilter = null;
- /** @type {!Function} */
- var c1State = opt_configureForTesting;
- /** @type {string} */
- var s = "";
- var options = this;
- /**
- * @param {string} stat
- * @return {?}
- */
- this.next = function(stat) {
- if (options.hasNext) {
- if (options.isLoading) {
- callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat);
- } else {
- if (null !== options.nicknameContainsFilter && void 0 !== options.nicknameContainsFilter || (options.nicknameContainsFilter = ""), null !== options.channelNameContainsFilter && void 0 !== options.channelNameContainsFilter || (options.channelNameContainsFilter = ""), null === options.customTypeStartsWithFilter || "string" == typeof options.customTypeStartsWithFilter) {
- if (!Array.isArray(options._userIdsExactFilter) || !Array.isArray(options._userIdsIncludeFilter) || "string" != typeof options._userIdsIncludeFilterQueryType || [iterator.USER_IDS_INCLUDE_QUERY_TYPE.AND, iterator.USER_IDS_INCLUDE_QUERY_TYPE.OR].indexOf(options._userIdsIncludeFilterQueryType.toUpperCase()) < 0) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat);
- } else {
- if ("number" == typeof options.memberStateFilter) {
- if (typeof options.memberStateFilter < 0 || typeof options.memberStateFilter > 4) {
- return void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat);
- }
- options.memberStateFilter = ["all", "joined_only", "invited_only", "invited_by_friend", "invited_by_non_friend"][options.memberStateFilter];
- }
- if (!cb(options.limit) || !Array.isArray(options.userIdsFilter) || "boolean" != typeof options.includeEmpty || "boolean" != typeof options.userIdsFilterExactMatch || "string" != typeof options.customTypeFilter || !Array.isArray(options.customTypesFilter) || "string" != typeof options.queryType || ["AND", "OR"].indexOf(options.queryType.toUpperCase()) < 0 || "string" != typeof options.order || [Context.ORDER_CHRONOLOGICAL, Context.ORDER_LATEST_LAST_MESSAGE, Context.CHANNEL_NAME_ALPHABETICAL].indexOf(options.order.toLowerCase()) <
- 0 || "string" != typeof options.memberStateFilter || [link.memberStateFilter.ALL, link.memberStateFilter.JOINED, link.memberStateFilter.INVITED, link.memberStateFilter.INVITED_BY_FRIEND, link.memberStateFilter.INVITED_BY_NON_FRIEND].indexOf(options.memberStateFilter.toLowerCase()) < 0 || "string" != typeof options.nicknameContainsFilter || "string" != typeof options.channelNameContainsFilter || !Array.isArray(options.channelUrlsFilter) || "string" != typeof options.superChannelFilter ||
- [link.superChannelFilter.ALL, link.superChannelFilter.SUPER, link.superChannelFilter.NON_SUPER].indexOf(options.superChannelFilter.toLowerCase()) < 0 || "string" != typeof options.publicChannelFilter || [link.publicChannelFilter.ALL, link.publicChannelFilter.PUBLIC, link.publicChannelFilter.PRIVATE].indexOf(options.publicChannelFilter.toLowerCase()) < 0) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat);
- } else {
- if (Array.isArray(options.userIdsFilter) && options.userIdsFilter.length > 0) {
- d = {
- userIds : options.userIdsFilter,
- includeMode : !options.userIdsFilterExactMatch,
- queryType : options.queryType
- };
- }
- /** @type {boolean} */
- options.isLoading = true;
- exports.getInstance().loadUserGroupChannelList(c1State.userId, s, options.limit, options.includeEmpty, options.order, d, options.nicknameContainsFilter, options.channelNameContainsFilter, options.channelUrlsFilter, options.customTypeFilter, options.customTypesFilter, options.customTypeStartsWithFilter, options.memberStateFilter, options.superChannelFilter, options.publicChannelFilter, function(calendar_obj, exisObj) {
- if (exisObj) {
- return options.isLoading = false, void callback(null, exisObj, stat);
- }
- /** @type {!Object} */
- var data = calendar_obj;
- if (!(s = String(data.next)) || s.length <= 0) {
- /** @type {boolean} */
- options.hasNext = false;
- }
- var allChannels = data.channels;
- /** @type {!Array} */
- var cache = [];
- var i;
- for (i in allChannels) {
- var u = link.upsert(allChannels[i]);
- cache.push(u);
- }
- /** @type {boolean} */
- options.isLoading = false;
- callback(cache, null, stat);
- });
- }
- }
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat);
- }
- }
- } else {
- callback([], null, stat);
- }
- };
- };
- /** @type {string} */
- Context.ORDER_LATEST_LAST_MESSAGE = "latest_last_message";
- /** @type {string} */
- Context.ORDER_CHRONOLOGICAL = "chronological";
- /** @type {string} */
- Context.CHANNEL_NAME_ALPHABETICAL = "channel_name_alphabetical";
- /** @type {string} */
- Context.MEMBER_STATE_INVITED_ONLY = "invited_only";
- /** @type {string} */
- Context.MEMBER_STATE_JOINED_ONLY = "joined_only";
- /** @type {string} */
- Context.MEMBER_STATE_ALL = "all";
- /**
- * @return {undefined}
- */
- var iterator = function() {
- /** @type {string} */
- var authToken = "";
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {number} */
- this.limit = 20;
- /** @type {boolean} */
- this.includeEmpty = true;
- /** @type {string} */
- this.order = iterator.ORDER_CHRONOLOGICAL;
- /** @type {null} */
- this.channelNameContainsFilter = null;
- /** @type {!Array} */
- this.channelUrlsFilter = [];
- /** @type {!Array} */
- this.customTypesFilter = [];
- /** @type {null} */
- this.customTypeStartsWithFilter = null;
- /** @type {string} */
- this.superChannelFilter = link.superChannelFilter.ALL;
- /** @type {string} */
- this.membershipFilter = iterator.MEMBERSHIP_TYPE.JOINED;
- var request = this;
- /**
- * @param {string} err
- * @return {?}
- */
- this.next = function(err) {
- return setup.getInstance().hasLoggedIn() ? request.hasNext ? request.isLoading ? void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), err) : !cb(request.limit) || "boolean" != typeof request.includeEmpty || !Array.isArray(request.customTypesFilter) || !Array.isArray(request.channelUrlsFilter) || null !== request.channelNameContainsFilter && "string" != typeof request.channelNameContainsFilter || null !== request.customTypeStartsWithFilter && "string" != typeof request.customTypeStartsWithFilter ||
- "string" != typeof request.order || [iterator.ORDER_CHRONOLOGICAL, iterator.ORDER_LATEST_LAST_MESSAGE, iterator.CHANNEL_NAME_ALPHABETICAL].indexOf(request.order.toLowerCase()) < 0 ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), err) : "string" != typeof request.superChannelFilter || [link.superChannelFilter.ALL, link.superChannelFilter.SUPER, link.superChannelFilter.NON_SUPER].indexOf(request.superChannelFilter.toLowerCase()) < 0 || "string" != typeof request.membershipFilter ||
- [iterator.MEMBERSHIP_TYPE.ALL, iterator.MEMBERSHIP_TYPE.JOINED].indexOf(request.membershipFilter.toLowerCase()) < 0 ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), err) : (request.isLoading = true, void exports.getInstance().loadPublicGroupChannelList(authToken, request.limit, request.includeEmpty, request.order, request.channelNameContainsFilter, request.channelUrlsFilter, request.customTypesFilter, request.customTypeStartsWithFilter, request.superChannelFilter,
- request.membershipFilter, function(calendar_obj, exisObj) {
- if (exisObj) {
- return request.isLoading = false, void callback(null, exisObj, err);
- }
- /** @type {!Object} */
- var data = calendar_obj;
- if (!(authToken = String(data.next)) || authToken.length <= 0) {
- /** @type {boolean} */
- request.hasNext = false;
- }
- var allChannels = data.channels;
- /** @type {!Array} */
- var cache = [];
- var i;
- for (i in allChannels) {
- var u = link.upsert(allChannels[i]);
- cache.push(u);
- }
- /** @type {boolean} */
- request.isLoading = false;
- callback(cache, null, err);
- })) : void callback([], null, err) : void(err && callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), err));
- };
- };
- /** @type {string} */
- iterator.ORDER_CHRONOLOGICAL = "chronological";
- /** @type {string} */
- iterator.CHANNEL_NAME_ALPHABETICAL = "channel_name_alphabetical";
- iterator.USER_IDS_INCLUDE_QUERY_TYPE = {
- AND : "AND",
- OR : "OR"
- };
- iterator.MEMBERSHIP_TYPE = {
- ALL : "all",
- JOINED : "joined"
- };
- /**
- * @param {!Object} width
- * @return {undefined}
- */
- var initialize = function(width) {
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {!Object} */
- var n = width;
- var maritalStatusesStore = this;
- /**
- * @param {undefined} results
- * @param {undefined} err
- * @param {?} val
- * @param {string} e
- * @return {undefined}
- */
- this.next = function(results, err, val, e) {
- if (maritalStatusesStore.isLoading) {
- callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), e);
- } else {
- if (4 === arguments.length) {
- if (cb(results) && cb(err) && "boolean" == typeof val) {
- /** @type {boolean} */
- maritalStatusesStore.isLoading = true;
- exports.getInstance().messageList(n.isOpenChannel(), n.url, results, 0, err, false, val, "", "", [], function(data, exisObj) {
- if (exisObj) {
- return maritalStatusesStore.isLoading = false, void callback(null, exisObj, e);
- }
- var msgs = data.messages;
- /** @type {!Array} */
- var identifierPositions = [];
- var i;
- for (i in msgs) {
- var fn = $.build(msgs[i], n);
- if (fn) {
- identifierPositions.push(fn);
- }
- }
- /** @type {boolean} */
- maritalStatusesStore.isLoading = false;
- callback(identifierPositions, null, e);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- }
- } else {
- if ("function" != typeof e) {
- /** @type {!Array<?>} */
- var i = Array.prototype.slice.call(arguments);
- if ("function" == typeof i.slice(-1)[0]) {
- e = i.pop();
- }
- }
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- }
- }
- };
- /**
- * @param {undefined} e
- * @param {undefined} t
- * @param {?} obj
- * @param {string} a
- * @return {undefined}
- */
- this.prev = function(e, t, obj, a) {
- if (maritalStatusesStore.isLoading) {
- callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), a);
- } else {
- if (4 === arguments.length) {
- if (cb(e) && cb(t) && "boolean" == typeof obj) {
- /** @type {boolean} */
- maritalStatusesStore.isLoading = true;
- exports.getInstance().messageList(n.isOpenChannel(), n.url, e, t, 0, false, obj, "", "", [], function(data, exisObj) {
- if (exisObj) {
- return maritalStatusesStore.isLoading = false, void callback(null, exisObj, a);
- }
- var msgs = data.messages;
- /** @type {!Array} */
- var identifierPositions = [];
- var i;
- for (i in msgs) {
- var fn = $.build(msgs[i], n);
- if (fn) {
- identifierPositions.push(fn);
- }
- }
- /** @type {boolean} */
- maritalStatusesStore.isLoading = false;
- callback(identifierPositions, null, a);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), a);
- }
- } else {
- if ("function" != typeof a) {
- /** @type {!Array<?>} */
- var i = Array.prototype.slice.call(arguments);
- if ("function" == typeof i.slice(-1)[0]) {
- a = i.pop();
- }
- }
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), a);
- }
- }
- };
- /**
- * @param {undefined} results
- * @param {undefined} err
- * @param {undefined} r
- * @param {?} path
- * @param {string} e
- * @return {undefined}
- */
- this.load = function(results, err, r, path, e) {
- if (maritalStatusesStore.isLoading) {
- callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), e);
- } else {
- if (5 === arguments.length) {
- if (cb(results) && cb(err) && cb(r) && "boolean" == typeof path) {
- /** @type {boolean} */
- maritalStatusesStore.isLoading = true;
- exports.getInstance().messageList(n.isOpenChannel(), n.url, results, err, r, true, path, "", "", [], function(data, exisObj) {
- if (exisObj) {
- return maritalStatusesStore.isLoading = false, void callback(null, exisObj, e);
- }
- var msgs = data.messages;
- /** @type {!Array} */
- var identifierPositions = [];
- var i;
- for (i in msgs) {
- var fn = $.build(msgs[i], n);
- if (fn) {
- identifierPositions.push(fn);
- }
- }
- /** @type {boolean} */
- maritalStatusesStore.isLoading = false;
- callback(identifierPositions, null, e);
- });
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- }
- } else {
- if ("function" != typeof e) {
- /** @type {!Array<?>} */
- var o = Array.prototype.slice.call(arguments);
- if ("function" == typeof o.slice(-1)[0]) {
- e = o.pop();
- }
- }
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), e);
- }
- }
- };
- };
- /**
- * @return {undefined}
- */
- var Controller = function() {
- /** @type {string} */
- var authToken = "";
- /** @type {number} */
- this.limit = 20;
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {null} */
- this.nameKeyword = null;
- /** @type {null} */
- this.urlKeyword = null;
- /** @type {null} */
- this.customType = null;
- var self = this;
- /**
- * @param {string} stat
- * @return {?}
- */
- this.next = function(stat) {
- return this.hasNext ? this.isLoading ? void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat) : "string" != typeof self.nameKeyword && null !== self.nameKeyword || "string" != typeof self.urlKeyword && null !== self.urlKeyword || "string" != typeof self.customType && null !== self.customType || !cb(self.limit) ? void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat) : (self.isLoading = true, void exports.getInstance().loadOpenChannelList(authToken,
- self.limit, self.nameKeyword, self.urlKeyword, self.customType, function(text, exisObj) {
- if (exisObj) {
- return self.isLoading = false, void callback(null, exisObj, stat);
- }
- /** @type {!Object} */
- var state = text;
- try {
- /** @type {string} */
- authToken = String(state.next);
- } catch (n) {
- /** @type {string} */
- authToken = "";
- }
- if (!authToken) {
- /** @type {boolean} */
- self.hasNext = false;
- }
- var channels = state.channels;
- /** @type {!Array} */
- var o = [];
- channels.forEach(function(query) {
- var n = Model.upsert(query);
- o.push(n);
- });
- /** @type {boolean} */
- self.isLoading = false;
- callback(o, null, stat);
- })) : void callback([], null, stat);
- };
- };
- /**
- * @param {!Object} options
- * @return {undefined}
- */
- var Assets = function(options) {
- /** @type {!Object} */
- var data = options;
- /** @type {number} */
- var start = 0x7fffffffffffffff;
- /** @type {boolean} */
- this.hasMore = true;
- /** @type {boolean} */
- this.isLoading = false;
- var self = this;
- /** @type {number} */
- this.limit = 20;
- /** @type {boolean} */
- this.reverse = false;
- /** @type {null} */
- this.messageTypeFilter = null;
- /** @type {null} */
- this.customTypeFilter = null;
- /** @type {!Array} */
- this.senderUserIdsFilter = [];
- /**
- * @return {?}
- */
- this.load = function() {
- /** @type {null} */
- var productInfo = null;
- /** @type {!Array<?>} */
- var nodes = Array.prototype.slice.call(arguments);
- switch("function" == typeof nodes.slice(-1)[0] && (productInfo = nodes.pop()), nodes.length) {
- case 2:
- this.limit = nodes[0];
- this.reverse = nodes[1];
- break;
- case 3:
- this.limit = nodes[0];
- this.reverse = nodes[1];
- this.messageTypeFilter = nodes[2];
- }
- if (null === this.messageTypeFilter || void 0 === this.messageTypeFilter || this.messageTypeFilter === R.MessageTypeFilter.ALL ? this.messageTypeFilter = "" : this.messageTypeFilter.toString().toLowerCase() === $.MESSAGE_TYPE_USER || this.messageTypeFilter === R.MessageTypeFilter.USER ? this.messageTypeFilter = "MESG" : this.messageTypeFilter.toString().toLowerCase() === $.MESSAGE_TYPE_FILE || this.messageTypeFilter === R.MessageTypeFilter.FILE ? this.messageTypeFilter = "FILE" : this.messageTypeFilter.toString().toLowerCase() !==
- $.MESSAGE_TYPE_ADMIN && this.messageTypeFilter !== R.MessageTypeFilter.ADMIN || (this.messageTypeFilter = "ADMM"), !cb(this.limit) || "boolean" != typeof this.reverse || null !== this.messageTypeFilter && "string" != typeof this.messageTypeFilter || null !== this.customTypeFilter && "string" != typeof this.customTypeFilter || !Array.isArray(this.senderUserIdsFilter)) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), productInfo);
- } else {
- /** @type {number} */
- var layer_i = 0;
- for (; layer_i < this.senderUserIdsFilter.length; layer_i++) {
- if ("string" != typeof this.senderUserIdsFilter[layer_i]) {
- return void callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), productInfo);
- }
- }
- if (self.hasMore) {
- if (self.isLoading) {
- return void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), productInfo);
- }
- /** @type {boolean} */
- self.isLoading = true;
- exports.getInstance().messageList(data.isOpenChannel(), data.url, start, this.limit, 0, false, this.reverse, this.messageTypeFilter, this.customTypeFilter, this.senderUserIdsFilter, function(data, exisObj) {
- if (exisObj) {
- return self.isLoading = false, void callback(null, exisObj, productInfo);
- }
- var msgs = data.messages;
- /** @type {!Array} */
- var queue = [];
- var i;
- for (i in msgs) {
- var token = $.build(msgs[i], data);
- if (token) {
- queue.push(token);
- if (token.createdAt <= start) {
- start = token.createdAt;
- }
- }
- }
- if (queue.length <= 0 || queue.length < self.limit) {
- /** @type {boolean} */
- self.hasMore = false;
- }
- /** @type {boolean} */
- self.isLoading = false;
- callback(queue, null, productInfo);
- });
- }
- }
- };
- };
- /**
- * @param {number} track
- * @param {!Object} url
- * @return {undefined}
- */
- var load = function(track, url) {
- var lastTrackTitle;
- var s;
- var result;
- /** @type {string} */
- var a = "";
- /** @type {boolean} */
- this.hasNext = true;
- /** @type {number} */
- this.limit = 20;
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {!Array} */
- this.userIds = [];
- /** @type {string} */
- this.metaDataKey = "";
- /** @type {!Array} */
- this.metaDataValues = [];
- var data = this;
- switch(url && (s = url), lastTrackTitle = track) {
- case load.ALL_USER:
- case load.BLOCKED_USER:
- /** @type {string} */
- result = "users";
- break;
- case load.FILTERED_USER:
- /** @type {!Object} */
- this.userIds = url;
- /** @type {string} */
- result = "users";
- break;
- case load.PARTICIPANT:
- /** @type {string} */
- result = "participants";
- break;
- case load.MUTED_USER:
- /** @type {string} */
- result = "muted_list";
- break;
- case load.BANNED_USER:
- /** @type {string} */
- result = "banned_list";
- }
- /**
- * @param {string} stat
- * @return {undefined}
- */
- this.next = function(stat) {
- if (data.hasNext) {
- if (setup.getInstance().hasLoggedIn()) {
- if (data.isLoading) {
- callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat);
- } else {
- if (!(cb(data.limit) && Array.isArray(data.userIds) && "string" == typeof data.metaDataKey && Array.isArray(data.metaDataValues)) || data.metaDataKey && check(data.metaDataValues) || !data.metaDataKey && !check(data.metaDataValues)) {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), stat);
- } else {
- /** @type {boolean} */
- data.isLoading = true;
- /**
- * @param {!Object} res
- * @param {?} refresh
- * @return {?}
- */
- var create = function(res, refresh) {
- if (refresh) {
- return data.isLoading = false, void callback(null, refresh, stat);
- }
- if (!(a = res.next)) {
- /** @type {boolean} */
- data.hasNext = false;
- }
- var r = res[result];
- /** @type {!Array} */
- var users = [];
- var i;
- for (i in r) {
- if (track === load.BANNED_USER) {
- users.push(new client(r[i].user));
- } else {
- users.push(new client(r[i]));
- }
- }
- /** @type {boolean} */
- data.isLoading = false;
- callback(users, null, stat);
- };
- switch(lastTrackTitle) {
- case load.ALL_USER:
- exports.getInstance().loadUserList(a, data.limit, [], data.metaDataKey, data.metaDataValues, create);
- break;
- case load.FILTERED_USER:
- exports.getInstance().loadUserList(a, data.limit, data.userIds, data.metaDataKey, data.metaDataValues, create);
- break;
- case load.BLOCKED_USER:
- exports.getInstance().loadBlockedUserList(setup.getInstance().getCurrentUserId(), a, data.limit, create);
- break;
- case load.PARTICIPANT:
- exports.getInstance().loadOpenChannelParticipantList(s.url, a, data.limit, create);
- break;
- case load.MUTED_USER:
- exports.getInstance().loadMutedUserList(s, a, data.limit, create);
- break;
- case load.BANNED_USER:
- exports.getInstance().loadBannedUserList(s, a, data.limit, create);
- }
- }
- }
- } else {
- if (stat) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED), stat);
- }
- }
- } else {
- callback([], null, stat);
- }
- };
- };
- /** @type {string} */
- load.ALL_USER = "alluser";
- /** @type {string} */
- load.FILTERED_USER = "filtereduser";
- /** @type {string} */
- load.BLOCKED_USER = "blockeduser";
- /** @type {string} */
- load.PARTICIPANT = "participant";
- /** @type {string} */
- load.MUTED_USER = "muteduser";
- /** @type {string} */
- load.BANNED_USER = "banneduser";
- /**
- * @return {undefined}
- */
- var concat = function() {
- };
- /** @type {number} */
- concat.INVALID_INITIALIZATION = 800100;
- /** @type {number} */
- concat.CONNECTION_REQUIRED = 800101;
- /** @type {number} */
- concat.INVALID_PARAMETER = 800110;
- /** @type {number} */
- concat.NETWORK_ERROR = 800120;
- /** @type {number} */
- concat.NETWORK_ROUTING_ERROR = 800121;
- /** @type {number} */
- concat.MALFORMED_DATA = 800130;
- /** @type {number} */
- concat.MALFORMED_ERROR_DATA = 800140;
- /** @type {number} */
- concat.WRONG_CHANNEL_TYPE = 800150;
- /** @type {number} */
- concat.MARK_AS_READ_RATE_LIMIT_EXCEEDED = 800160;
- /** @type {number} */
- concat.QUERY_IN_PROGRESS = 800170;
- /** @type {number} */
- concat.ACK_TIMEOUT = 800180;
- /** @type {number} */
- concat.LOGIN_TIMEOUT = 800190;
- /** @type {number} */
- concat.WEBSOCKET_CONNECTION_CLOSED = 800200;
- /** @type {number} */
- concat.WEBSOCKET_CONNECTION_FAILED = 800210;
- /** @type {number} */
- concat.REQUEST_FAILED = 800220;
- /** @type {number} */
- concat.FILE_UPLOAD_CANCEL_FAILED = 800230;
- /** @type {number} */
- concat.REQUEST_CANCELLED = 800240;
- /**
- * @param {?} listener
- * @return {undefined}
- */
- var Client = function(listener) {
- var socket;
- var newentry_;
- /** @type {boolean} */
- var callback_topic = false;
- if (!listener) {
- listener = new Client.WSClientHandler;
- }
- /**
- * @return {?}
- */
- this.getConnectionState = function() {
- return 1 === socket.readyState ? setup.getInstance().connectionState.OPEN : setup.getInstance().connectionState.CLOSED;
- };
- var riak = new function() {
- var _takingTooLongTimeout;
- var paintNodesTimeout;
- /**
- * @return {undefined}
- */
- this.ping = function() {
- if (t) {
- console.log("PING");
- }
- clearTimeout(_takingTooLongTimeout);
- clearTimeout(paintNodesTimeout);
- /** @type {number} */
- _takingTooLongTimeout = setTimeout(function() {
- var a = init.bPing();
- setup.getInstance().wsClient.send(a);
- /** @type {number} */
- paintNodesTimeout = setTimeout(function() {
- if (t) {
- console.log("PING Timeout");
- }
- clearTimeout(_takingTooLongTimeout);
- clearTimeout(paintNodesTimeout);
- listener.onError();
- }, 5e3);
- }, 15e3);
- };
- /**
- * @return {undefined}
- */
- this.stop = function() {
- clearTimeout(_takingTooLongTimeout);
- clearTimeout(paintNodesTimeout);
- };
- };
- /**
- * @param {!Object} o
- * @param {!Object} name
- * @param {?} v
- * @return {?}
- */
- this.connect = function(o, name, v) {
- if (t) {
- console.log("WSClient connect called");
- }
- newentry_ = v;
- /** @type {null} */
- var Socket = null;
- /** @type {boolean} */
- var _ = false;
- try {
- Socket = "undefined" == typeof WebSocket ? require("./node_modules/websocket/lib/browser.js").w3cwebsocket : WebSocket;
- } catch (e) {
- /** @type {function(new:WebSocket, string, string=): ?} */
- Socket = WebSocket;
- }
- try {
- /** @type {string} */
- var entryName = "/?p=JS&pv=" + encodeURIComponent(i) + "&sv=" + encodeURIComponent("3.0.69") + "&ai=" + encodeURIComponent(path);
- if (exports.getInstance().sessionKey ? entryName = entryName + ("&key=" + encodeURIComponent(exports.getInstance().sessionKey)) : entryName = entryName + ("&user_id=" + encodeURIComponent(o) + "&access_token=" + encodeURIComponent(name)), !(socket = new Socket(newentry_ + entryName))) {
- return void listener.onError("ws is not exist.");
- }
- } catch (id) {
- return void listener.onError(id);
- }
- if (t) {
- try {
- window.ws = socket;
- } catch (e) {
- }
- }
- /**
- * @param {?} evt
- * @return {undefined}
- */
- socket.onopen = function(evt) {
- if (riak) {
- riak.ping();
- }
- if (t) {
- console.log("WSClient onopen called");
- }
- listener.onOpen(evt);
- };
- /**
- * @param {!Object} event
- * @return {undefined}
- */
- socket.onmessage = function(event) {
- (new Date).getTime();
- var functions = event.data.split("\n");
- var name;
- for (name in functions) {
- var fn = functions[name];
- if (fn && "string" == typeof fn) {
- try {
- if ("PONG" === fn.substring(0, 4)) {
- if (riak) {
- riak.ping();
- }
- continue;
- }
- } catch (size_buffer) {
- if (t) {
- console.log("ws.onmessage-command check error: ", size_buffer);
- }
- }
- listener.onMessage(fn);
- }
- }
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- socket.onclose = function(e) {
- if (t) {
- console.log("WSClient ws.onclose called - e, explicitDisconnect: ", e, callback_topic);
- }
- if (riak) {
- riak.stop();
- }
- if (callback_topic) {
- listener.onClose(e);
- } else {
- if (!_) {
- listener.onError(e);
- }
- }
- /** @type {boolean} */
- callback_topic = false;
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- socket.onerror = function(e) {
- if (t) {
- console.log("WSClient ws.onerror called: ", e);
- }
- if (riak) {
- riak.stop();
- }
- /** @type {boolean} */
- _ = true;
- listener.onError(e);
- };
- };
- /**
- * @param {?} force
- * @param {?} callback
- * @return {undefined}
- */
- this.disconnect = function(force, callback) {
- if (t) {
- console.log("WSClient disconnect called [explicit]: ", force);
- }
- if (riak) {
- riak.stop();
- }
- /** @type {null} */
- riak = null;
- /** @type {boolean} */
- callback_topic = true === force;
- if (socket) {
- /**
- * @return {undefined}
- */
- socket.onopen = function() {
- };
- /**
- * @return {undefined}
- */
- socket.onmessage = function() {
- };
- /**
- * @return {undefined}
- */
- socket.onclose = function() {
- if (callback) {
- callback();
- }
- };
- /**
- * @return {undefined}
- */
- socket.onerror = function() {
- };
- socket.close();
- /** @type {null} */
- socket = null;
- }
- if (callback_topic) {
- listener.onClose();
- } else {
- listener.onError();
- }
- /** @type {boolean} */
- callback_topic = false;
- };
- /**
- * @param {!Object} value
- * @param {!Function} next
- * @return {undefined}
- */
- this.send = function(value, next) {
- if (1 !== socket.readyState) {
- if (next) {
- next(null, new Date("Connection is not valid. Please reconnect.", concat.WEBSOCKET_CONNECTION_CLOSED));
- }
- } else {
- socket.send(value.encode());
- if (next) {
- next(null, null);
- }
- }
- };
- };
- /**
- * @return {undefined}
- */
- Client.WSClientHandler = function() {
- /**
- * @return {undefined}
- */
- this.onReady = function() {
- };
- /**
- * @return {undefined}
- */
- this.onOpen = function() {
- };
- /**
- * @return {undefined}
- */
- this.onClose = function() {
- };
- /**
- * @return {undefined}
- */
- this.onMessage = function() {
- };
- /**
- * @return {undefined}
- */
- this.onError = function() {
- };
- };
- /**
- * @return {?}
- */
- var exports = function() {
- var quandl = exports.getInstance();
- if (quandl) {
- return quandl;
- }
- this.sessionKey;
- /** @type {number} */
- var t = 0;
- /**
- * @param {string} _
- * @param {?} c
- * @param {string} t
- * @param {!Function} e
- * @return {undefined}
- */
- this.getMessageChangeLogsByToken = function(_, c, t, e) {
- /** @type {string} */
- var r = "";
- /** @type {string} */
- r = _ ? exports.API_OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s", encodeURIComponent(c)) : exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s", encodeURIComponent(c));
- var app = {};
- if (t) {
- /** @type {string} */
- app.token = t;
- }
- callback(r, app, e);
- };
- /**
- * @param {?} s
- * @param {?} n
- * @param {string} k
- * @return {undefined}
- */
- this.setChannelInvitationPreference = function(s, n, k) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s", encodeURIComponent(s));
- render(lexed, {
- auto_accept : n
- }, k);
- };
- /**
- * @param {?} s
- * @param {string} color
- * @return {undefined}
- */
- this.getChannelInvitationPreference = function(s, color) {
- /** @type {string} */
- var t = exports.API_USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s", encodeURIComponent(s));
- callback(t, color);
- };
- /**
- * @param {?} xml
- * @param {number} t
- * @param {!Function} c
- * @return {undefined}
- */
- this.getGroupChannelCount = function(xml, t, c) {
- /** @type {string} */
- var s = exports.API_USERS_USERID_GROUP_CHANNEL_COUNT.replace("%s", encodeURIComponent(xml));
- /** @type {string} */
- var isActive = "";
- /** @type {string} */
- isActive = t === link.memberState.JOINED ? "joined" : t === link.memberState.INVITED ? "invited" : t === link.memberState.INVITED_BY_FRIEND ? "invited_by_friend" : t === link.memberState.INVITED_BY_NON_FRIEND ? "invited_by_non_friend" : "all";
- callback(s, {
- state : isActive
- }, c);
- };
- /**
- * @param {?} s
- * @param {!Array} n
- * @param {!Function} updated
- * @return {undefined}
- */
- this.getUnreadItemCount = function(s, n, updated) {
- /** @type {string} */
- var e = exports.API_USERS_USERID_UNREAD_ITEM_COUNT.replace("%s", encodeURIComponent(s));
- var r = {
- item_keys : n.join(",")
- };
- callback(e, r, updated);
- };
- /**
- * @param {?} hash
- * @param {!Object} result
- * @param {string} styles
- * @param {!Function} zoom
- * @return {undefined}
- */
- this.getTotalUnreadMessageCount = function(hash, result, styles, zoom) {
- /** @type {string} */
- var r = exports.API_USERS_USERID_UNREAD_MESSAGE_COUNT.replace("%s", encodeURIComponent(hash));
- /** @type {null} */
- var body = null;
- if (null !== result && result.length > 0) {
- body = extend(result);
- }
- var x = {
- super_mode : styles
- };
- if (body) {
- x.custom_types = body;
- }
- callback(r, x, zoom);
- };
- /**
- * @param {?} s
- * @param {string} color
- * @return {undefined}
- */
- this.getTotalUnreadChannelCount = function(s, color) {
- /** @type {string} */
- var t = exports.API_USERS_USERID_UNREAD_CHANNEL_COUNT.replace("%s", encodeURIComponent(s));
- callback(t, color);
- };
- /**
- * @param {!Function} cb
- * @return {undefined}
- */
- this.checkRouting = function(cb) {
- if (setup.getInstance() && setup.getInstance().customApiHost && setup.getInstance().customWsHost) {
- if ("function" == typeof cb) {
- cb({
- API_HOST : setup.getInstance().customApiHost,
- WS_HOST : setup.getInstance().customWsHost
- });
- }
- } else {
- /** @type {number} */
- var t0 = (new Date).getTime() / 1e3;
- if (0 === t || t - t0 > 300) {
- get(exports.API_ROUTING_URL.replace("%s", path), {}, "GET", {
- SendBird : spec + path
- }, function(result, i) {
- if (i) {
- cb(null, new Date("Server is unreachable.", concat.NETWORK_ROUTING_ERROR));
- } else {
- ref1 = result.ws_server;
- combined = result.api_server;
- /** @type {number} */
- t = t0;
- if ("function" == typeof cb) {
- cb({
- API_HOST : combined,
- WS_HOST : ref1
- });
- }
- }
- });
- } else {
- cb({
- API_HOST : setup.getInstance().getCurrentApiHost(),
- WS_HOST : setup.getInstance().getCurrentWsHost()
- }, null);
- }
- }
- };
- /**
- * @param {string} data
- * @param {number} level
- * @param {!Object} file
- * @param {string} obj
- * @param {!Object} stream
- * @param {string} state
- * @param {!Function} done
- * @param {?} progress
- * @param {?} params
- * @param {?} type
- * @return {undefined}
- */
- var request = function(data, level, file, obj, stream, state, done, progress, params, type) {
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().checkRouting(function(config, canCreateDiscussions) {
- if (canCreateDiscussions) {
- done(null, new Date("Request failed.", concat.REQUEST_FAILED));
- } else {
- var xhr = cb();
- xhr.open("POST", config.API_HOST + data, true);
- xhr.setRequestHeader("SendBird", spec + path);
- xhr.setRequestHeader("Session-Key", exports.getInstance().sessionKey);
- var self = Model ? new Model : new FormData;
- var i;
- for (i in obj && "undefined" != typeof Blob && (file instanceof Blob || "string" == typeof file || Array.isArray(file) || file.hasOwnProperty("isRNFetchBlobPolyfill")) ? self.append("file", new Blob([file], {
- type : obj
- }), file.name) : self.append("file", file, file.name), state && self.append("channel_url", state), stream) {
- /** @type {number} */
- var id = parseInt(i) + 1;
- self.append("thumbnail" + id, stream[i].maxWidth + "," + stream[i].maxHeight);
- }
- /**
- * @return {undefined}
- */
- xhr.onload = function() {
- if (params && params[type]) {
- delete params[type];
- }
- if (xhr.status >= 200 && xhr.status < 400) {
- callback(null, JSON.parse(xhr.responseText), done);
- } else {
- callback({
- status : xhr.status,
- statusText : xhr.statusText,
- response : xhr.responseText
- }, null, done);
- }
- };
- /**
- * @param {?} event
- * @return {undefined}
- */
- xhr.onerror = function(event) {
- if (params && params[type]) {
- delete params[type];
- }
- done(null, new Date(xhr.statusText, concat.REQUEST_FAILED));
- };
- /**
- * @param {?} event
- * @return {undefined}
- */
- xhr.onabort = function(event) {
- if (params && params[type]) {
- delete params[type];
- }
- done(null, new Date("File upload has been cancelled.", concat.REQUEST_CANCELLED));
- };
- /**
- * @param {!ProgressEvent} e
- * @return {undefined}
- */
- xhr.upload.onprogress = function(e) {
- if (e.lengthComputable && e.loaded >= e.total && params && params[type]) {
- delete params[type];
- }
- if (progress) {
- progress(e);
- }
- };
- if (self.oldIE) {
- xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + self.boundary);
- xhr.send(self.toString());
- } else {
- xhr.send(self);
- }
- if (params) {
- params[type] = xhr;
- }
- }
- });
- } else {
- if (done) {
- done(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {string} data
- * @param {!Object} obj
- * @param {!Object} callback
- * @return {undefined}
- */
- var forEach = function(data, obj, callback) {
- if ("function" == typeof obj) {
- /** @type {!Object} */
- callback = obj;
- obj = {};
- }
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().checkRouting(function(config, canCreateDiscussions) {
- if (canCreateDiscussions) {
- callback(null, new Date("Request failed.", concat.REQUEST_FAILED));
- } else {
- get(config.API_HOST + data, obj, "DELETE", {
- "Session-Key" : exports.getInstance().sessionKey,
- SendBird : spec + path
- }, callback);
- }
- });
- } else {
- if (callback) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {!Object} arr
- * @return {?}
- */
- var extend = function(arr) {
- /** @type {string} */
- var reverse_search_string = "";
- var index;
- for (index in arr) {
- if (arr.hasOwnProperty(index)) {
- /** @type {string} */
- reverse_search_string = reverse_search_string + (encodeURIComponent(arr[index]) + ",");
- }
- }
- return reverse_search_string.length > 1 && (reverse_search_string = reverse_search_string.substring(0, reverse_search_string.length - 1)), reverse_search_string;
- };
- /**
- * @param {string} str
- * @param {!Object} n
- * @param {!Function} text
- * @return {undefined}
- */
- var callback = function(str, n, text) {
- if ("function" == typeof n && (text = n, n = {}), setup.getInstance().hasLoggedIn()) {
- var data;
- /** @type {string} */
- var value = "";
- if (n) {
- var c;
- for (c in n) {
- if ("" !== value) {
- /** @type {string} */
- value = value + "&";
- }
- /** @type {string} */
- value = value + (c + "=" + n[c]);
- }
- /** @type {string} */
- data = str + "?" + value;
- } else {
- /** @type {string} */
- data = str;
- }
- exports.getInstance().checkRouting(function(config, canCreateDiscussions) {
- if (canCreateDiscussions) {
- text(null, new Date("Request failed.", concat.REQUEST_FAILED));
- } else {
- get(config.API_HOST + data, n, "GET", {
- "Session-Key" : exports.getInstance().sessionKey,
- SendBird : spec + path
- }, text);
- }
- });
- } else {
- if (text) {
- text(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {string} data
- * @param {!Object} options
- * @param {!Function} callback
- * @return {undefined}
- */
- var next = function(data, options, callback) {
- if ("function" == typeof options) {
- /** @type {!Object} */
- callback = options;
- options = {};
- }
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().checkRouting(function(config, webhookMsg) {
- if (webhookMsg) {
- callback(null, webhookMsg);
- } else {
- get(config.API_HOST + data, options, "POST", {
- "Session-Key" : exports.getInstance().sessionKey,
- SendBird : spec + path
- }, callback);
- }
- });
- } else {
- if (callback) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {string} input
- * @param {!Object} obj
- * @param {!Object} text
- * @return {undefined}
- */
- var render = function(input, obj, text) {
- if ("function" == typeof obj) {
- /** @type {!Object} */
- text = obj;
- obj = {};
- }
- if (setup.getInstance().hasLoggedIn()) {
- exports.getInstance().checkRouting(function(CONFIG, canCreateDiscussions) {
- if (!canCreateDiscussions) {
- get(CONFIG.API_HOST + input, obj, "PUT", {
- "Session-Key" : exports.getInstance().sessionKey,
- SendBird : spec + path
- }, text);
- }
- });
- } else {
- if (text) {
- text(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {?} id
- * @param {string} event
- * @param {!Function} cb
- * @return {undefined}
- */
- this.addFriends = function(id, event, cb) {
- /** @type {string} */
- var instrumented = exports.API_FRIENDS.replace("%s", encodeURIComponent(id));
- next(instrumented, {
- user_ids : event
- }, cb);
- };
- /**
- * @param {!Array} keywords
- * @param {!Array} k
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteFriends = function(keywords, k, fun) {
- /** @type {string} */
- var b = exports.API_FRIENDS.replace("%s", encodeURIComponent(keywords));
- if (k.length > 0) {
- b = b + "?user_ids=";
- k.forEach(function(qov) {
- b = b + (encodeURIComponent(qov) + ",");
- });
- b = b.substring(0, b.length - 1);
- }
- forEach(b, {}, fun);
- };
- /**
- * @param {!Array} val
- * @param {!Array} o
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteFriendDiscoveries = function(val, o, fun) {
- /** @type {string} */
- var b = exports.API_FRIENDS_DISCOVERIES.replace("%s", encodeURIComponent(val));
- if (o.length > 0) {
- b = b + "?friend_discovery_keys=";
- o.forEach(function(qov) {
- b = b + (encodeURIComponent(qov) + ",");
- });
- b = b.substring(0, b.length - 1);
- }
- forEach(b, {}, fun);
- };
- /**
- * @param {?} val
- * @param {!Object} from
- * @param {string} profile
- * @return {undefined}
- */
- this.uploadFriendDiscoveries = function(val, from, profile) {
- /** @type {string} */
- var lexed = exports.API_FRIENDS_DISCOVERIES.replace("%s", encodeURIComponent(val));
- var view = {
- friend_discoveries : []
- };
- from.forEach(function(views) {
- view.friend_discoveries.push({
- friend_discovery_key : views.friendDiscoveryKey,
- friend_name : "string" == typeof views.friendName || views.friendName ? views.friendName : null
- });
- });
- render(lexed, view, profile);
- };
- /**
- * @param {?} s
- * @param {string} name
- * @param {!Function} updated
- * @return {undefined}
- */
- this.getFriendChangeLogsByToken = function(s, name, updated) {
- /** @type {string} */
- var e = exports.API_FRIENDS_CHANGE_LOGS.replace("%s", encodeURIComponent(s));
- var r = {};
- if (name) {
- /** @type {string} */
- r.token = name;
- }
- callback(e, r, updated);
- };
- /**
- * @param {?} match
- * @param {string} token
- * @param {number} duration
- * @param {!Function} value
- * @return {undefined}
- */
- this.friendListQuery = function(match, token, duration, value) {
- /** @type {string} */
- var r = exports.API_FRIENDS.replace("%s", encodeURIComponent(match));
- var result = {
- limit : duration,
- token : encodeURIComponent(token)
- };
- callback(r, result, value);
- };
- /**
- * @param {?} s
- * @param {!Object} data
- * @param {!Function} items
- * @return {undefined}
- */
- this.createUserMetaData = function(s, data, items) {
- /** @type {string} */
- var instrumented = exports.API_USERS_USERID_METADATA.replace("%s", encodeURIComponent(s));
- var r = {};
- /** @type {!Object} */
- r.metadata = data;
- next(instrumented, r, items);
- };
- /**
- * @param {?} i
- * @param {!Object} match
- * @param {!Object} keys
- * @param {string} k
- * @return {undefined}
- */
- this.updateUserMetaData = function(i, match, keys, k) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_METADATA.replace("%s", encodeURIComponent(i));
- var self = {};
- /** @type {!Object} */
- self.metadata = match;
- /** @type {!Object} */
- self.upsert = keys;
- render(lexed, self, k);
- };
- /**
- * @param {?} hash
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteAllUserMetaData = function(hash, fun) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_METADATA.replace("%s", encodeURIComponent(hash));
- forEach(temporaryStyles, {}, fun);
- };
- /**
- * @param {?} s
- * @param {string} n
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteUserMetaData = function(s, n, fun) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_METADATA_KEY.replace("%s", encodeURIComponent(s)).replace("%s", encodeURIComponent(n));
- forEach(temporaryStyles, {}, fun);
- };
- /**
- * @param {?} query
- * @param {string} profile
- * @return {undefined}
- */
- this.resetMyHistory = function(query, profile) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_RESET_USER_HISTORY.replace("%s", encodeURIComponent(query));
- render(lexed, {}, profile);
- };
- /**
- * @param {?} line
- * @param {!Object} input
- * @param {!Function} request
- * @return {undefined}
- */
- this.groupChannelInvite = function(line, input, request) {
- /** @type {string} */
- var instrumented = exports.API_GROUPCHANNELS_CHANNELURL_INVITE.replace("%s", encodeURIComponent(line));
- var data = {};
- /** @type {!Array} */
- var temp = [];
- try {
- if (Array.isArray(input)) {
- /** @type {!Object} */
- temp = input;
- } else {
- temp.push(input);
- }
- } catch (e) {
- request(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER));
- }
- /** @type {!Array} */
- data.user_ids = temp;
- next(instrumented, data, request);
- };
- /**
- * @param {?} token
- * @param {string} user
- * @param {string} res
- * @return {undefined}
- */
- this.acceptInvitation = function(token, user, res) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION.replace("%s", encodeURIComponent(token));
- var data = {};
- /** @type {string} */
- data.user_id = user;
- render(lexed, data, res);
- };
- /**
- * @param {?} id
- * @param {string} room
- * @param {string} reason
- * @return {undefined}
- */
- this.declineInvitation = function(id, room, reason) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION.replace("%s", encodeURIComponent(id));
- var item = {};
- /** @type {string} */
- item.user_id = room;
- render(lexed, item, reason);
- };
- /**
- * @param {?} e
- * @param {string} id
- * @param {?} n
- * @param {string} k
- * @return {undefined}
- */
- this.groupChannelHide = function(e, id, n, k) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_HIDE.replace("%s", encodeURIComponent(e));
- var item = {};
- /** @type {string} */
- item.user_id = id;
- item.hide_previous_messages = n;
- render(lexed, item, k);
- };
- /**
- * @param {?} url
- * @param {string} username
- * @param {string} profile
- * @return {undefined}
- */
- this.publicGroupChannelJoin = function(url, username, profile) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_JOIN.replace("%s", encodeURIComponent(url));
- var item = {};
- /** @type {string} */
- item.user_id = username;
- render(lexed, item, profile);
- };
- /**
- * @param {?} url
- * @param {string} username
- * @param {string} profile
- * @return {undefined}
- */
- this.groupChannelLeave = function(url, username, profile) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_LEAVE.replace("%s", encodeURIComponent(url));
- var item = {};
- /** @type {string} */
- item.user_id = username;
- render(lexed, item, profile);
- };
- /**
- * @param {?} e
- * @param {string} id
- * @param {undefined} profile
- * @return {undefined}
- */
- this.groupChannelMarkAsRead = function(e, id, profile) {
- /** @type {string} */
- var lexed = exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASREAD.replace("%s", encodeURIComponent(e));
- var item = {};
- /** @type {string} */
- item.user_id = id;
- render(lexed, item, profile);
- };
- /**
- * @param {?} val
- * @param {!Object} from
- * @param {string} profile
- * @return {undefined}
- */
- this.groupChannelMarkAsReadAll = function(val, from, profile) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_MARKASREADALL.replace("%s", encodeURIComponent(val));
- var data = {};
- if (from) {
- /** @type {!Object} */
- data.channel_urls = from;
- }
- render(lexed, data, profile);
- };
- /**
- * @param {string} show
- * @param {?} text
- * @param {number} val
- * @param {number} type
- * @param {number} err
- * @param {boolean} args
- * @param {?} arr
- * @param {string} value
- * @param {string} source
- * @param {!Array} obj
- * @param {!Function} h
- * @return {undefined}
- */
- this.messageList = function(show, text, val, type, err, args, arr, value, source, obj, h) {
- var mode;
- /** @type {string} */
- mode = show ? String(exports.API_OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s", text)) : String(exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s", text));
- var self = {};
- /** @type {string} */
- self.is_sdk = String(true);
- /** @type {string} */
- self.message_ts = String(val);
- /** @type {string} */
- self.prev_limit = String(type);
- /** @type {string} */
- self.next_limit = String(err);
- /** @type {string} */
- self.include = String(args);
- /** @type {string} */
- self.reverse = String(arr);
- if (value) {
- /** @type {string} */
- self.message_type = String(value);
- }
- if (source) {
- /** @type {string} */
- self.custom_type = String(source);
- }
- if (obj.length > 0) {
- self.sender_ids = extend(obj);
- }
- callback(mode, self, h);
- };
- /**
- * @param {string} show
- * @param {?} index
- * @param {number} message
- * @param {number} format
- * @param {number} width
- * @param {boolean} e
- * @param {?} filename
- * @param {string} key
- * @param {?} text
- * @param {!Object} obj
- * @param {!Function} h
- * @return {undefined}
- */
- this.messageListByID = function(show, index, message, format, width, e, filename, key, text, obj, h) {
- var mode;
- /** @type {string} */
- mode = show ? String(exports.API_OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s", index)) : String(exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s", index));
- var data = {};
- /** @type {string} */
- data.is_sdk = String(true);
- /** @type {number} */
- data.message_id = message;
- /** @type {string} */
- data.prev_limit = String(format);
- /** @type {string} */
- data.next_limit = String(width);
- /** @type {string} */
- data.include = String(e);
- /** @type {string} */
- data.reverse = String(filename);
- if (key) {
- /** @type {string} */
- data.message_type = String(key);
- }
- if (text) {
- /** @type {string} */
- data.custom_type = String(text);
- }
- if (obj.length > 0) {
- data.sender_ids = extend(obj);
- }
- callback(mode, data, h);
- };
- /**
- * @param {?} pkg
- * @param {string} data
- * @param {?} callback
- * @return {undefined}
- */
- this.login = function(pkg, data, callback) {
- /** @type {string} */
- var instrumented = exports.API_USERS_USERID_LOGIN.replace("%s", encodeURIComponent(pkg));
- var options = {};
- options.app_id = path;
- if (data) {
- /** @type {string} */
- options.access_token = data;
- }
- next(instrumented, options, function(data, webhookMsg) {
- if (webhookMsg) {
- callback(null, webhookMsg);
- } else {
- exports.getInstance().sessionKey = data.key;
- exports.getInstance().ekey = data.ekey;
- callback(data, webhookMsg);
- }
- });
- };
- /**
- * @param {?} val
- * @param {string} data
- * @param {!Object} info
- * @param {!Array} id
- * @return {undefined}
- */
- this.updateUserInfo = function(val, data, info, id) {
- var item = {};
- if (data) {
- /** @type {string} */
- item.nickname = data;
- }
- if (info) {
- /** @type {!Object} */
- item.profile_url = info;
- }
- /** @type {string} */
- var lexed = String(exports.API_USERS_USERID).replace("%s", encodeURIComponent(val));
- render(lexed, item, id);
- };
- /**
- * @param {?} url
- * @param {string} s
- * @param {!Object} v
- * @param {!Array} k
- * @return {undefined}
- */
- this.updateCurrentUserInfoWithFile = function(url, s, v, k) {
- if ("string" == typeof v) {
- this.updateUserInfo(url, s, v, k);
- } else {
- var $ = Model ? new Model : new FormData;
- $.append("nickname", s);
- $.append("profile_file", v, v.name);
- /** @type {string} */
- var lexed = String(exports.API_USERS_USERID).replace("%s", encodeURIComponent(url));
- render(lexed, $, k);
- }
- };
- /**
- * @param {string} id
- * @param {boolean} n
- * @param {boolean} e
- * @param {!Function} percent
- * @return {undefined}
- */
- this.getGroupChannel = function(id, n, e, percent) {
- /** @type {string} */
- var r = exports.API_GROUPCHANNELS_CHANNELURL.replace("%s", encodeURIComponent(id));
- var output = {
- member : String(n),
- read_receipt : String(e)
- };
- callback(r, output, percent);
- };
- /**
- * @param {string} resourceName
- * @param {string} color
- * @return {undefined}
- */
- this.getOpenChannel = function(resourceName, color) {
- /** @type {string} */
- var t = exports.API_OPENCHANNELS_CHANNELURL.replace("%s", encodeURIComponent(resourceName));
- callback(t, color);
- };
- /**
- * @param {!Array} b
- * @param {!Object} f
- * @param {string} name
- * @param {string} file
- * @param {!Object} a
- * @param {!Object} v
- * @param {!Object} s
- * @param {!Object} o
- * @param {!Object} c
- * @param {!Object} tree
- * @param {!Function} items
- * @return {undefined}
- */
- this.createGroupChannel = function(b, f, name, file, a, v, s, o, c, tree, items) {
- /** @type {string} */
- var level = exports.API_GROUPCHANNELS;
- /** @type {!Array} */
- var p = [];
- if ("string" == typeof b) {
- p.push(b);
- } else {
- b.forEach(function(e) {
- p.push(e);
- });
- }
- var data;
- /** @type {!Array<?>} */
- var inputblob = p.filter(function(value, index) {
- return p.indexOf(value) === index;
- });
- var i = o.isPublic;
- var m = o.channelUrl;
- if (file && "string" != typeof file) {
- data = Model ? new Model : new FormData;
- if (file) {
- data.append("cover_file", file, file.name);
- }
- data.append("user_ids", inputblob);
- if (null !== m) {
- data.append("channel_url", m);
- }
- if (null !== f) {
- data.append("is_distinct", f);
- }
- if (null !== s) {
- data.append("is_super", s);
- }
- if (null !== i) {
- data.append("is_public", i);
- }
- if (null !== tree) {
- data.append("is_ephemeral", tree);
- }
- if (null !== name && "string" == typeof name) {
- data.append("name", name);
- }
- if (a) {
- data.append("data", a);
- }
- if (v) {
- data.append("custom_type", v);
- }
- if (Array.isArray(c) && c.length > 0) {
- data.append("operator_ids", c);
- }
- } else {
- data = {};
- if (null !== file && "string" == typeof file) {
- /** @type {string} */
- data.cover_url = file;
- }
- /** @type {!Array<?>} */
- data.user_ids = inputblob;
- if (null !== m) {
- data.channel_url = m;
- }
- if (null !== f) {
- /** @type {!Object} */
- data.is_distinct = f;
- }
- if (null !== s) {
- /** @type {!Object} */
- data.is_super = s;
- }
- if (null !== i) {
- data.is_public = i;
- }
- if (null !== tree) {
- /** @type {!Object} */
- data.is_ephemeral = tree;
- }
- if (null !== name && "string" == typeof name) {
- /** @type {string} */
- data.name = name;
- }
- if (a) {
- /** @type {!Object} */
- data.data = a;
- }
- if (v) {
- /** @type {!Object} */
- data.custom_type = v;
- }
- if (Array.isArray(c) && c.length > 0) {
- /** @type {!Object} */
- data.operator_ids = c;
- }
- }
- next(level, data, items);
- };
- /**
- * @param {string} c
- * @param {?} data
- * @param {?} t
- * @param {!Object} value
- * @param {?} options
- * @param {!Function} code
- * @return {undefined}
- */
- this.createOpenChannel = function(c, data, t, value, options, code) {
- var self;
- /** @type {string} */
- var instrumented = String(exports.API_OPENCHANNELS);
- if (data && "string" != typeof data) {
- self = Model ? new Model : new FormData;
- if (data) {
- self.append("cover_file", data, data.name);
- }
- if (null !== c && "string" == typeof c) {
- self.append("name", c);
- }
- if (t) {
- self.append("data", t);
- }
- if (value) {
- if (Array.isArray(value)) {
- self.append("operators", value);
- } else {
- self.append("operators", [value]);
- }
- }
- if (options) {
- self.append("custom_type", options);
- }
- } else {
- self = {};
- if (null !== data && "string" == typeof data) {
- /** @type {string} */
- self.cover_url = data;
- }
- if (null !== c && "string" == typeof c) {
- /** @type {string} */
- self.name = c;
- }
- if (t) {
- self.data = t;
- }
- if (value) {
- if (Array.isArray(value)) {
- /** @type {!Object} */
- self.operators = value;
- } else {
- /** @type {!Array} */
- self.operators = [value];
- }
- }
- if (options) {
- self.custom_type = options;
- }
- }
- next(instrumented, self, code);
- };
- /**
- * @param {?} shareUrl
- * @param {!Object} title
- * @param {string} config
- * @param {string} value
- * @param {string} id
- * @param {string} child
- * @param {string} i
- * @param {string} k
- * @return {undefined}
- */
- this.updateGroupChannel = function(shareUrl, title, config, value, id, child, i, k) {
- var item;
- /** @type {string} */
- var parsedValue = String(exports.API_GROUPCHANNELS_CHANNELURL.replace("%s", encodeURIComponent(shareUrl)));
- if (value && "string" != typeof value) {
- item = Model ? new Model : new FormData;
- if (null !== title) {
- item.append("is_distinct", title);
- }
- if (null !== i) {
- item.append("is_public", i);
- }
- if (value) {
- item.append("cover_file", value, value.name);
- }
- if (null !== config && "string" == typeof config) {
- item.append("name", config);
- }
- if (null !== id && "string" == typeof id) {
- item.append("data", id);
- }
- if (null !== child && "string" == typeof child) {
- item.append("custom_type", child);
- }
- } else {
- item = {};
- if (null !== title) {
- /** @type {!Object} */
- item.is_distinct = title;
- }
- if (null !== i) {
- /** @type {string} */
- item.is_public = i;
- }
- if (null !== value && "string" == typeof value) {
- /** @type {string} */
- item.cover_url = value;
- }
- if (null !== config && "string" == typeof config) {
- /** @type {string} */
- item.name = config;
- }
- if (null !== id && "string" == typeof id) {
- /** @type {string} */
- item.data = id;
- }
- if (null !== child && "string" == typeof child) {
- /** @type {string} */
- item.custom_type = child;
- }
- }
- render(parsedValue, item, k);
- };
- /**
- * @param {?} file
- * @param {string} name
- * @param {?} data
- * @param {?} obj
- * @param {!Object} id
- * @param {?} a
- * @param {string} cur
- * @return {undefined}
- */
- this.updateOpenChannel = function(file, name, data, obj, id, a, cur) {
- var $scope;
- /** @type {string} */
- var parsedValue = String(exports.API_OPENCHANNELS_CHANNELURL.replace("%s", encodeURIComponent(file)));
- if (data && "string" != typeof data) {
- $scope = Model ? new Model : new FormData;
- if (data) {
- $scope.append("cover_file", data, data.name);
- }
- if (null !== name && "string" == typeof name) {
- $scope.append("name", name);
- }
- if (null !== obj && "string" == typeof obj) {
- $scope.append("data", obj);
- }
- if (null !== id) {
- if (Array.isArray(id)) {
- $scope.append("operators", id);
- } else {
- $scope.append("operators", [id]);
- }
- }
- if (null !== a && "string" == typeof a) {
- $scope.append("custom_type", a);
- }
- } else {
- $scope = {};
- if (null !== data && "string" == typeof data) {
- /** @type {string} */
- $scope.cover_url = data;
- }
- if (null !== name && "string" == typeof name) {
- /** @type {string} */
- $scope.name = name;
- }
- if (null !== obj && "string" == typeof obj) {
- /** @type {string} */
- $scope.data = obj;
- }
- if (null !== id) {
- if (Array.isArray(id)) {
- /** @type {!Object} */
- $scope.operators = id;
- } else {
- /** @type {!Array} */
- $scope.operators = [id];
- }
- }
- if (null !== a && "string" == typeof a) {
- /** @type {string} */
- $scope.custom_type = a;
- }
- }
- render(parsedValue, $scope, cur);
- };
- /**
- * @param {?} url
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteOpenChannel = function(url, fun) {
- /** @type {string} */
- var rawContents = String(exports.API_OPENCHANNELS_CHANNELURL.replace("%s", encodeURIComponent(url)));
- forEach(rawContents, {}, fun);
- };
- /**
- * @param {string} _
- * @param {?} val
- * @param {!Object} arr
- * @param {!Function} items
- * @return {undefined}
- */
- this.createMetaCounters = function(_, val, arr, items) {
- var r;
- /** @type {string} */
- r = _ ? exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val)) : exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val));
- var bucket = {};
- /** @type {!Object} */
- bucket.metacounter = arr;
- next(r, bucket, items);
- };
- /**
- * @param {string} lmbda
- * @param {?} n
- * @param {?} w
- * @param {!Object} p
- * @param {?} p2
- * @param {string} format
- * @return {undefined}
- */
- this.updateMetaCounters = function(lmbda, n, w, p, p2, format) {
- var lexed;
- /** @type {string} */
- lexed = lmbda ? exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(n)) : exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(n));
- var obj = {};
- switch(obj.metacounter = w, obj.upsert = p, p2) {
- case exports.UPDATE_META_COUNTER_MODE_SET:
- /** @type {string} */
- obj.mode = "set";
- break;
- case exports.UPDATE_META_COUNTER_MODE_INC:
- /** @type {string} */
- obj.mode = "increase";
- break;
- case exports.UPDATE_META_COUNTER_MODE_DEC:
- /** @type {string} */
- obj.mode = "decrease";
- }
- render(lexed, obj, format);
- };
- /**
- * @param {undefined} n
- * @param {string} s
- * @param {!Function} sf
- * @return {undefined}
- */
- this.getAllMetaCounters = function(n, s, sf) {
- this.getMetaCounters(n, s, {}, sf);
- };
- /**
- * @param {string} doc
- * @param {string} val
- * @param {!Object} src
- * @param {!Function} filename
- * @return {undefined}
- */
- this.getMetaCounters = function(doc, val, src, filename) {
- var result;
- /** @type {string} */
- result = doc ? exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val)) : exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val));
- var l = extend(src);
- callback(result, {
- keys : l
- }, filename);
- };
- /**
- * @param {string} right
- * @param {?} val
- * @param {?} size
- * @param {string} ctx
- * @return {undefined}
- */
- this.deleteMetaCounter = function(right, val, size, ctx) {
- /** @type {string} */
- var str = "";
- /** @type {string} */
- str = right ? exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s", encodeURIComponent(val)).replace("%s", size) : exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s", encodeURIComponent(val)).replace("%s", size);
- forEach(str, {}, ctx);
- };
- /**
- * @param {string} _
- * @param {?} val
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteAllMetaCounters = function(_, val, fun) {
- /** @type {string} */
- var r = "";
- /** @type {string} */
- r = _ ? exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val)) : exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s", encodeURIComponent(val));
- forEach(r, {}, fun);
- };
- /**
- * @param {string} done
- * @param {?} index
- * @param {!Object} obj
- * @param {!Function} data
- * @return {undefined}
- */
- this.createMetaData = function(done, index, obj, data) {
- /** @type {string} */
- var args = "";
- /** @type {string} */
- args = done ? exports.API_OPENCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(index)) : exports.API_GROUPCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(index));
- var n = {};
- var file = {};
- var p;
- for (p in obj) {
- var val = obj[p];
- file[p] = val;
- }
- n.metadata = file;
- next(args, n, data);
- };
- /**
- * @param {string} index
- * @param {?} base
- * @param {!Object} data
- * @param {!Object} type
- * @param {string} metadata
- * @return {undefined}
- */
- this.updateMetaData = function(index, base, data, type, metadata) {
- /** @type {string} */
- var output = "";
- /** @type {string} */
- output = index ? exports.API_OPENCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(base)) : exports.API_GROUPCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(base));
- var options = {};
- var body = {};
- var i;
- for (i in data) {
- var row = data[i];
- body[i] = row;
- }
- options.metadata = body;
- /** @type {!Object} */
- options.upsert = type;
- render(output, options, metadata);
- };
- /**
- * @param {undefined} item
- * @param {string} n
- * @param {!Function} elem
- * @return {undefined}
- */
- this.getAllMetaData = function(item, n, elem) {
- this.getMetaData(item, n, {}, elem);
- };
- /**
- * @param {string} params
- * @param {string} data
- * @param {!Object} name
- * @param {!Function} text
- * @return {undefined}
- */
- this.getMetaData = function(params, data, name, text) {
- /** @type {string} */
- var url = "";
- /** @type {string} */
- url = params ? exports.API_OPENCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(data)) : exports.API_GROUPCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(data));
- var l = extend(name);
- callback(url, {
- keys : l
- }, text);
- };
- /**
- * @param {string} right
- * @param {?} val
- * @param {?} size
- * @param {string} ctx
- * @return {undefined}
- */
- this.deleteMetaData = function(right, val, size, ctx) {
- /** @type {string} */
- var str = "";
- /** @type {string} */
- str = right ? exports.API_OPENCHANNELS_CHANNELURL_METADATA_KEY.replace("%s", encodeURIComponent(val)).replace("%s", size) : exports.API_GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace("%s", encodeURIComponent(val)).replace("%s", size);
- forEach(str, {}, ctx);
- };
- /**
- * @param {string} _
- * @param {?} val
- * @param {string} fun
- * @return {undefined}
- */
- this.deleteAllMetaData = function(_, val, fun) {
- /** @type {string} */
- var r = "";
- /** @type {string} */
- r = _ ? exports.API_OPENCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(val)) : exports.API_GROUPCHANNELS_CHANNELURL_METADATA.replace("%s", encodeURIComponent(val));
- forEach(r, {}, fun);
- };
- /**
- * @param {string} token
- * @param {?} i
- * @param {!Object} data
- * @param {string} xml
- * @param {!Object} args
- * @param {!Function} port
- * @return {undefined}
- */
- this.loadUserList = function(token, i, data, xml, args, port) {
- /** @type {string} */
- var returnValue = exports.API_USERS;
- var result = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- if (!check(data)) {
- try {
- /** @type {string} */
- var query = "";
- var a;
- for (a in data) {
- var i = data[a];
- /** @type {string} */
- query = query + (encodeURIComponent(i) + ",");
- }
- if (query.length > 1) {
- /** @type {string} */
- query = query.substring(0, query.length - 1);
- }
- /** @type {string} */
- result.user_ids = query;
- } catch (e) {
- }
- }
- if (xml && !check(args)) {
- /** @type {string} */
- var b = "";
- args.forEach(function(qov) {
- b = b + (encodeURIComponent(qov) + ",");
- });
- if (b.length > 0) {
- b = b.substring(0, b.length - 1);
- }
- /** @type {string} */
- result.metadatakey = encodeURIComponent(xml);
- result.metadatavalues_in = b;
- }
- callback(returnValue, result, port);
- };
- /**
- * @param {?} match
- * @param {string} token
- * @param {?} i
- * @param {!Function} err
- * @return {undefined}
- */
- this.loadBlockedUserList = function(match, token, i, err) {
- /** @type {string} */
- var r = exports.API_USERS_USERID_BLOCK.replace("%s", encodeURIComponent(match));
- var result = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- callback(r, result, err);
- };
- /**
- * @param {string} token
- * @param {?} i
- * @param {number} s
- * @param {?} xml
- * @param {number} url
- * @param {!Function} c
- * @return {undefined}
- */
- this.loadOpenChannelList = function(token, i, s, xml, url, c) {
- /** @type {string} */
- var returnValue = exports.API_OPENCHANNELS;
- var result = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- if (null !== s) {
- /** @type {string} */
- result.name_contains = encodeURIComponent(s);
- }
- if (xml) {
- /** @type {string} */
- result.url_contains = encodeURIComponent(xml);
- }
- if (null !== url) {
- /** @type {string} */
- result.custom_type = encodeURIComponent(url);
- }
- callback(returnValue, result, c);
- };
- /**
- * @param {!Object} json
- * @param {string} options
- * @param {!Object} params
- * @param {string} data
- * @param {!Function} callback
- * @param {?} key
- * @param {?} cb
- * @param {?} parent
- * @return {undefined}
- */
- this.uploadFile = function(json, options, params, data, callback, key, cb, parent) {
- request(exports.API_STORAGE_FILE, 0, json, options, params, data, callback, key, cb, parent);
- };
- /**
- * @param {!Object} file
- * @param {!Function} callback
- * @return {undefined}
- */
- this.uploadProfileImage = function(file, callback) {
- request(exports.API_STORAGE_PROFILE, 0, file, "", [], "", callback);
- };
- /**
- * @param {?} e
- * @param {string} value
- * @param {string} i
- * @param {number} time
- * @param {!Function} r
- * @return {undefined}
- */
- this.loadOperatorList = function(e, value, i, time, r) {
- /** @type {string} */
- var id = value ? exports.API_OPENCHANNELS_OPERATORS.replace("%url", encodeURIComponent(e)) : exports.API_GROUPCHANNELS_OPERATORS.replace("%url", encodeURIComponent(e));
- var result = {
- token : encodeURIComponent(i),
- limit : time
- };
- callback(id, result, r);
- };
- /**
- * @param {?} match
- * @param {string} token
- * @param {number} duration
- * @param {string} format
- * @param {string} a
- * @param {?} unused
- * @param {?} name
- * @param {string} n
- * @param {!Function} updated
- * @return {undefined}
- */
- this.loadGroupChannelMemberList = function(match, token, duration, format, a, unused, name, n, updated) {
- /** @type {string} */
- var c = exports.API_GROUPCHANNELS_MEMBERS.replace("%url", encodeURIComponent(match));
- var result = {
- token : encodeURIComponent(token),
- limit : duration,
- muted_member_filter : format.toLowerCase(),
- operator_filter : a.toLowerCase(),
- member_state_filter : unused,
- order : n.toLowerCase()
- };
- if (name) {
- /** @type {string} */
- result.nickname_startswith = encodeURIComponent(name);
- }
- callback(c, result, updated);
- };
- /**
- * @param {string} token
- * @param {?} i
- * @param {?} state_name
- * @param {string} value
- * @param {?} process
- * @param {!Array} id
- * @param {!Array} snippets
- * @param {?} scope
- * @param {?} cond
- * @param {?} t
- * @param {!Function} c
- * @return {undefined}
- */
- this.loadPublicGroupChannelList = function(token, i, state_name, value, process, id, snippets, scope, cond, t, c) {
- /** @type {string} */
- var returnValue = exports.API_GROUPCHANNELS;
- var options = {
- public_mode : link.publicChannelFilter.PUBLIC,
- token : encodeURIComponent(token),
- limit : String(i),
- show_member : true,
- show_read_receipt : true,
- show_empty : String(state_name),
- order : value
- };
- if (process) {
- try {
- /** @type {string} */
- options.name_contains = encodeURIComponent(process);
- } catch (e) {
- }
- }
- if (id.length > 0) {
- try {
- options.channel_urls = id.map(function(qov) {
- return encodeURIComponent(qov);
- }).join(",");
- } catch (e) {
- }
- }
- if (snippets.length > 0) {
- /** @type {string} */
- var result = "";
- snippets.forEach(function(qov) {
- result = result + (encodeURIComponent(qov) + ",");
- });
- result = result.substring(0, result.length - 1);
- options.custom_types = result;
- }
- if (scope) {
- options.custom_type_startswith = scope;
- }
- options.super_mode = cond;
- options.public_membership_mode = t;
- callback(returnValue, options, c);
- };
- /**
- * @param {?} match
- * @param {string} i
- * @param {?} query
- * @param {boolean} partialName
- * @param {string} state
- * @param {!Object} data
- * @param {string} tableName
- * @param {string} image
- * @param {!Array} slice
- * @param {string} d
- * @param {!Array} h
- * @param {?} edge
- * @param {string} event
- * @param {string} details
- * @param {string} result
- * @param {!Function} fields
- * @return {undefined}
- */
- this.loadUserGroupChannelList = function(match, i, query, partialName, state, data, tableName, image, slice, d, h, edge, event, details, result, fields) {
- /** @type {string} */
- var m = exports.API_MYGROUPCHANNELS.replace("%s", encodeURIComponent(match));
- var userIds = data.userIds;
- /** @type {boolean} */
- var A = !data.includeMode;
- var stripeTokenId = data.queryType;
- var options = {
- token : encodeURIComponent(i),
- limit : String(query),
- show_member : true,
- show_read_receipt : true,
- show_empty : String(partialName),
- order : state,
- member_state_filter : event
- };
- if (h.length > 0) {
- /** @type {string} */
- var displayName = "";
- h.forEach(function(qov) {
- displayName = displayName + (encodeURIComponent(qov) + ",");
- });
- displayName = displayName.substring(0, displayName.length - 1);
- options.custom_types = displayName;
- } else {
- if (d) {
- /** @type {string} */
- options.custom_type = encodeURIComponent(d);
- }
- }
- if (tableName) {
- try {
- /** @type {string} */
- options.members_nickname_contains = encodeURIComponent(tableName);
- } catch (e) {
- }
- }
- if (image) {
- try {
- /** @type {string} */
- options.name_contains = encodeURIComponent(image);
- } catch (e) {
- }
- }
- if (userIds.length > 0) {
- try {
- if (A) {
- options.members_exactly_in = extend(userIds);
- } else {
- options.members_include_in = extend(userIds);
- options.query_type = stripeTokenId;
- }
- } catch (e) {
- }
- }
- if (slice.length > 0) {
- try {
- options.channel_urls = slice.map(function(qov) {
- return encodeURIComponent(qov);
- }).join(",");
- } catch (e) {
- }
- }
- /** @type {string} */
- options.super_mode = details;
- /** @type {string} */
- options.public_mode = result;
- if (edge) {
- options.custom_type_startswith = edge;
- }
- callback(m, options, fields);
- };
- /**
- * @param {?} substitution
- * @param {string} token
- * @param {?} i
- * @param {!Function} err
- * @return {undefined}
- */
- this.loadOpenChannelParticipantList = function(substitution, token, i, err) {
- /** @type {string} */
- var result = exports.API_OPENCHANNELS_CHANNELURL_PARTICIPANTS.replace("%s", substitution);
- var opts = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- callback(result, opts, err);
- };
- /**
- * @param {!Object} s
- * @param {string} token
- * @param {?} i
- * @param {!Function} err
- * @return {undefined}
- */
- this.loadMutedUserList = function(s, token, i, err) {
- /** @type {string} */
- var r = s.isOpenChannel() ? exports.API_OPENCHANNELS_CHANNELURL_MUTE.replace("%s", s.url) : exports.API_GROUPCHANNELS_CHANNELURL_MUTE.replace("%s", s.url);
- var result = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- callback(r, result, err);
- };
- /**
- * @param {!Object} s
- * @param {string} token
- * @param {?} i
- * @param {!Function} err
- * @return {undefined}
- */
- this.loadBannedUserList = function(s, token, i, err) {
- /** @type {string} */
- var r = s.isOpenChannel() ? exports.API_OPENCHANNELS_CHANNELURL_BAN.replace("%s", s.url) : exports.API_GROUPCHANNELS_CHANNELURL_BAN.replace("%s", s.url);
- var result = {
- token : encodeURIComponent(token),
- limit : String(i)
- };
- callback(r, result, err);
- };
- /**
- * @param {?} s
- * @param {string} q
- * @param {string} id
- * @return {undefined}
- */
- this.setPushTemplate = function(s, q, id) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_PUSH_TEMPLATE.replace("%s", encodeURIComponent(s));
- render(lexed, {
- name : q
- }, id);
- };
- /**
- * @param {?} s
- * @param {string} color
- * @return {undefined}
- */
- this.getPushTemplate = function(s, color) {
- /** @type {string} */
- var t = exports.API_USERS_USERID_PUSH_TEMPLATE.replace("%s", encodeURIComponent(s));
- callback(t, color);
- };
- /**
- * @param {?} word
- * @param {!Object} s
- * @param {number} t
- * @param {number} canvas
- * @param {number} r
- * @param {number} g
- * @param {string} name
- * @param {string} check
- * @return {undefined}
- */
- this.setDoNotDisturb = function(word, s, t, canvas, r, g, name, check) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_PUSHPREFERENCE.replace("%s", encodeURIComponent(word));
- render(lexed, {
- do_not_disturb : s,
- start_hour : t,
- start_min : canvas,
- end_hour : r,
- end_min : g,
- timezone : name
- }, check);
- };
- /**
- * @param {?} s
- * @param {string} color
- * @return {undefined}
- */
- this.getDoNotDisturb = function(s, color) {
- /** @type {string} */
- var t = exports.API_USERS_USERID_PUSHPREFERENCE.replace("%s", encodeURIComponent(s));
- callback(t, color);
- };
- /**
- * @param {?} i
- * @param {?} line
- * @param {string} v
- * @param {string} total
- * @return {undefined}
- */
- this.setPushPreference = function(i, line, v, total) {
- /** @type {string} */
- var lexed = exports.API_USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s", encodeURIComponent(i)).replace("%s", encodeURIComponent(line));
- var view = {};
- /** @type {string} */
- view.enable = v;
- render(lexed, view, total);
- };
- /**
- * @param {?} url
- * @param {?} c
- * @param {string} selected
- * @return {undefined}
- */
- this.getPushPreference = function(url, c, selected) {
- /** @type {string} */
- var s = exports.API_USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s", encodeURIComponent(url)).replace("%s", encodeURIComponent(c));
- callback(s, selected);
- };
- /**
- * @param {?} hash
- * @param {?} username
- * @param {?} time
- * @param {string} check
- * @return {undefined}
- */
- this.setCountPreference = function(hash, username, time, check) {
- /** @type {string} */
- var lexed = exports.API_USERS_COUNT_PREFERENCE.replace("%s", encodeURIComponent(hash)).replace("%s", encodeURIComponent(username));
- var item = {};
- item.count_preference = time;
- render(lexed, item, check);
- };
- /**
- * @param {?} token
- * @param {string} mappings
- * @param {!Function} code
- * @return {undefined}
- */
- this.registerGCMPushToken = function(token, mappings, code) {
- /** @type {string} */
- var instrumented = exports.API_USERS_USERID_PUSH_GCM.replace("%s", encodeURIComponent(token));
- next(instrumented, {
- gcm_reg_token : mappings
- }, code);
- };
- /**
- * @param {?} t
- * @param {?} c
- * @param {string} f
- * @return {undefined}
- */
- this.unregisterGCMPushToken = function(t, c, f) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_PUSH_GCM_TOKEN.replace("%s", encodeURIComponent(t)).replace("%s", encodeURIComponent(c));
- forEach(temporaryStyles, f);
- };
- /**
- * @param {?} c
- * @param {string} f
- * @return {undefined}
- */
- this.unregisterGCMPushTokenAll = function(c, f) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_PUSH_GCM.replace("%s", encodeURIComponent(c));
- forEach(temporaryStyles, f);
- };
- /**
- * @param {?} token
- * @param {!Function} mappings
- * @param {!Function} code
- * @return {undefined}
- */
- this.registerAPNSPushToken = function(token, mappings, code) {
- /** @type {string} */
- var instrumented = exports.API_USERS_USERID_PUSH_APNS.replace("%s", encodeURIComponent(token));
- next(instrumented, {
- apns_device_token : mappings
- }, code);
- };
- /**
- * @param {?} t
- * @param {?} c
- * @param {string} f
- * @return {undefined}
- */
- this.unregisterAPNSPushToken = function(t, c, f) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_PUSH_APNS_TOKEN.replace("%s", encodeURIComponent(t)).replace("%s", encodeURIComponent(c));
- forEach(temporaryStyles, f);
- };
- /**
- * @param {?} c
- * @param {string} f
- * @return {undefined}
- */
- this.unregisterAPNSPushTokenAll = function(c, f) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_PUSH_APNS.replace("%s", encodeURIComponent(c));
- forEach(temporaryStyles, f);
- };
- /**
- * @param {?} c
- * @param {string} f
- * @return {undefined}
- */
- this.unregisterPushTokenAll = function(c, f) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_PUSH.replace("%s", encodeURIComponent(c));
- forEach(temporaryStyles, f);
- };
- /**
- * @param {?} username
- * @param {?} id
- * @param {!Function} type
- * @return {undefined}
- */
- this.blockUser = function(username, id, type) {
- /** @type {string} */
- var instrumented = exports.API_USERS_USERID_BLOCK.replace("%s", encodeURIComponent(username));
- next(instrumented, {
- target_id : id
- }, type);
- };
- /**
- * @param {?} param
- * @param {?} arg
- * @param {string} cb
- * @return {undefined}
- */
- this.unblockUser = function(param, arg, cb) {
- /** @type {string} */
- var temporaryStyles = exports.API_USERS_USERID_BLOCK_TARGETID.replace("%s", encodeURIComponent(param)).replace("%s", encodeURIComponent(arg));
- forEach(temporaryStyles, {}, cb);
- };
- /**
- * @param {?} username
- * @param {string} uid
- * @param {string} result
- * @param {number} value
- * @param {string} toggle
- * @param {!Function} callback
- * @return {undefined}
- */
- this.banUser = function(username, uid, result, value, toggle, callback) {
- /** @type {string} */
- var output = toggle ? exports.API_GROUPCHANNELS_CHANNELURL_BAN.replace("%s", encodeURIComponent(username)) : exports.API_OPENCHANNELS_CHANNELURL_BAN.replace("%s", encodeURIComponent(username));
- var options = {
- user_id : uid
- };
- if (result) {
- /** @type {string} */
- options.description = result;
- }
- /** @type {string} */
- options.seconds = String(value);
- next(output, options, callback);
- };
- /**
- * @param {?} file
- * @param {boolean} val
- * @param {string} callback
- * @param {string} obj
- * @return {undefined}
- */
- this.unbanUser = function(file, val, callback, obj) {
- /** @type {string} */
- var result = callback ? exports.API_GROUPCHANNELS_CHANNELURL_BAN_USERID.replace("%s", encodeURIComponent(file)).replace("%s", encodeURIComponent(val)) : exports.API_OPENCHANNELS_CHANNELURL_BAN_USERID.replace("%s", encodeURIComponent(file)).replace("%s", encodeURIComponent(val));
- forEach(result, {}, obj);
- };
- /**
- * @param {?} data
- * @param {string} id
- * @param {string} cb
- * @param {!Function} user
- * @return {undefined}
- */
- this.muteUser = function(data, id, cb, user) {
- /** @type {string} */
- var results = cb ? exports.API_GROUPCHANNELS_CHANNELURL_MUTE.replace("%s", encodeURIComponent(data)) : exports.API_OPENCHANNELS_CHANNELURL_MUTE.replace("%s", encodeURIComponent(data));
- next(results, {
- user_id : id
- }, user);
- };
- /**
- * @param {?} n
- * @param {boolean} id
- * @param {string} cb
- * @param {string} s
- * @return {undefined}
- */
- this.unmuteUser = function(n, id, cb, s) {
- /** @type {string} */
- var results = cb ? exports.API_GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace("%s", encodeURIComponent(n)).replace("%s", encodeURIComponent(id)) : exports.API_OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s", encodeURIComponent(n)).replace("%s", encodeURIComponent(id));
- forEach(results, {}, s);
- };
- /**
- * @param {string} index
- * @param {?} type
- * @param {?} data
- * @param {string} obj
- * @return {undefined}
- */
- this.deleteMessage = function(index, type, data, obj) {
- /** @type {string} */
- var source = "";
- /** @type {string} */
- source = index ? exports.API_OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s", encodeURIComponent(type)).replace("%s", encodeURIComponent(data)) : exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s", encodeURIComponent(type)).replace("%s", encodeURIComponent(data));
- forEach(source, {}, obj);
- };
- /**
- * @param {!Array} value
- * @param {string} options
- * @param {string} store
- * @param {string} k
- * @return {undefined}
- */
- this.freeze = function(value, options, store, k) {
- /** @type {string} */
- var data = options ? exports.API_GROUPCHANNELS_CHANNELURL_FREEZE.replace("%s", encodeURIComponent(value)) : exports.API_OPENCHANNELS_CHANNELURL_FREEZE.replace("%s", encodeURIComponent(value));
- render(data, {
- freeze : store
- }, k);
- };
- };
- /** @type {null} */
- var ne = null;
- /**
- * @return {?}
- */
- exports.getInstance = function() {
- return null === ne ? null : ne;
- };
- /** @type {string} */
- exports.API_VERSION = "v3";
- /** @type {string} */
- exports.API_ROUTING_URL = "https://api-p.sendbird.com/routing/%s";
- /** @type {string} */
- exports.API_USERS = "/%v/users".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_LOGIN = "/%v/users/%s/login".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID = "/%v/users/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_UNREAD_ITEM_COUNT = "/%v/users/%s/unread_item_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_METADATA = "/%v/users/%s/metadata".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_METADATA_KEY = "/%v/users/%s/metadata/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_UNREAD_MESSAGE_COUNT = "/%v/users/%s/unread_message_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_UNREAD_CHANNEL_COUNT = "/%v/users/%s/unread_channel_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_MARKASREADALL = "/%v/users/%s/mark_as_read_all".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH_GCM_TOKEN = "/%v/users/%s/push/gcm/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH_GCM = "/%v/users/%s/push/gcm".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSHPREFERENCE_CHANNELURL = "/%v/users/%s/push_preference/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSHPREFERENCE = "/%v/users/%s/push_preference/".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH_TEMPLATE = "/%v/users/%s/push/template".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_BLOCK = "/%v/users/%s/block".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_BLOCK_TARGETID = "/%v/users/%s/block/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH_APNS_TOKEN = "/%v/users/%s/push/apns/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH_APNS = "/%v/users/%s/push/apns".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_PUSH = "/%v/users/%s/push".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE = "/%v/users/%s/channel_invitation_preference".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_USERID_GROUP_CHANNEL_COUNT = "/%v/users/%s/group_channel_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_USERS_COUNT_PREFERENCE = "/%v/users/%s/count_preference/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS = "/%v/open_channels".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL = "/%v/open_channels/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_MESSAGES = "/%v/open_channels/%s/messages".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID = "/%v/open_channels/%s/messages/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_PARTICIPANTS = "/%v/open_channels/%s/participants".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_METADATA = "/%v/open_channels/%s/metadata".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_METADATA_KEY = "/%v/open_channels/%s/metadata/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER = "/%v/open_channels/%s/metacounter".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_METACOUNTER_KEY = "/%v/open_channels/%s/metacounter/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_BAN = "/%v/open_channels/%s/ban".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_BAN_USERID = "/%v/open_channels/%s/ban/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_MUTE = "/%v/open_channels/%s/mute".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_MUTE_USERID = "/%v/open_channels/%s/mute/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_FREEZE = "/%v/open_channels/%s/freeze".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS = "/%v/group_channels".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_MYGROUPCHANNELS = "/%v/users/%s/my_group_channels".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL = "/%v/group_channels/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_INVITE = "/%v/group_channels/%s/invite".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION = "/%v/group_channels/%s/accept".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION = "/%v/group_channels/%s/decline".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_HIDE = "/%v/group_channels/%s/hide".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_LEAVE = "/%v/group_channels/%s/leave".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_JOIN = "/%v/group_channels/%s/join".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES = "/%v/group_channels/%s/messages".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASREAD = "/%v/group_channels/%s/messages/mark_as_read".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_TOTALCOUNT = "/%v/group_channels/%s/messages/total_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_UNREADCOUNT = "/%v/group_channels/%s/messages/unread_count".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID = "/%v/group_channels/%s/messages/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MEMBERS = "/%v/group_channels/%s/members".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_METADATA = "/%v/group_channels/%s/metadata".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_METADATA_KEY = "/%v/group_channels/%s/metadata/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER = "/%v/group_channels/%s/metacounter".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY = "/%v/group_channels/%s/metacounter/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_RESET_USER_HISTORY = "/%v/group_channels/%s/reset_user_history".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_MEMBERS = "/%v/group_channels/%url/members".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_BAN = "/%v/group_channels/%s/ban".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_BAN_USERID = "/%v/group_channels/%s/ban/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MUTE = "/%v/group_channels/%s/mute".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MUTE_USERID = "/%v/group_channels/%s/mute/%s".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_FREEZE = "/%v/group_channels/%s/freeze".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_STORAGE_FILE = "/%v/storage/file".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_STORAGE_PROFILE = "/%v/storage/profile_image".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS = "/%v/open_channels/%s/messages/changelogs".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS = "/%v/group_channels/%s/messages/changelogs".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_FRIENDS = "/%v/users/%s/friends".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_FRIENDS_CHANGE_LOGS = "/%v/users/%s/friends/changelogs".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_FRIENDS_DISCOVERIES = "/%v/users/%s/friend_discoveries".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_GROUPCHANNELS_OPERATORS = "/%v/group_channels/%url/operators".replace("%v", exports.API_VERSION);
- /** @type {string} */
- exports.API_OPENCHANNELS_OPERATORS = "/%v/open_channels/%url/operators".replace("%v", exports.API_VERSION);
- /** @type {number} */
- exports.UPDATE_META_COUNTER_MODE_SET = 0;
- /** @type {number} */
- exports.UPDATE_META_COUNTER_MODE_INC = 1;
- /** @type {number} */
- exports.UPDATE_META_COUNTER_MODE_DEC = 2;
- /**
- * @return {undefined}
- */
- var transform = function() {
- /** @type {string} */
- var t = "";
- /** @type {boolean} */
- this.isLoading = false;
- /** @type {boolean} */
- this.hasMore = true;
- /** @type {number} */
- this.limit = 20;
- var $scope = this;
- /**
- * @param {string} stat
- * @return {?}
- */
- this.next = function(stat) {
- if (cb($scope.limit)) {
- if ($scope.hasMore) {
- if ($scope.isLoading) {
- return void callback(null, new Date("Query in progress.", concat.QUERY_IN_PROGRESS), stat);
- }
- /** @type {boolean} */
- $scope.isLoading = true;
- exports.getInstance().friendListQuery(setup.getInstance().getCurrentUserId(), t, $scope.limit, function(data, exisObj) {
- if (exisObj) {
- return $scope.isLoading = false, void callback(null, exisObj, stat);
- }
- var users = data.users;
- var identifierPositions = users.map(function(options) {
- return new client(options);
- });
- $scope.hasMore = data.has_more;
- /** @type {boolean} */
- $scope.isLoading = false;
- t = data.next;
- callback(identifierPositions, null, stat);
- });
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), stat);
- }
- };
- };
- /**
- * @param {!Object} info
- * @param {string} obj
- * @param {string} key
- * @param {string} type
- * @return {undefined}
- */
- var debug = function(info, obj, key, type) {
- if (c) {
- this[key] = info[obj];
- } else {
- Object.defineProperty(info, key, {
- get : function() {
- return "_coverUrl" === obj || "_coverImage" === obj ? info._channelCover : info[obj];
- },
- set : function(value) {
- if ("file" === type) {
- if ("string" == typeof value || "object" != typeof value) {
- return;
- }
- } else {
- if (type && typeof value !== type) {
- return;
- }
- }
- /** @type {string} */
- info[obj] = value;
- if (!("_coverUrl" !== obj && "_coverImage" !== obj)) {
- /** @type {string} */
- info._channelCover = value;
- }
- }
- });
- }
- };
- /**
- * @return {undefined}
- */
- var render = function() {
- /** @type {null} */
- this._isDistinct = null;
- debug(this, "_isDistinct", "isDistinct", "boolean");
- /** @type {null} */
- this._isSuper = null;
- debug(this, "_isSuper", "isSuper", "boolean");
- /** @type {null} */
- this._isPublic = null;
- debug(this, "_isPublic", "isPublic", "boolean");
- /** @type {null} */
- this._channelUrl = null;
- debug(this, "_channelUrl", "channelUrl", "string");
- /** @type {null} */
- this._name = null;
- debug(this, "_name", "name", "string");
- /** @type {null} */
- this._data = null;
- debug(this, "_data", "data", "string");
- /** @type {null} */
- this._customType = null;
- debug(this, "_customType", "customType", "string");
- /** @type {null} */
- this._channelCover = null;
- debug(this, "_channelCover", "channelCover", null);
- /** @type {null} */
- this._coverUrl = null;
- debug(this, "_coverUrl", "coverUrl", "string");
- /** @type {null} */
- this._coverImage = null;
- debug(this, "_coverImage", "coverImage", "file");
- /** @type {!Array} */
- this._operatorIds = [];
- /** @type {null} */
- this._operators = null;
- if (c) {
- /** @type {null} */
- this.operators = this._operators;
- } else {
- Object.defineProperty(this, "operators", {
- get : function() {
- return this._operators;
- },
- set : function(items) {
- if (Array.isArray(items)) {
- /** @type {!Array} */
- var users = [];
- /** @type {number} */
- var i = 0;
- for (; i < items.length; i++) {
- if (items[i].hasOwnProperty("userId")) {
- users.push(items[i].userId);
- } else {
- /** @type {!Array} */
- users = [];
- }
- }
- if (users.length === items.length) {
- /** @type {!Array} */
- this._operatorIds = users;
- }
- }
- }
- });
- }
- /** @type {null} */
- this._operatorUserIds = null;
- if (c) {
- /** @type {null} */
- this.operatorUserIds = this._operatorUserIds;
- } else {
- Object.defineProperty(this, "operatorUserIds", {
- get : function() {
- return this._operatorUserIds;
- },
- set : function(b) {
- if (Array.isArray(b)) {
- /** @type {!Array} */
- var a = [];
- /** @type {number} */
- var i = 0;
- for (; i < b.length; i++) {
- if ("string" == typeof b[i]) {
- a.push(b[i]);
- } else {
- /** @type {!Array} */
- a = [];
- }
- }
- if (a.length === b.length) {
- /** @type {!Array} */
- this._operatorIds = a;
- }
- }
- }
- });
- }
- /** @type {null} */
- this._isEphemeral = null;
- debug(this, "_isEphemeral", "isEphemeral", "boolean");
- /** @type {!Array} */
- this._inviteUserIds = [];
- /**
- * @param {!NodeList} users
- * @return {undefined}
- */
- this.addUsers = function(users) {
- if (Array.isArray(users)) {
- var l = users.length;
- /** @type {!Array} */
- var todos = [];
- /** @type {number} */
- var i = 0;
- for (; i < l; i++) {
- if (users[i].hasOwnProperty("userId")) {
- todos.push(users[i].userId);
- } else {
- /** @type {!Array} */
- todos = [];
- }
- }
- if (todos.length > 0) {
- this._inviteUserIds = this._inviteUserIds.concat(todos);
- }
- }
- };
- /**
- * @param {!Object} data
- * @return {undefined}
- */
- this.addUser = function(data) {
- if (data.hasOwnProperty("userId")) {
- this._inviteUserIds.push(data.userId);
- }
- };
- /**
- * @param {!NodeList} elems
- * @return {undefined}
- */
- this.addUserIds = function(elems) {
- if (Array.isArray(elems)) {
- var length = elems.length;
- /** @type {!Array} */
- var ret = [];
- /** @type {number} */
- var i = 0;
- for (; i < length; i++) {
- if ("string" == typeof elems[i]) {
- ret.push(elems[i]);
- } else {
- /** @type {!Array} */
- ret = [];
- }
- }
- if (ret.length > 0) {
- this._inviteUserIds = this._inviteUserIds.concat(ret);
- }
- }
- };
- /**
- * @param {?} callback
- * @return {undefined}
- */
- this.addUserId = function(callback) {
- if ("string" == typeof callback) {
- this._inviteUserIds.push(callback);
- }
- };
- };
- /**
- * @return {undefined}
- */
- var UserService = function() {
- };
- UserService.MentionType = {
- USERS : "users",
- CHANNEL : "channel"
- };
- /**
- * @return {undefined}
- */
- var next = function() {
- /** @type {null} */
- this._message = null;
- debug(this, "_message", "message", "string");
- /** @type {null} */
- this._targetLanguages = null;
- if (c) {
- /** @type {null} */
- this.targetLanguages = this._targetLanguages;
- } else {
- Object.defineProperty(this, "targetLanguages", {
- get : function() {
- return this._targetLanguages;
- },
- set : function(e) {
- if (Array.isArray(e)) {
- /** @type {number} */
- var i = 0;
- for (; i < e.length; i++) {
- if ("string" != typeof e[i]) {
- return void(this._targetLanguages = []);
- }
- }
- /** @type {!NodeList} */
- this._targetLanguages = e;
- }
- }
- });
- }
- /** @type {null} */
- this._data = null;
- debug(this, "_data", "data", "string");
- /** @type {null} */
- this._customType = null;
- debug(this, "_customType", "customType", "string");
- /** @type {string} */
- this._mentionType = UserService.MentionType.USERS;
- if (c) {
- /** @type {string} */
- this.mentionType = this._mentionType;
- } else {
- Object.defineProperty(this, "mentionType", {
- get : function() {
- return this._mentionType;
- },
- set : function(e) {
- if (!([UserService.MentionType.USERS, UserService.MentionType.CHANNEL].indexOf(e) < 0)) {
- this._mentionType = e;
- }
- }
- });
- }
- /** @type {!Array} */
- this._mentionedIds = [];
- /** @type {null} */
- this._mentionedUsers = null;
- if (c) {
- /** @type {null} */
- this.mentionedUsers = this._mentionedUsers;
- } else {
- Object.defineProperty(this, "mentionedUsers", {
- get : function() {
- return this._mentionedUsers;
- },
- set : function(members) {
- if (Array.isArray(members)) {
- /** @type {!Array} */
- var connections = [];
- /** @type {!Array} */
- var am = [];
- var userIdToMatchId = {};
- /** @type {number} */
- var i = 0;
- for (; i < members.length; i++) {
- if (!members[i].hasOwnProperty("userId")) {
- return this._mentionedIds = [], void(this._mentionedUsers = []);
- }
- if (!userIdToMatchId[members[i].userId]) {
- /** @type {boolean} */
- userIdToMatchId[members[i].userId] = true;
- if (setup.getInstance().getCurrentUserId() !== members[i].userId) {
- connections.push(members[i]);
- am.push(members[i].userId);
- }
- }
- }
- /** @type {!Array} */
- this._mentionedUserIds = [];
- /** @type {!Array} */
- this._mentionedIds = am;
- /** @type {!Array} */
- this._mentionedUsers = connections;
- }
- }
- });
- }
- /** @type {null} */
- this._mentionedUserIds = null;
- if (c) {
- /** @type {null} */
- this.mentionedUserIds = this._mentionedUserIds;
- } else {
- Object.defineProperty(this, "mentionedUserIds", {
- get : function() {
- return this._mentionedUserIds;
- },
- set : function(a) {
- if (Array.isArray(a)) {
- /** @type {!Array} */
- var reorderMap = [];
- var asm = {};
- /** @type {number} */
- var i = 0;
- for (; i < a.length; i++) {
- if ("string" != typeof a[i]) {
- return this._mentionedIds = [], void(this._mentionedUserIds = []);
- }
- if (!asm[a[i]]) {
- /** @type {boolean} */
- asm[a[i]] = true;
- if (setup.getInstance().getCurrentUserId() !== a[i]) {
- reorderMap.push(a[i]);
- }
- }
- }
- /** @type {!Array} */
- this._mentionedUsers = [];
- /** @type {!Array} */
- this._mentionedIds = reorderMap;
- /** @type {!Array} */
- this._mentionedUserIds = reorderMap;
- }
- }
- });
- }
- /** @type {null} */
- this._pushNotificationDeliveryOption = null;
- debug(this, "_pushNotificationDeliveryOption", "pushNotificationDeliveryOption", "string");
- };
- next.PushNotificationDeliveryOption = {
- DEFAULT : "default",
- SUPPRESS : "suppress"
- };
- /**
- * @return {undefined}
- */
- var set = function() {
- /** @type {null} */
- this._file = null;
- if (c) {
- /** @type {null} */
- this.file = this._file;
- } else {
- Object.defineProperty(this, "file", {
- get : function() {
- return this._file;
- },
- set : function(val) {
- if ("string" != typeof val && "object" == typeof val) {
- /** @type {null} */
- this._fileUrl = null;
- /** @type {!Object} */
- this._file = val;
- }
- }
- });
- }
- /** @type {null} */
- this._fileUrl = null;
- if (c) {
- /** @type {null} */
- this.fileUrl = this._fileUrl;
- } else {
- Object.defineProperty(this, "fileUrl", {
- get : function() {
- return this._fileUrl;
- },
- set : function(expires) {
- if ("string" == typeof expires) {
- /** @type {null} */
- this._file = null;
- /** @type {!Object} */
- this._fileUrl = expires;
- }
- }
- });
- }
- /** @type {null} */
- this._thumbnailSizes = null;
- if (c) {
- /** @type {null} */
- this.thumbnailSizes = this._thumbnailSizes;
- } else {
- Object.defineProperty(this, "thumbnailSizes", {
- get : function() {
- return this._thumbnailSizes;
- },
- set : function(stream) {
- if (Array.isArray(stream)) {
- /** @type {number} */
- var i = 0;
- for (; i < stream.length; i++) {
- if ("object" != typeof stream[i] || "number" != typeof stream[i].maxWidth || "number" != typeof stream[i].maxHeight) {
- return void(this._thumbnailSizes = []);
- }
- }
- /** @type {string} */
- this._thumbnailSizes = stream;
- }
- }
- });
- }
- /** @type {null} */
- this._fileName = null;
- debug(this, "_fileName", "fileName", "string");
- /** @type {null} */
- this._mimeType = null;
- debug(this, "_mimeType", "mimeType", "string");
- /** @type {null} */
- this._fileSize = null;
- debug(this, "_fileSize", "fileSize", "number");
- /** @type {null} */
- this._data = null;
- debug(this, "_data", "data", "string");
- /** @type {null} */
- this._customType = null;
- debug(this, "_customType", "customType", "string");
- /** @type {string} */
- this._mentionType = UserService.MentionType.USERS;
- if (c) {
- /** @type {string} */
- this.mentionType = this._mentionType;
- } else {
- Object.defineProperty(this, "mentionType", {
- get : function() {
- return this._mentionType;
- },
- set : function(e) {
- if (!([UserService.MentionType.USERS, UserService.MentionType.CHANNEL].indexOf(e) < 0)) {
- /** @type {string} */
- this._mentionType = e;
- }
- }
- });
- }
- /** @type {!Array} */
- this._mentionedIds = [];
- /** @type {null} */
- this._mentionedUsers = null;
- if (c) {
- /** @type {null} */
- this.mentionedUsers = this._mentionedUsers;
- } else {
- Object.defineProperty(this, "mentionedUsers", {
- get : function() {
- return this._mentionedUsers;
- },
- set : function(members) {
- if (Array.isArray(members)) {
- /** @type {!Array} */
- var connections = [];
- /** @type {!Array} */
- var am = [];
- var userIdToMatchId = {};
- /** @type {number} */
- var i = 0;
- for (; i < members.length; i++) {
- if (!members[i].hasOwnProperty("userId")) {
- return this._mentionedIds = [], void(this._mentionedUsers = []);
- }
- if (!userIdToMatchId[members[i].userId]) {
- /** @type {boolean} */
- userIdToMatchId[members[i].userId] = true;
- if (setup.getInstance().getCurrentUserId() !== members[i].userId) {
- connections.push(members[i]);
- am.push(members[i].userId);
- }
- }
- }
- /** @type {!Array} */
- this._mentionedUserIds = [];
- /** @type {!Array} */
- this._mentionedIds = am;
- /** @type {!Array} */
- this._mentionedUsers = connections;
- }
- }
- });
- }
- /** @type {null} */
- this._mentionedUserIds = null;
- if (c) {
- /** @type {null} */
- this.mentionedUserIds = this._mentionedUserIds;
- } else {
- Object.defineProperty(this, "mentionedUserIds", {
- get : function() {
- return this._mentionedUserIds;
- },
- set : function(a) {
- if (Array.isArray(a)) {
- /** @type {!Array} */
- var reorderMap = [];
- var asm = {};
- /** @type {number} */
- var i = 0;
- for (; i < a.length; i++) {
- if ("string" != typeof a[i]) {
- return this._mentionedIds = [], void(this._mentionedUserIds = []);
- }
- if (!asm[a[i]]) {
- /** @type {boolean} */
- asm[a[i]] = true;
- if (setup.getInstance().getCurrentUserId() !== a[i]) {
- reorderMap.push(a[i]);
- }
- }
- }
- /** @type {!Array} */
- this._mentionedUsers = [];
- /** @type {!Array} */
- this._mentionedIds = reorderMap;
- /** @type {!Array} */
- this._mentionedUserIds = reorderMap;
- }
- }
- });
- }
- /** @type {null} */
- this._pushNotificationDeliveryOption = null;
- debug(this, "_pushNotificationDeliveryOption", "pushNotificationDeliveryOption", "string");
- };
- set.PushNotificationDeliveryOption = {
- DEFAULT : "default",
- SUPPRESS : "suppress"
- };
- /**
- * @param {!Object} req
- * @return {?}
- */
- var setup = function(req) {
- var data = setup.getInstance();
- if (data) {
- return data;
- }
- try {
- if (!req.hasOwnProperty("appId")) {
- return console.log("Must be set appId"), {};
- }
- } catch (e) {
- return console.log("Must be set appId"), {};
- }
- /** @type {string} */
- this.GCMPushToken = "";
- /** @type {string} */
- this.APNSPushToken = "";
- /** @type {string} */
- this.PUSH_TEMPLATE_DEFAULT = "default";
- /** @type {string} */
- this.PUSH_TEMPLATE_ALTERNATIVE = "alternative";
- /** @type {boolean} */
- this.isSessionOpened = false;
- this.pushTokenRegistrationState = {
- SUCCESS : "success",
- PENDING : "pending",
- ERROR : "error"
- };
- this.loginTimer;
- this.onLoginTimerCancel;
- this.globalTimer;
- this.reconnectTimer;
- this.onReconnectTimerCancel;
- /** @type {null} */
- this.currentUser = null;
- /**
- * @return {?}
- */
- this.getCurrentUserId = function() {
- return setup.getInstance().currentUser ? setup.getInstance().currentUser.userId : null;
- };
- this.wsClient;
- this.connectionState = {
- CONNECTING : "CONNECTING",
- OPEN : "OPEN",
- CLOSING : "CLOSING",
- CLOSED : "CLOSED"
- };
- this.ConnectionState = this.connectionState;
- this.BaseChannel = R;
- /** @type {function(!Object): undefined} */
- this.User = client;
- /** @type {function(undefined): undefined} */
- this.Member = _this;
- /** @type {function(undefined): undefined} */
- this.OpenChannel = Model;
- /** @type {function(undefined): undefined} */
- this.GroupChannel = link;
- /** @type {function(!Object): undefined} */
- this.UserMessage = self;
- /** @type {function(!Object): undefined} */
- this.FileMessage = test;
- /** @type {function(string): undefined} */
- this.AdminMessage = logger;
- this.userEventHandlers = {};
- this.channelHandlers = {};
- this.connectionHandlers = {};
- /** @type {!Array} */
- this.connectionCallback = [];
- /** @type {function(): undefined} */
- this.GroupChannelParams = render;
- /** @type {function(): undefined} */
- this.BaseMessageParams = UserService;
- /** @type {function(): undefined} */
- this.FileMessageParams = set;
- /** @type {function(): undefined} */
- this.UserMessageParams = next;
- /** @type {function(): undefined} */
- this.GroupChannelTotalUnreadMessageCountParams = B;
- var transforms = {};
- path = req.appId;
- ue = this;
- if (!(ne = exports.getInstance())) {
- ne = new exports;
- }
- this.Options = {
- _useMemberAsMessageSender : false,
- get UseMemberAsMessageSender() {
- return this._useMemberAsMessageSender;
- },
- set UseMemberAsMessageSender(val) {
- if ("boolean" == typeof val) {
- /** @type {boolean} */
- this._useMemberAsMessageSender = val;
- }
- },
- get useMemberAsMessageSender() {
- return this._useMemberAsMessageSender;
- },
- set useMemberAsMessageSender(val) {
- if ("boolean" == typeof val) {
- /** @type {boolean} */
- this._useMemberAsMessageSender = val;
- }
- },
- _typingIndicatorThrottle : 1e3,
- get typingIndicatorThrottle() {
- return this._typingIndicatorThrottle;
- },
- set typingIndicatorThrottle(index) {
- if ("number" == typeof index && index >= 1e3 && index <= 9e3) {
- /** @type {number} */
- this._typingIndicatorThrottle = index;
- }
- }
- };
- /** @type {null} */
- this.customApiHost = null;
- /** @type {null} */
- this.customWsHost = null;
- /**
- * @return {undefined}
- */
- this.UserEventHandler = function() {
- /**
- * @param {?} isSlidingUp
- * @return {undefined}
- */
- this.onFriendsDiscovered = function(isSlidingUp) {
- };
- };
- /**
- * @param {?} url
- * @param {?} eTag
- * @return {undefined}
- */
- this.addUserEventHandler = function(url, eTag) {
- setup.getInstance().userEventHandlers[url] = eTag;
- };
- /**
- * @param {?} ballNumber
- * @return {undefined}
- */
- this.removeUserEventHandler = function(ballNumber) {
- delete setup.getInstance().userEventHandlers[ballNumber];
- };
- /**
- * @return {undefined}
- */
- this.removeAllUserEventHandler = function() {
- setup.getInstance().userEventHandlers = {};
- };
- /**
- * @return {undefined}
- */
- this.ChannelHandler = function() {
- /**
- * @param {!Object} message
- * @param {string} e
- * @return {undefined}
- */
- this.onMessageReceived = function(message, e) {
- };
- /**
- * @param {?} message
- * @param {string} paramName
- * @return {undefined}
- */
- this.onMessageUpdated = function(message, paramName) {
- };
- /**
- * @param {?} name
- * @param {string} identityId
- * @return {undefined}
- */
- this.onMessageDeleted = function(name, identityId) {
- };
- /**
- * @param {!Array} proplist
- * @return {undefined}
- */
- this.onReadReceiptUpdated = function(proplist) {
- };
- /**
- * @param {?} val
- * @return {undefined}
- */
- this.onTypingStatusUpdated = function(val) {
- };
- /**
- * @param {!Object} socket
- * @param {?} userId
- * @return {undefined}
- */
- this.onUserJoined = function(socket, userId) {
- };
- /**
- * @param {!Object} tab
- * @param {?} id
- * @return {undefined}
- */
- this.onUserLeft = function(tab, id) {
- };
- /**
- * @param {?} meeting
- * @param {?} callback
- * @return {undefined}
- */
- this.onUserEntered = function(meeting, callback) {
- };
- /**
- * @param {?} meeting
- * @param {?} callback
- * @return {undefined}
- */
- this.onUserExited = function(meeting, callback) {
- };
- /**
- * @param {?} i
- * @param {?} purchaseDetails
- * @return {undefined}
- */
- this.onUserMuted = function(i, purchaseDetails) {
- };
- /**
- * @param {?} i
- * @param {?} purchaseDetails
- * @return {undefined}
- */
- this.onUserUnmuted = function(i, purchaseDetails) {
- };
- /**
- * @param {!Object} b
- * @param {?} n
- * @return {undefined}
- */
- this.onUserBanned = function(b, n) {
- };
- /**
- * @param {!Object} b
- * @param {?} n
- * @return {undefined}
- */
- this.onUserUnbanned = function(b, n) {
- };
- /**
- * @param {!Object} rule
- * @return {undefined}
- */
- this.onChannelFrozen = function(rule) {
- };
- /**
- * @param {!Object} rule
- * @return {undefined}
- */
- this.onChannelUnfrozen = function(rule) {
- };
- /**
- * @param {!Object} container
- * @return {undefined}
- */
- this.onChannelChanged = function(container) {
- };
- /**
- * @param {?} canCreateDiscussions
- * @return {undefined}
- */
- this.onChannelDeleted = function(canCreateDiscussions) {
- };
- /**
- * @param {!Object} tests
- * @param {!Object} n
- * @param {!Array} froot
- * @return {undefined}
- */
- this.onUserReceivedInvitation = function(tests, n, froot) {
- };
- /**
- * @param {!Object} res
- * @param {!Object} record
- * @param {?} seriesData
- * @return {undefined}
- */
- this.onUserDeclinedInvitation = function(res, record, seriesData) {
- };
- /**
- * @param {?} boundContext
- * @param {?} fromDir
- * @return {undefined}
- */
- this.onMetaDataCreated = function(boundContext, fromDir) {
- };
- /**
- * @param {?} pageData
- * @param {?} relationData
- * @return {undefined}
- */
- this.onMetaDataUpdated = function(pageData, relationData) {
- };
- /**
- * @param {?} boundContext
- * @param {?} fromDir
- * @return {undefined}
- */
- this.onMetaDataDeleted = function(boundContext, fromDir) {
- };
- /**
- * @param {?} boundContext
- * @param {?} fromDir
- * @return {undefined}
- */
- this.onMetaCountersCreated = function(boundContext, fromDir) {
- };
- /**
- * @param {?} boundContext
- * @param {?} fromDir
- * @return {undefined}
- */
- this.onMetaCountersUpdated = function(boundContext, fromDir) {
- };
- /**
- * @param {?} boundContext
- * @param {?} fromDir
- * @return {undefined}
- */
- this.onMetaCountersDeleted = function(boundContext, fromDir) {
- };
- /**
- * @param {!Object} i
- * @return {undefined}
- */
- this.onChannelHidden = function(i) {
- };
- /**
- * @param {!Object} adapter
- * @param {string} callback
- * @return {undefined}
- */
- this.onMentionReceived = function(adapter, callback) {
- };
- };
- /**
- * @param {?} url
- * @param {?} eTag
- * @return {undefined}
- */
- this.addChannelHandler = function(url, eTag) {
- setup.getInstance().channelHandlers[url] = eTag;
- };
- /**
- * @param {?} ballNumber
- * @return {undefined}
- */
- this.removeChannelHandler = function(ballNumber) {
- delete setup.getInstance().channelHandlers[ballNumber];
- };
- /**
- * @return {undefined}
- */
- this.removeAllChannelHandlers = function() {
- setup.getInstance().channelHandlers = {};
- };
- /**
- * @return {undefined}
- */
- this.ConnectionHandler = function() {
- /**
- * @return {undefined}
- */
- this.onReconnectStarted = function() {
- };
- /**
- * @return {undefined}
- */
- this.onReconnectSucceeded = function() {
- };
- /**
- * @return {undefined}
- */
- this.onReconnectFailed = function() {
- };
- };
- /**
- * @param {?} url
- * @param {?} eTag
- * @return {undefined}
- */
- this.addConnectionHandler = function(url, eTag) {
- setup.getInstance().connectionHandlers[url] = eTag;
- };
- /**
- * @param {?} ballNumber
- * @return {undefined}
- */
- this.removeConnectionHandler = function(ballNumber) {
- delete setup.getInstance().connectionHandlers[ballNumber];
- };
- /**
- * @return {undefined}
- */
- this.removeAllConnectionHandlers = function() {
- setup.getInstance().connectionHandlers = {};
- };
- /**
- * @param {(!Function|RegExp|string)} e
- * @return {?}
- */
- this.createUserListQuery = function(e) {
- return e ? new load(load.FILTERED_USER, e) : new load(load.ALL_USER);
- };
- /**
- * @return {?}
- */
- this.createBlockedUserListQuery = function() {
- return new load(load.BLOCKED_USER);
- };
- /**
- * @return {?}
- */
- this.getApplicationId = function() {
- return path;
- };
- /**
- * @return {?}
- */
- this.getDebugMode = function() {
- return t;
- };
- /**
- * @param {boolean} d
- * @return {undefined}
- */
- this.setDebugMode = function(d) {
- /** @type {boolean} */
- t = d;
- };
- /**
- * @param {string} results
- * @return {undefined}
- */
- this.setAPIHost = function(results) {
- /** @type {string} */
- combined = results;
- };
- /**
- * @param {string} n
- * @return {undefined}
- */
- this.setWSHost = function(n) {
- /** @type {string} */
- ref1 = n;
- };
- /**
- * @return {undefined}
- */
- this.clearCurrentApiHost = function() {
- /** @type {null} */
- this.customApiHost = null;
- };
- /**
- * @return {?}
- */
- this.getCurrentApiHost = function() {
- return this.customApiHost ? this.customApiHost : combined;
- };
- /**
- * @return {undefined}
- */
- this.clearCurrentWsHost = function() {
- /** @type {null} */
- this.customWsHost = null;
- };
- /**
- * @return {?}
- */
- this.getCurrentWsHost = function() {
- return this.customWsHost ? this.customWsHost : ref1;
- };
- /**
- * @param {boolean} trackInfoUrl
- * @return {undefined}
- */
- this.setErrorFirstCallback = function(trackInfoUrl) {
- /** @type {boolean} */
- lastTrackInfoUrl = trackInfoUrl;
- };
- /**
- * @return {?}
- */
- this.getErrorFirstCallback = function() {
- return lastTrackInfoUrl;
- };
- /**
- * @return {?}
- */
- this.getConnectionState = function() {
- if (!setup.getInstance()) {
- return this.connectionState.CLOSED;
- }
- try {
- return setup.getInstance().wsClient ? setup.getInstance().isSessionOpened ? setup.getInstance().wsClient.getConnectionState() : setup.getInstance().connectionState.CONNECTING : setup.getInstance().connectionState.CLOSED;
- } catch (e) {
- return setup.getInstance().connectionState.CLOSED;
- }
- };
- /**
- * @return {?}
- */
- this.hasLoggedIn = function() {
- return setup.getInstance().currentUser && exports.getInstance().sessionKey;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- var route = function(type) {
- return transforms.hasOwnProperty(type) ? transforms[type] : null;
- };
- /**
- * @param {?} params
- * @return {undefined}
- */
- var run = function(params) {
- var a = new init(params);
- if (a.requestId) {
- var result = route(a.requestId);
- if (null == result) {
- return;
- }
- clearTimeout(result.timer);
- var r = result.handler;
- if (r) {
- if ("EROR" === a.command) {
- var parsed = a.getJsonElement();
- var source = parsed.code;
- var str = parsed.message;
- r(a, new Date(str, source));
- } else {
- r(a, null);
- }
- }
- } else {
- switch(a.command) {
- case "LOGI":
- if (setup.getInstance().loginTimer) {
- clearTimeout(setup.getInstance().loginTimer);
- /** @type {null} */
- setup.getInstance().loginTimer = null;
- /** @type {null} */
- setup.getInstance().onLoginTimerCancel = null;
- var data = a.getJsonElement();
- if (data.hasOwnProperty("error")) {
- /** @type {boolean} */
- setup.getInstance().isSessionOpened = false;
- source = data.code;
- str = data.message;
- setup.getInstance().loginHandler(null, new Date(str, source));
- } else {
- /** @type {boolean} */
- setup.getInstance().isSessionOpened = true;
- if (data.hasOwnProperty("key")) {
- exports.getInstance().sessionKey = data.key;
- }
- if (data.hasOwnProperty("ekey")) {
- exports.getInstance().ekey = data.ekey;
- }
- if (data.hasOwnProperty("user_id")) {
- setup.getInstance().currentUser = new client(data);
- }
- setup.getInstance().loginHandler(setup.getInstance().currentUser, null);
- }
- }
- break;
- case "MESG":
- case "FILE":
- case "BRDM":
- case "ADMM":
- /** @type {string} */
- var req = "";
- /** @type {boolean} */
- var silent = false;
- if ("MESG" === a.command ? req = new self(a.getJsonElement()) : "FILE" === a.command ? req = new test(a.getJsonElement()) : (req = new logger(a.getJsonElement()), a.getJsonElement().hasOwnProperty("silent") && (silent = a.getJsonElement().silent)), !req) {
- return;
- }
- if (req.isGroupChannel()) {
- /** @type {boolean} */
- var p = link.cachedChannels.hasOwnProperty(req.channelUrl);
- link.getChannel(req.channelUrl, function(self, callback) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var network = self;
- /** @type {!Object} */
- self = callback;
- callback = network;
- }
- if (callback) {
- if (r) {
- r(null, callback);
- }
- } else {
- if (self.isHidden = false, link.cachedChannels[self.url] = self, req._sender && self.memberMap.hasOwnProperty(req._sender.userId)) {
- var user = self.memberMap[req._sender.userId];
- if (user.nickname !== req._sender.nickname) {
- user.nickname = req._sender.nickname;
- }
- if (user.profileUrl !== req._sender.profileUrl) {
- user.profileUrl = req._sender.profileUrl;
- }
- }
- var user = setup.getInstance().currentUser;
- if (user && req._sender && user.userId === req._sender.userId) {
- if (user.nickname !== req._sender.nickname) {
- user.nickname = req._sender.nickname;
- }
- if (user.profileUrl !== req._sender.profileUrl) {
- user.profileUrl = req._sender.profileUrl;
- }
- }
- /** @type {boolean} */
- var extension = false;
- if (req.mentionType === UserService.MentionType.CHANNEL) {
- if (!(req.sender && req.sender.userId === setup.getInstance().getCurrentUserId())) {
- /** @type {boolean} */
- extension = true;
- }
- } else {
- if (req.mentionType === UserService.MentionType.USERS) {
- var key;
- for (key in req.mentionedUsers) {
- if ((!req.sender || req.sender.userId !== setup.getInstance().getCurrentUserId()) && req.mentionedUsers[key].userId === setup.getInstance().getCurrentUserId()) {
- /** @type {boolean} */
- extension = true;
- break;
- }
- }
- }
- }
- if (silent || (self.isEphemeral ? (self.lastMessage = req, req.sender && req.sender.userId === setup.getInstance().getCurrentUserId() || log(self, self.unreadMessageCount + 1, self.unreadMentionCount + (extension ? 1 : 0))) : p && (self.lastMessage = req, req.sender && req.sender.userId === setup.getInstance().getCurrentUserId() || log(self, self.unreadMessageCount + 1, self.unreadMentionCount + (extension ? 1 : 0)))), !silent) {
- for (key in setup.getInstance().channelHandlers) {
- var list = setup.getInstance().channelHandlers[key];
- list.onChannelChanged(self);
- }
- }
- for (key in setup.getInstance().channelHandlers) {
- list = setup.getInstance().channelHandlers[key];
- list.onMessageReceived(self, req);
- if (extension) {
- list.onMentionReceived(self, req);
- }
- }
- }
- });
- } else {
- Model.getChannel(req.channelUrl, function(validator, trOpts) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var rrjqbvValidator = validator;
- /** @type {string} */
- validator = trOpts;
- trOpts = rrjqbvValidator;
- }
- if (trOpts) {
- if (r) {
- r(null, trOpts);
- }
- } else {
- /** @type {boolean} */
- var s = false;
- if (req.mentionType === UserService.MentionType.CHANNEL) {
- /** @type {boolean} */
- s = true;
- } else {
- if (req.mentionType === UserService.MentionType.USERS) {
- var key;
- for (key in req.mentionedUsers) {
- if (req.mentionedUsers[key].userId === setup.getInstance().getCurrentUserId()) {
- /** @type {boolean} */
- s = true;
- break;
- }
- }
- }
- }
- for (key in setup.getInstance().channelHandlers) {
- var self = setup.getInstance().channelHandlers[key];
- if (Model.enteredChannels[validator.url]) {
- self.onMessageReceived(validator, req);
- }
- if (s) {
- self.onMentionReceived(validator, req);
- }
- }
- }
- });
- }
- break;
- case "MEDI":
- case "FEDI":
- case "AEDI":
- /** @type {string} */
- req = "";
- if (!(req = "MEDI" === a.command ? new self(a.getJsonElement()) : "FEDI" === a.command ? new test(a.getJsonElement()) : new logger(a.getJsonElement()))) {
- return;
- }
- if (req.isGroupChannel()) {
- link.getChannel(req.channelUrl, function(e, o) {
- if (lastTrackInfoUrl) {
- var str = e;
- e = o;
- o = str;
- }
- if (o) {
- if (r) {
- r(null, o);
- }
- } else {
- if (req._sender && e.memberMap.hasOwnProperty(req._sender.userId)) {
- var user = e.memberMap[req._sender.userId];
- if (user.nickname !== req._sender.nickname) {
- user.nickname = req._sender.nickname;
- }
- if (user.profileUrl !== req._sender.profileUrl) {
- user.profileUrl = req._sender.profileUrl;
- }
- }
- var user = setup.getInstance().currentUser;
- var i;
- for (i in user && req._sender && user.userId === req._sender.userId && (user.nickname !== req._sender.nickname && (user.nickname = req._sender.nickname), user.profileUrl !== req._sender.profileUrl && (user.profileUrl = req._sender.profileUrl)), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[i].onMessageUpdated(e, req);
- }
- }
- });
- } else {
- Model.getChannel(req.channelUrl, function(e, o) {
- if (lastTrackInfoUrl) {
- var str = e;
- e = o;
- o = str;
- }
- if (o) {
- if (r) {
- r(null, o);
- }
- } else {
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onMessageUpdated(e, req);
- }
- }
- });
- }
- break;
- case "READ":
- var data = new function(config) {
- if (config) {
- this.reader = new client(config.user);
- /** @type {number} */
- this.timestamp = parseInt(config.ts);
- /** @type {string} */
- this.channelUrl = config.hasOwnProperty("channel_url") ? String(config.channel_url) : "";
- /** @type {string} */
- this.channelType = config.hasOwnProperty("channel_type") ? String(config.channel_type) : update.CHANNEL_TYPE_GROUP;
- }
- }(a.getJsonElement());
- /** @type {boolean} */
- p = link.cachedChannels.hasOwnProperty(data.channelUrl);
- link.getChannel(data.channelUrl, function(self, callback) {
- if (lastTrackInfoUrl) {
- /** @type {!Array} */
- var network = self;
- /** @type {!Array} */
- self = callback;
- callback = network;
- }
- if (callback) {
- if (r) {
- r(null, callback);
- }
- } else {
- if (data.reader.userId === setup.getInstance().getCurrentUserId()) {
- if (p) {
- if (self.unreadMessageCount > 0 || self.unreadMentionCount > 0) {
- var type;
- for (type in log(self, 0, 0), setup.getInstance().channelHandlers) {
- var list = setup.getInstance().channelHandlers[type];
- list.onChannelChanged(self);
- }
- }
- } else {
- if (0 === self.unreadMessageCount || 0 === self.unreadMentionCount) {
- for (type in setup.getInstance().channelHandlers) {
- list = setup.getInstance().channelHandlers[type];
- list.onChannelChanged(self);
- }
- }
- }
- } else {
- for (type in self.updateReadReceipt(data.reader.userId, data.timestamp), setup.getInstance().channelHandlers) {
- list = setup.getInstance().channelHandlers[type];
- list.onReadReceiptUpdated(self);
- }
- }
- }
- });
- break;
- case "TPST":
- case "TPEN":
- case "MTIO":
- break;
- case "SYEV":
- init(a);
- break;
- case "USEV":
- success(a);
- break;
- case "DELM":
- var item = a.getJsonElement();
- /** @type {string} */
- var yminstr = String(item.channel_type);
- /** @type {string} */
- var name = String(item.channel_url);
- /** @type {string} */
- var userId = String(item.msg_id);
- switch(yminstr) {
- case update.CHANNEL_TYPE_OPEN:
- Model.getChannel(name, function(e, realEvent) {
- if (lastTrackInfoUrl) {
- var event = e;
- e = realEvent;
- realEvent = event;
- }
- if (realEvent) {
- console.log("Discard a command.");
- } else {
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onMessageDeleted(e, userId);
- }
- }
- });
- break;
- case update.CHANNEL_TYPE_GROUP:
- link.getChannel(name, function(e, realEvent) {
- if (lastTrackInfoUrl) {
- var event = e;
- e = realEvent;
- realEvent = event;
- }
- if (realEvent) {
- console.log("Discard a command.");
- } else {
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onMessageDeleted(e, userId);
- }
- }
- });
- }
- }
- }
- };
- /**
- * @param {?} art
- * @return {undefined}
- */
- var success = function(art) {
- var _this = new read(art.getJsonElement());
- switch(_this.category) {
- case _init.CATEGORY_USER_BLOCK:
- case _init.CATEGORY_USER_UNBLOCK:
- var id = _this.data.blocker.user_id;
- var userId = _this.data.blockee.user_id;
- Object.keys(link.cachedChannels).forEach(function(key) {
- var session = link.cachedChannels[key];
- try {
- if (setup.getInstance().getCurrentUserId() === id) {
- /** @type {boolean} */
- session.memberMap[userId].isBlockedByMe = _this.category === _init.CATEGORY_USER_BLOCK;
- } else {
- if (setup.getInstance().getCurrentUserId() === userId) {
- /** @type {boolean} */
- session.memberMap[id].isBlockingMe = _this.category === _init.CATEGORY_USER_BLOCK;
- }
- }
- } catch (e) {
- }
- });
- break;
- case _init.CATEGORY_FRIEND_DISCOVERED:
- var navLinksArr = _this.data.friend_discoveries;
- var clojIsReversed = navLinksArr.map(function(options) {
- return new client(options);
- });
- var i;
- for (i in setup.getInstance().userEventHandlers) {
- setup.getInstance().userEventHandlers[i].onFriendsDiscovered(clojIsReversed);
- }
- }
- };
- /**
- * @param {!Object} ast
- * @return {undefined}
- */
- var init = function(ast) {
- var data = ast.getJsonElement();
- var req = new read(data);
- switch(req.category) {
- case read.CATEGORY_CHANNEL_JOIN:
- case read.CATEGORY_CHANNEL_LEAVE:
- link.getChannel(req.channelUrl, function($scope, scope) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var s = $scope;
- /** @type {string} */
- $scope = scope;
- scope = s;
- }
- if (scope) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var obj = req.data.hasOwnProperty("member_count") ? req.data.member_count : null;
- var element = req.data.hasOwnProperty("joined_member_count") ? req.data.joined_member_count : null;
- if (req.category === read.CATEGORY_CHANNEL_JOIN) {
- (req.data.hasOwnProperty("users") ? req.data.users : function(storeData) {
- return storeData.state = _this.JOINED, [storeData];
- }(req.data)).forEach(function(keyReads) {
- !function(options, exit, item) {
- if ($scope.isSuper) {
- $scope.setLatestMemberCount(exit, item, data.ts);
- } else {
- /** @type {string} */
- options.state = _this.JOINED;
- $scope.addMember(new _this(options));
- $scope.updateJoinedMemberCount();
- }
- var c = new client(options);
- var i;
- for (i in c.userId === setup.getInstance().getCurrentUserId() && ($scope.myMemberState = "joined", link.cachedChannels[$scope.url] = $scope), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[i].onUserJoined($scope, c);
- }
- }(keyReads, obj, element);
- });
- } else {
- var c = new client(req.data);
- var indexLookupKey;
- for (indexLookupKey in c.userId === setup.getInstance().getCurrentUserId() ? ($scope.isPublic || link.removeCachedChannel(req.channelUrl), $scope.myMemberState = "none") : link.cachedChannels[$scope.url] = $scope, $scope.isSuper ? $scope.setLatestMemberCount(obj, element, data.ts) : ($scope.removeMember(c), $scope.updateJoinedMemberCount()), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onUserLeft($scope, c);
- }
- }
- }
- });
- break;
- case read.CATEGORY_CHANNEL_INVITE:
- link.getChannel(req.channelUrl, function(options, url) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var method = options;
- /** @type {!Object} */
- options = url;
- url = method;
- }
- if (url) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- /** @type {null} */
- var uncert = null;
- if (req.data && req.data.inviter && !check(req.data.inviter)) {
- uncert = new client(req.data.inviter);
- }
- /** @type {!Array} */
- var newNodeLists = [];
- var j;
- for (j in req.data.invitees) {
- var itemNodeList = new client(req.data.invitees[j]);
- newNodeLists.push(itemNodeList);
- /** @type {string} */
- req.data.invitees[j].state = _this.INVITED;
- var child = new _this(req.data.invitees[j]);
- if (options.isSuper) {
- var _ = req.data.hasOwnProperty("member_count") ? req.data.member_count : null;
- var activeItem = req.data.hasOwnProperty("joined_member_count") ? req.data.joined_member_count : null;
- options.setLatestMemberCount(_, activeItem, data.ts);
- } else {
- options.addMember(child);
- }
- if (child.userId === setup.getInstance().getCurrentUserId()) {
- /** @type {boolean} */
- options.isHidden = false;
- if ("joined" !== options.myMemberState) {
- /** @type {string} */
- options.myMemberState = "invited";
- }
- /** @type {!Object} */
- link.cachedChannels[options.url] = options;
- }
- }
- for (j in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[j].onUserReceivedInvitation(options, uncert, newNodeLists);
- }
- }
- });
- break;
- case read.CATEGORY_CHANNEL_DECLINE_INVITE:
- link.getChannel(req.channelUrl, function(options, url) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var method = options;
- /** @type {string} */
- options = url;
- url = method;
- }
- if (url) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- /** @type {null} */
- var recordWithMsg = null;
- if (req.data && req.data.inviter && !check(req.data.inviter)) {
- recordWithMsg = new client(req.data.inviter);
- }
- var data = new client(req.data.invitee);
- if (data.userId === setup.getInstance().getCurrentUserId() && (options.myMemberState = "none", options.isPublic || link.removeCachedChannel(req.channelUrl)), options.isSuper) {
- var u = req.data.hasOwnProperty("member_count") ? req.data.member_count : null;
- var activeItem = req.data.hasOwnProperty("joined_member_count") ? req.data.joined_member_count : null;
- options.setLatestMemberCount(u, activeItem, data.ts);
- } else {
- options.removeMember(data);
- }
- var indexLookupKey;
- for (indexLookupKey in link.cachedChannels[options.url] = options, setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onUserDeclinedInvitation(options, recordWithMsg, data);
- }
- }
- });
- break;
- case read.CATEGORY_TYPING_START:
- case read.CATEGORY_TYPING_END:
- link.getChannel(req.channelUrl, function(newPath, i) {
- if (lastTrackInfoUrl) {
- var origNewPath = newPath;
- newPath = i;
- i = origNewPath;
- }
- if (i) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var type = new client(req.data);
- var indexLookupKey;
- for (indexLookupKey in req.category === read.CATEGORY_TYPING_START ? newPath.updateTypingStatus(type, true) : newPath.updateTypingStatus(type, false), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onTypingStatusUpdated(newPath);
- }
- }
- });
- break;
- case read.CATEGORY_CHANNEL_ENTER:
- case read.CATEGORY_CHANNEL_EXIT:
- Model.getChannel(req.channelUrl, function(meeting, data) {
- if (lastTrackInfoUrl) {
- var meetingInfo = meeting;
- meeting = data;
- data = meetingInfo;
- }
- if (data) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- if (req.data.hasOwnProperty("participant_count")) {
- meeting.participantCount = req.data.participant_count;
- }
- var c = new client(req.data);
- if (req.category === read.CATEGORY_CHANNEL_ENTER) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var filterValue = setup.getInstance().channelHandlers[i];
- filterValue.onUserEntered(meeting, c);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- filterValue = setup.getInstance().channelHandlers[i];
- filterValue.onUserExited(meeting, c);
- }
- }
- }
- });
- break;
- case read.CATEGORY_USER_CHANNEL_MUTE:
- case read.CATEGORY_USER_CHANNEL_UNMUTE:
- if (req.isOpenChannel()) {
- Model.getChannel(req.channelUrl, function(f, _$param5) {
- if (lastTrackInfoUrl) {
- var f3 = f;
- f = _$param5;
- _$param5 = f3;
- }
- if (_$param5) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var purchaseDetails = new client(req.data);
- if (req.category === read.CATEGORY_USER_CHANNEL_MUTE) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var instanceAndSymbol = setup.getInstance().channelHandlers[i];
- instanceAndSymbol.onUserMuted(f, purchaseDetails);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- instanceAndSymbol = setup.getInstance().channelHandlers[i];
- instanceAndSymbol.onUserUnmuted(f, purchaseDetails);
- }
- }
- }
- });
- } else {
- link.getChannel(req.channelUrl, function(f, _$param5) {
- if (lastTrackInfoUrl) {
- var f3 = f;
- f = _$param5;
- _$param5 = f3;
- }
- if (_$param5) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var purchaseDetails = new client(req.data);
- if (purchaseDetails.userId === setup.getInstance().getCurrentUserId() && (f.myMutedState = req.category === read.CATEGORY_USER_CHANNEL_MUTE ? "muted" : "unmuted"), req.category === read.CATEGORY_USER_CHANNEL_MUTE) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var instanceAndSymbol = setup.getInstance().channelHandlers[i];
- instanceAndSymbol.onUserMuted(f, purchaseDetails);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- instanceAndSymbol = setup.getInstance().channelHandlers[i];
- instanceAndSymbol.onUserUnmuted(f, purchaseDetails);
- }
- }
- }
- });
- }
- break;
- case read.CATEGORY_USER_CHANNEL_BAN:
- case read.CATEGORY_USER_CHANNEL_UNBAN:
- if (req.isOpenChannel()) {
- Model.getChannel(req.channelUrl, function(newPath, i) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var origNewPath = newPath;
- /** @type {string} */
- newPath = i;
- i = origNewPath;
- }
- if (i) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var c = new client(req.data);
- if (req.category === read.CATEGORY_USER_CHANNEL_BAN) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var form = setup.getInstance().channelHandlers[i];
- form.onUserBanned(newPath, c);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- form = setup.getInstance().channelHandlers[i];
- form.onUserUnbanned(newPath, c);
- }
- }
- }
- });
- } else {
- link.getChannel(req.channelUrl, function(t, a) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var tmp = t;
- /** @type {string} */
- t = a;
- a = tmp;
- }
- if (a) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var c = new client(req.data);
- if (req.category === read.CATEGORY_USER_CHANNEL_BAN) {
- if (c.userId === setup.getInstance().getCurrentUserId() && (t.myMemberState = "none"), t.isSuper) {
- var l = req.data.hasOwnProperty("member_count") ? req.data.member_count : null;
- var previousWidgetPos = req.data.hasOwnProperty("joined_member_count") ? req.data.joined_member_count : null;
- t.setLatestMemberCount(l, previousWidgetPos, data.ts);
- } else {
- t.removeMember(c);
- t.updateJoinedMemberCount();
- }
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var d = setup.getInstance().channelHandlers[i];
- d.onUserBanned(t, c);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- d = setup.getInstance().channelHandlers[i];
- d.onUserUnbanned(t, c);
- }
- }
- }
- });
- }
- break;
- case read.CATEGORY_CHANNEL_FREEZE:
- case read.CATEGORY_CHANNEL_UNFREEZE:
- if (req.isOpenChannel()) {
- Model.getChannel(req.channelUrl, function(validator, val) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var config = validator;
- /** @type {string} */
- validator = val;
- val = config;
- }
- if (val) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- if (validator.isFrozen = req.data.freeze, Model.cachedChannels[validator.url] = validator, req.category === read.CATEGORY_CHANNEL_FREEZE) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var rule = setup.getInstance().channelHandlers[i];
- rule.onChannelFrozen(validator);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- rule = setup.getInstance().channelHandlers[i];
- rule.onChannelUnfrozen(validator);
- }
- }
- }
- });
- } else {
- link.getChannel(req.channelUrl, function(copy, byte) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var supportTypes = copy;
- /** @type {string} */
- copy = byte;
- byte = supportTypes;
- }
- if (byte) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- if (copy.isFrozen = req.data.freeze, link.cachedChannels[copy.url] = copy, req.category === read.CATEGORY_CHANNEL_FREEZE) {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- var rule = setup.getInstance().channelHandlers[i];
- rule.onChannelFrozen(copy);
- }
- } else {
- for (i in setup.getInstance().channelHandlers) {
- rule = setup.getInstance().channelHandlers[i];
- rule.onChannelUnfrozen(copy);
- }
- }
- }
- });
- }
- break;
- case read.CATEGORY_CHANNEL_DELETED:
- if (req.isGroupChannel()) {
- var targetId;
- for (targetId in link.removeCachedChannel(req.channelUrl), setup.getInstance().channelHandlers) {
- var target = setup.getInstance().channelHandlers[targetId];
- target.onChannelDeleted(req.channelUrl, "group");
- }
- } else {
- for (targetId in Model.removeCachedChannel(req.channelUrl), setup.getInstance().channelHandlers) {
- target = setup.getInstance().channelHandlers[targetId];
- target.onChannelDeleted(req.channelUrl, "open");
- }
- }
- break;
- case read.CATEGORY_CHANNEL_PROP_CHANGED:
- if (req.isOpenChannel()) {
- Model.getChannelWithoutCache(req.channelUrl, function(height, opt_height) {
- if (lastTrackInfoUrl) {
- var whatToScale = height;
- height = opt_height;
- opt_height = whatToScale;
- }
- if (opt_height) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var i;
- for (i in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[i].onChannelChanged(height);
- }
- }
- });
- } else {
- link.getChannelWithoutCache(req.channelUrl, function(self, p) {
- if (lastTrackInfoUrl) {
- /** @type {!Array} */
- var current = self;
- /** @type {!Array} */
- self = p;
- p = current;
- }
- if (p) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var x = self.unreadMessageCount;
- var y = self.unreadMentionCount;
- var indexLookupKey;
- for (indexLookupKey in self.myCountPreference !== link.CountPreference.ALL && (self.myCountPreference === link.CountPreference.UNREAD_MESSAGE_COUNT_ONLY ? y = 0 : self.myCountPreference === link.CountPreference.UNREAD_MENTION_COUNT_ONLY ? x = 0 : (x = 0, y = 0)), log(self, x, y), setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onChannelChanged(self);
- }
- }
- });
- }
- break;
- case read.CATEGORY_CHANNEL_META_DATA_CHANGED:
- case read.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:
- var db = req.data.hasOwnProperty("created");
- var ret = req.data.hasOwnProperty("updated");
- var deletedIds = req.data.hasOwnProperty("deleted");
- if (req.isOpenChannel()) {
- Model.getChannel(req.channelUrl, function(that, hash) {
- if (lastTrackInfoUrl) {
- var fooabcdefghi = that;
- that = hash;
- hash = fooabcdefghi;
- }
- if (hash) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- var _updateMap = setup.getInstance().channelHandlers[indexLookupKey];
- if (req.category === read.CATEGORY_CHANNEL_META_DATA_CHANGED) {
- if (db) {
- _updateMap.onMetaDataCreated(that, req.data.created);
- }
- if (ret) {
- _updateMap.onMetaDataUpdated(that, req.data.updated);
- }
- if (deletedIds) {
- _updateMap.onMetaDataDeleted(that, req.data.deleted);
- }
- } else {
- if (db) {
- _updateMap.onMetaCountersCreated(that, req.data.created);
- }
- if (ret) {
- _updateMap.onMetaCountersUpdated(that, req.data.updated);
- }
- if (deletedIds) {
- _updateMap.onMetaCountersDeleted(that, req.data.deleted);
- }
- }
- }
- }
- });
- } else {
- link.getChannel(req.channelUrl, function(that, hash) {
- if (lastTrackInfoUrl) {
- var fooabcdefghi = that;
- that = hash;
- hash = fooabcdefghi;
- }
- if (hash) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- var _updateMap = setup.getInstance().channelHandlers[indexLookupKey];
- if (req.category === read.CATEGORY_CHANNEL_META_DATA_CHANGED) {
- if (db) {
- _updateMap.onMetaDataCreated(that, req.data.created);
- }
- if (ret) {
- _updateMap.onMetaDataUpdated(that, req.data.updated);
- }
- if (deletedIds) {
- _updateMap.onMetaDataDeleted(that, req.data.deleted);
- }
- } else {
- if (db) {
- _updateMap.onMetaCountersCreated(that, req.data.created);
- }
- if (ret) {
- _updateMap.onMetaCountersUpdated(that, req.data.updated);
- }
- if (deletedIds) {
- _updateMap.onMetaCountersDeleted(that, req.data.deleted);
- }
- }
- }
- }
- });
- }
- break;
- case read.CATEGORY_CHANNEL_HIDE:
- link.getChannel(req.channelUrl, function(f, _$param5) {
- if (lastTrackInfoUrl) {
- /** @type {!Object} */
- var f3 = f;
- /** @type {!Object} */
- f = _$param5;
- _$param5 = f3;
- }
- if (_$param5) {
- console.log("Discard a command: " + ast.command + ":" + req.category);
- } else {
- if (f.isHidden = true, req.data && req.data.hasOwnProperty("hide_previous_messages") && req.data.hide_previous_messages && link.cachedChannels) {
- var div = link.cachedChannels[f.url];
- log(div, 0, 0);
- link.cachedChannels[f.url] = div;
- }
- var indexLookupKey;
- for (indexLookupKey in setup.getInstance().channelHandlers) {
- setup.getInstance().channelHandlers[indexLookupKey].onChannelHidden(f);
- }
- }
- });
- }
- };
- /**
- * @param {string} body
- * @param {string} success
- * @return {?}
- */
- this.setPushTemplate = function(body, success) {
- return !body || body !== this.PUSH_TEMPLATE_DEFAULT && body !== this.PUSH_TEMPLATE_ALTERNATIVE ? void callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), success) : this.currentUser ? void exports.getInstance().setPushTemplate(this.getCurrentUserId(), body, function(it_case, exisObj) {
- if (exisObj) {
- callback(null, exisObj, success);
- } else {
- var identifierPositions = it_case.name.toString();
- callback(identifierPositions, null, success);
- }
- }) : void callback(null, new Date("Connection must be made before you set push template", concat.CONNECTION_REQUIRED), success);
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getPushTemplate = function(productInfo) {
- if (this.currentUser) {
- exports.getInstance().getPushTemplate(this.getCurrentUserId(), function(it_case, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- var identifierPositions = it_case.name.toString();
- callback(identifierPositions, null, productInfo);
- }
- });
- } else {
- callback(null, new Date("Connection must be made before you get push template", concat.CONNECTION_REQUIRED), productInfo);
- }
- };
- /**
- * @param {?} t
- * @param {!Function} c
- * @return {undefined}
- */
- this.setChannelInvitationPreference = function(t, c) {
- if ("boolean" != typeof t) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), c);
- }
- exports.getInstance().setChannelInvitationPreference(this.getCurrentUserId(), t, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, c);
- } else {
- callback({
- autoAccept : canCreateDiscussions.auto_accept
- }, null, c);
- }
- });
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getChannelInvitationPreference = function(productInfo) {
- exports.getInstance().getChannelInvitationPreference(this.getCurrentUserId(), function(n, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- callback({
- autoAccept : n.auto_accept
- }, null, productInfo);
- }
- });
- };
- /**
- * @return {undefined}
- */
- this.connect = function() {
- /** @type {!Array<?>} */
- var args = Array.prototype.slice.call(arguments);
- /** @type {null} */
- var id = null;
- /** @type {null} */
- var event = null;
- /** @type {null} */
- var productInfo = null;
- switch("function" == typeof args.slice(-1)[0] && (productInfo = args.pop()), args.length) {
- case 1:
- id = args[0];
- break;
- case 2:
- id = args[0];
- event = args[1];
- break;
- case 3:
- id = args[0];
- this.customApiHost = args[1];
- this.customWsHost = args[2];
- break;
- case 4:
- id = args[0];
- event = args[1];
- this.customApiHost = args[2];
- this.customWsHost = args[3];
- break;
- default:
- if (t) {
- console.log("sb.connect args length error: ", arguments);
- }
- }
- if (id && 0 !== id.length) {
- if (setup.getInstance().reconnectTimer) {
- clearTimeout(setup.getInstance().reconnectTimer);
- /** @type {null} */
- setup.getInstance().reconnectTimer = null;
- /** @type {null} */
- setup.getInstance().onReconnectTimerCancel = null;
- }
- if (setup.getInstance().getConnectionState() === this.connectionState.OPEN && setup.getInstance().getCurrentUserId() === id) {
- callback(setup.getInstance().currentUser, null, productInfo);
- } else {
- setup.getInstance().connectionCallback.push(productInfo);
- if (1 === setup.getInstance().connectionCallback.length) {
- callback(true, null);
- connect(id, event);
- }
- }
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), productInfo);
- }
- };
- /** @type {boolean} */
- var canViewMyFiles = false;
- /** @type {boolean} */
- var _ = false;
- /** @type {boolean} */
- var canAccessMyFiles = true;
- /**
- * @return {undefined}
- */
- this.setBackgroundState = function() {
- if (!canViewMyFiles && canAccessMyFiles) {
- /** @type {boolean} */
- canViewMyFiles = true;
- if (this.getConnectionState() !== this.connectionState.CLOSED) {
- /** @type {boolean} */
- _ = true;
- callback(false, null);
- } else {
- /** @type {boolean} */
- _ = false;
- }
- }
- };
- /**
- * @return {undefined}
- */
- this.setForegroundState = function() {
- if (canViewMyFiles && canAccessMyFiles) {
- /** @type {boolean} */
- canViewMyFiles = false;
- if (_ && this.currentUser) {
- /** @type {number} */
- retries = 0;
- start(this.getCurrentUserId(), true);
- }
- }
- };
- /**
- * @return {undefined}
- */
- this.disableStateChange = function() {
- /** @type {boolean} */
- canAccessMyFiles = false;
- };
- /**
- * @return {undefined}
- */
- this.enableStateChange = function() {
- /** @type {boolean} */
- canAccessMyFiles = true;
- };
- /**
- * @param {string} progress
- * @return {undefined}
- */
- this.disconnect = function(progress) {
- callback(true, progress);
- };
- /**
- * @return {?}
- */
- this.reconnect = function() {
- if (!exports.getInstance().sessionKey || !this.currentUser) {
- return false;
- }
- /** @type {boolean} */
- var touch = true;
- return retries > 0 && (touch = false), callback(false, null), retries = 0, start(this.getCurrentUserId(), touch), true;
- };
- /**
- * @param {boolean} remaining
- * @param {string} result
- * @return {undefined}
- */
- var callback = function(remaining, result) {
- var socket = this;
- if (setup.getInstance().loginTimer) {
- clearTimeout(setup.getInstance().loginTimer);
- if (setup.getInstance().onLoginTimerCancel) {
- setup.getInstance().onLoginTimerCancel();
- /** @type {null} */
- setup.getInstance().onLoginTimerCancel = null;
- }
- /** @type {null} */
- setup.getInstance().loginTimer = null;
- }
- if (setup.getInstance().reconnectTimer) {
- clearTimeout(setup.getInstance().reconnectTimer);
- if (setup.getInstance().onReconnectTimerCancel) {
- setup.getInstance().onReconnectTimerCancel();
- /** @type {null} */
- setup.getInstance().onReconnectTimerCancel = null;
- }
- /** @type {null} */
- setup.getInstance().reconnectTimer = null;
- }
- if (setup.getInstance().wsClient) {
- /** @type {number} */
- retries = 0;
- setup.getInstance().wsClient.disconnect(true);
- /** @type {null} */
- setup.getInstance().wsClient = null;
- }
- (function() {
- if (remaining) {
- var name;
- for (name in Model.clearEnteredChannels(), Model.clearCache(), link.clearCache(), setup.getInstance().globalTimer && (clearTimeout(socket.globalTimer), setup.getInstance().globalTimer = null), setup.getInstance().ackStateMap) {
- clearTimeout(setup.getInstance().ackStateMap[name].timer);
- }
- setup.getInstance().ackStateMap = {};
- /** @type {null} */
- setup.getInstance().currentUser = null;
- /** @type {null} */
- exports.getInstance().sessionKey = null;
- /** @type {null} */
- exports.getInstance().ekey = null;
- }
- callback(null, null, result);
- })();
- };
- /**
- * @param {!Object} e
- * @param {boolean} touch
- * @return {undefined}
- */
- var start = function(e, touch) {
- if (setup.getInstance().reconnectTimer) {
- if (t) {
- console.log("still reconnecting");
- }
- } else {
- if ((retries = retries + 1) <= 1) {
- if (touch) {
- var i;
- for (i in setup.getInstance().connectionHandlers) {
- var instanceAndSymbol = setup.getInstance().connectionHandlers[i];
- instanceAndSymbol.onReconnectStarted(i);
- }
- }
- /** @type {number} */
- ms = 0;
- } else {
- /** @type {number} */
- ms = 3e3 * Math.pow(2, retries - 2);
- }
- if (!e || !exports.getInstance().sessionKey || retries >= 6) {
- for (i in callback(false, null), retries = 0, setup.getInstance().connectionHandlers) {
- instanceAndSymbol = setup.getInstance().connectionHandlers[i];
- instanceAndSymbol.onReconnectFailed(i);
- }
- return;
- }
- /**
- * @return {undefined}
- */
- setup.getInstance().onReconnectTimerCancel = function() {
- /** @type {number} */
- retries = 0;
- };
- /** @type {number} */
- setup.getInstance().reconnectTimer = setTimeout(function() {
- /** @type {null} */
- setup.getInstance().reconnectTimer = null;
- /** @type {null} */
- setup.getInstance().onReconnectTimerCancel = null;
- if (setup.getInstance().wsClient) {
- setup.getInstance().wsClient.disconnect(true);
- }
- var self = new Client.WSClientHandler;
- setup.getInstance().wsClient = new Client(self);
- /**
- * @param {!Object} status
- * @return {undefined}
- */
- setup.getInstance().loginHandler = function(status) {
- var i;
- for (i in retries = 0, Model.enteredChannels) {
- Model.enteredChannels[i].enter();
- }
- for (i in setup.getInstance().connectionHandlers) {
- setup.getInstance().connectionHandlers[i].onReconnectSucceeded(i);
- }
- };
- /**
- * @return {undefined}
- */
- self.onOpen = function() {
- if (t) {
- console.log("reconnectWS onOpen");
- }
- /** @type {number} */
- setup.getInstance().loginTimer = setTimeout(function() {
- if (t) {
- console.log("reconnectWS loginTimer timedout");
- }
- /** @type {null} */
- setup.getInstance().loginTimer = null;
- start(e, true);
- }, 1e4);
- /** @type {null} */
- setup.getInstance().onLoginTimerCancel = null;
- };
- /**
- * @param {?} url
- * @return {undefined}
- */
- self.onMessage = function(url) {
- run(url);
- };
- /**
- * @return {undefined}
- */
- self.onError = function() {
- if (t) {
- console.log("reconnectWS onError");
- }
- start(e, true);
- };
- /**
- * @return {undefined}
- */
- self.onClose = function() {
- if (t) {
- console.log("reconnectWS onClose");
- }
- };
- var contentSig = setup.getInstance().getCurrentApiHost();
- exports.getInstance().checkRouting(function(self, canCreateDiscussions) {
- if (canCreateDiscussions) {
- start(e, true);
- } else {
- if (contentSig !== self.API_HOST) {
- get(self.API_HOST, {}, "GET", {}, function() {
- });
- }
- setup.getInstance().wsClient.connect(e, null, self.WS_HOST);
- }
- });
- }, ms);
- }
- };
- /**
- * @param {!Object} e
- * @param {!Object} type
- * @return {undefined}
- */
- var connect = function(e, type) {
- var self = new Client.WSClientHandler;
- setup.getInstance().wsClient = new Client(self);
- /**
- * @param {?} url
- * @return {undefined}
- */
- self.onMessage = function(url) {
- run(url);
- };
- /**
- * @param {?} status
- * @param {?} headers
- * @return {undefined}
- */
- setup.getInstance().loginHandler = function(status, headers) {
- if (headers) {
- setup.getInstance().disconnect(null);
- setup.getInstance().connectionCallback.forEach(function(productInfo) {
- callback(null, headers, productInfo);
- });
- /** @type {!Array} */
- setup.getInstance().connectionCallback = [];
- } else {
- clearTimeout(setup.getInstance().globalTimer);
- /**
- * @return {undefined}
- */
- var login = function() {
- if (link.cachedChannels) {
- var key;
- for (key in link.cachedChannels) {
- var val = link.cachedChannels[key];
- if (val.invalidateTypingStatus()) {
- var type;
- for (type in setup.getInstance().channelHandlers) {
- var tag = setup.getInstance().channelHandlers[type];
- tag.onTypingStatusUpdated(val);
- }
- }
- }
- }
- /** @type {number} */
- setup.getInstance().globalTimer = setTimeout(function() {
- login();
- }, 1e3);
- };
- login();
- var pipelets = setup.getInstance().connectionCallback;
- /** @type {!Array} */
- setup.getInstance().connectionCallback = [];
- pipelets.forEach(function(productInfo) {
- callback(status, null, productInfo);
- });
- /** @type {!Array} */
- pipelets = [];
- }
- };
- /**
- * @param {?} p
- * @return {undefined}
- */
- self.onOpen = function(p) {
- /** @type {number} */
- setup.getInstance().loginTimer = setTimeout(function() {
- /** @type {null} */
- setup.getInstance().loginTimer = null;
- /** @type {null} */
- setup.getInstance().onLoginTimerCancel = null;
- setup.getInstance().disconnect(null);
- setup.getInstance().connectionCallback.forEach(function(productInfo) {
- callback(null, new Date("Connection timeout.", concat.LOGIN_TIMEOUT), productInfo);
- });
- /** @type {!Array} */
- setup.getInstance().connectionCallback = [];
- }, 1e4);
- /**
- * @return {undefined}
- */
- setup.getInstance().onLoginTimerCancel = function() {
- setup.getInstance().connectionCallback.forEach(function(productInfo) {
- callback(null, new Date("Connection Cancelled.", concat.REQUEST_FAILED), productInfo);
- });
- /** @type {!Array} */
- setup.getInstance().connectionCallback = [];
- };
- };
- /**
- * @param {string} e
- * @return {undefined}
- */
- self.onError = function(e) {
- if (t) {
- console.log("WSClientHandler.onError", e);
- }
- if (exports.getInstance().sessionKey) {
- start(e, true);
- } else {
- setup.getInstance().connectionCallback.forEach(function(productInfo) {
- callback(null, new Date("Websocket connection failed.", concat.WEBSOCKET_CONNECTION_FAILED), productInfo);
- });
- /** @type {!Array} */
- setup.getInstance().connectionCallback = [];
- }
- };
- /**
- * @param {string} fn
- * @return {undefined}
- */
- self.onClose = function(fn) {
- if (t) {
- console.log("WSClientHandler.onClose");
- }
- };
- exports.getInstance().checkRouting(function(self, s) {
- if (s) {
- return setup.getInstance().connectionCallback.forEach(function(productInfo) {
- callback(null, new Date("Connection routing failed.", concat.REQUEST_FAILED), productInfo);
- }), void(setup.getInstance().connectionCallback = []);
- }
- get(self.API_HOST, {}, "GET", {}, function() {
- });
- setup.getInstance().wsClient.connect(e, type, self.WS_HOST);
- });
- };
- /**
- * @param {!Object} command
- * @param {!Function} callback
- * @return {undefined}
- */
- this.sendCommand = function(command, callback) {
- if (setup.getInstance().hasLoggedIn()) {
- if (null != setup.getInstance().wsClient && setup.getInstance().wsClient.getConnectionState() === setup.getInstance().connectionState.OPEN) {
- if (command.isAckRequired()) {
- var id = command.requestId;
- var data = {
- handler : callback,
- timer : setTimeout(function() {
- callback(null, new Date("Command received no ack.", concat.ACK_TIMEOUT));
- delete transforms[id];
- }, 1e4)
- };
- transforms[id] = data;
- setup.getInstance().wsClient.send(command, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- return clearTimeout(data.timer), void callback(null, exisObj);
- }
- });
- } else {
- setup.getInstance().wsClient.send(command, callback);
- }
- } else {
- if (callback) {
- callback(null, new Date("Connection is not valid. Please reconnect.", concat.WEBSOCKET_CONNECTION_CLOSED));
- }
- }
- } else {
- if (callback) {
- callback(null, new Date("Connection should be made first.", concat.CONNECTION_REQUIRED));
- }
- }
- };
- /**
- * @param {string} width
- * @return {undefined}
- */
- this.markAsReadAll = function(width) {
- /** @type {number} */
- var idx_last = (new Date).getTime();
- if (idx_last - link.markAsReadAllLastSentAt < 1e3) {
- callback(null, new Date("MarkAsRead rate limit exceeded.", concat.MARK_AS_READ_RATE_LIMIT_EXCEEDED), width);
- } else {
- /** @type {number} */
- link.markAsReadAllLastSentAt = idx_last;
- exports.getInstance().groupChannelMarkAsReadAll(setup.getInstance().getCurrentUserId(), null, function(n, exisObj) {
- if (exisObj) {
- callback(null, exisObj, width);
- } else {
- var key;
- for (key in link.cachedChannels) {
- log(link.cachedChannels[key], 0, 0);
- }
- callback(null, null, width);
- }
- });
- }
- };
- /**
- * @param {!Object} data
- * @param {string} productInfo
- * @return {undefined}
- */
- this.markAsReadWithChannelUrls = function(data, productInfo) {
- if (Array.isArray(data)) {
- /** @type {number} */
- var idx_last = (new Date).getTime();
- if (idx_last - link.markAsReadAllLastSentAt < 1e3) {
- callback(null, new Date("MarkAsRead rate limit exceeded.", concat.MARK_AS_READ_RATE_LIMIT_EXCEEDED), productInfo);
- } else {
- /** @type {number} */
- link.markAsReadAllLastSentAt = idx_last;
- exports.getInstance().groupChannelMarkAsReadAll(setup.getInstance().getCurrentUserId(), data, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- data.forEach(function(key) {
- var resource = link.cachedChannels[key];
- if (resource) {
- log(resource, 0, 0);
- link.cachedChannels[key] = resource;
- }
- });
- callback(null, null, productInfo);
- }
- });
- }
- } else {
- callback(null, new Date("Invalid parameter.", concat.INVALID_PARAMETER), productInfo);
- }
- };
- /**
- * @param {string} id
- * @param {!Object} n
- * @param {string} data
- * @return {undefined}
- */
- this.updateCurrentUserInfoWithProfileImage = function(id, n, data) {
- var req = this;
- if (n) {
- exports.getInstance().updateCurrentUserInfoWithFile(req.getCurrentUserId(), id, n, function(data, exisObj) {
- if (exisObj) {
- callback(null, exisObj, data);
- } else {
- if (req.currentUser) {
- if (id) {
- /** @type {string} */
- req.currentUser.nickname = id;
- }
- if (n) {
- req.currentUser.profileUrl = data.profile_url;
- }
- }
- callback(req.currentUser, null, data);
- }
- });
- } else {
- req.updateCurrentUserInfo(id, null, data);
- }
- };
- /**
- * @param {string} username
- * @param {string} info
- * @param {string} state
- * @return {undefined}
- */
- this.updateCurrentUserInfo = function(username, info, state) {
- var req = this;
- exports.getInstance().updateUserInfo(req.getCurrentUserId(), username, info, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, state);
- } else {
- if (req.currentUser) {
- if (username) {
- /** @type {string} */
- req.currentUser.nickname = username;
- }
- if (info) {
- /** @type {string} */
- req.currentUser.profileUrl = info;
- }
- }
- callback(req.currentUser, null, state);
- }
- });
- };
- /**
- * @return {?}
- */
- this.getPendingGCMToken = function() {
- return this.GCMPushToken;
- };
- /**
- * @return {?}
- */
- this.getPendingAPNSToken = function() {
- return this.APNSPushToken;
- };
- /**
- * @param {string} data
- * @param {string} productInfo
- * @return {?}
- */
- this.registerGCMPushTokenForCurrentUser = function(data, productInfo) {
- var res = this;
- return data ? this.currentUser ? void exports.getInstance().registerGCMPushToken(this.getCurrentUserId(), data, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(res.pushTokenRegistrationState.ERROR, exisObj, productInfo);
- } else {
- /** @type {string} */
- res.GCMPushToken = "";
- callback(res.pushTokenRegistrationState.SUCCESS, null, productInfo);
- }
- }) : (res.GCMPushToken = data, void callback(res.pushTokenRegistrationState.PENDING, null, productInfo)) : void callback(res.pushTokenRegistrationState.ERROR, new Date("Invalid token", concat.INVALID_PARAMETER), productInfo);
- };
- /**
- * @param {?} data
- * @param {string} productInfo
- * @return {undefined}
- */
- this.unregisterGCMPushTokenForCurrentUser = function(data, productInfo) {
- if (data) {
- exports.getInstance().unregisterGCMPushToken(this.getCurrentUserId(), data, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, productInfo);
- });
- } else {
- callback(null, new Date("Invalid token", concat.INVALID_PARAMETER), productInfo);
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.unregisterGCMPushTokenAllForCurrentUser = function(productInfo) {
- exports.getInstance().unregisterGCMPushTokenAll(this.getCurrentUserId(), function(n, endNow) {
- callback(null, endNow || null, productInfo);
- });
- };
- /**
- * @param {!Function} data
- * @param {string} productInfo
- * @return {?}
- */
- this.registerAPNSPushTokenForCurrentUser = function(data, productInfo) {
- var res = this;
- return data ? this.currentUser ? void exports.getInstance().registerAPNSPushToken(this.getCurrentUserId(), data, function(canCreateDiscussions, exisObj) {
- if (exisObj) {
- callback(res.pushTokenRegistrationState.ERROR, exisObj, productInfo);
- } else {
- /** @type {string} */
- res.APNSPushToken = "";
- callback(res.pushTokenRegistrationState.SUCCESS, null, productInfo);
- }
- }) : (res.APNSPushToken = data, void callback(res.pushTokenRegistrationState.PENDING, null, productInfo)) : void callback(res.pushTokenRegistrationState.ERROR, new Date("Invalid token", concat.INVALID_PARAMETER), productInfo);
- };
- /**
- * @param {?} data
- * @param {string} productInfo
- * @return {undefined}
- */
- this.unregisterAPNSPushTokenForCurrentUser = function(data, productInfo) {
- if (data) {
- exports.getInstance().unregisterAPNSPushToken(this.getCurrentUserId(), data, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, productInfo);
- });
- } else {
- callback(null, new Date("Invalid token", concat.INVALID_PARAMETER), productInfo);
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.unregisterAPNSPushTokenAllForCurrentUser = function(productInfo) {
- exports.getInstance().unregisterAPNSPushTokenAll(this.getCurrentUserId(), function(n, endNow) {
- callback(null, endNow || null, productInfo);
- });
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.unregisterPushTokenAllForCurrentUser = function(productInfo) {
- exports.getInstance().unregisterPushTokenAll(this.getCurrentUserId(), function(n, endNow) {
- callback(null, endNow || null, productInfo);
- });
- };
- /**
- * @param {undefined} n2
- * @param {number} t
- * @param {number} f
- * @param {number} m
- * @param {number} v
- * @param {string} s
- * @param {string} k
- * @return {undefined}
- */
- this.setDoNotDisturb = function(n2, t, f, m, v, s, k) {
- if (t < 0 || t > 23 || f < 0 || f > 59 || m < 0 || m > 23 || v < 0 || v > 59) {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), k);
- } else {
- exports.getInstance().setDoNotDisturb(this.getCurrentUserId(), n2, t, f, m, v, s, function(e, n) {
- if (n) {
- callback(null, n, k);
- } else {
- var data = {
- doNotDisturbOn : e.do_not_disturb,
- startHour : e.start_hour,
- startMin : e.start_min,
- endHour : e.end_hour,
- endMin : e.end_min,
- timezone : e.timezone
- };
- callback(data, null, k);
- }
- });
- }
- };
- /**
- * @param {string} productInfo
- * @return {undefined}
- */
- this.getDoNotDisturb = function(productInfo) {
- exports.getInstance().getDoNotDisturb(this.getCurrentUserId(), function(e, exisObj) {
- if (exisObj) {
- callback(null, exisObj, productInfo);
- } else {
- var data = {
- doNotDisturbOn : e.do_not_disturb,
- startHour : e.start_hour,
- startMin : e.start_min,
- endHour : e.end_hour,
- endMin : e.end_min,
- timezone : e.timezone
- };
- callback(data, null, productInfo);
- }
- });
- };
- /**
- * @param {!Object} data
- * @param {!Function} user
- * @return {undefined}
- */
- this.blockUser = function(data, user) {
- if ("object" == typeof data) {
- this.blockUserWithUserId(data.userId, user);
- } else {
- callback(null, new Date("You have to pass user object.", concat.INVALID_PARAMETER), user);
- }
- };
- /**
- * @param {?} user_id
- * @param {string} destination
- * @return {undefined}
- */
- this.blockUserWithUserId = function(user_id, destination) {
- if (this.getCurrentUserId() !== user_id) {
- exports.getInstance().blockUser(this.getCurrentUserId(), user_id, function(enlivenedObjects, exisObj) {
- if (exisObj) {
- callback(null, exisObj, destination);
- } else {
- callback(new client(enlivenedObjects), null, destination);
- }
- });
- } else {
- callback(null, new Date("You can not block yourself.", concat.INVALID_PARAMETER), destination);
- }
- };
- /**
- * @param {!Object} options
- * @param {!Function} arg
- * @return {undefined}
- */
- this.unblockUser = function(options, arg) {
- if ("object" == typeof options) {
- this.unblockUserWithUserId(options.userId, arg);
- } else {
- callback(null, new Date("You have to pass user object.", concat.INVALID_PARAMETER), arg);
- }
- };
- /**
- * @param {?} d
- * @param {string} idx
- * @return {undefined}
- */
- this.unblockUserWithUserId = function(d, idx) {
- if (this.getCurrentUserId() !== d) {
- exports.getInstance().unblockUser(this.getCurrentUserId(), d, function(canCreateDiscussions, endNow) {
- callback(null, endNow || null, idx);
- });
- } else {
- callback(null, new Date("You can not unblock yourself.", concat.INVALID_PARAMETER), idx);
- }
- };
- /**
- * @param {string} event
- * @param {string} source
- * @return {undefined}
- */
- this.addFriends = function(event, source) {
- if (Array.isArray(event)) {
- exports.getInstance().addFriends(this.getCurrentUserId(), event, function(contributor, exisObj) {
- if (exisObj) {
- callback(null, exisObj, source);
- } else {
- var identifierPositions = contributor.users.map(function(options) {
- return new client(options);
- });
- callback(identifierPositions, null, source);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), source);
- }
- };
- /**
- * @param {?} val
- * @param {boolean} k
- * @return {undefined}
- */
- this.deleteFriends = function(val, k) {
- if (Array.isArray(val)) {
- exports.getInstance().deleteFriends(this.getCurrentUserId(), val, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, k);
- } else {
- callback(identifierPositions, null, k);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), k);
- }
- };
- /**
- * @param {?} callback
- * @param {undefined} id
- * @return {undefined}
- */
- this.deleteFriend = function(callback, id) {
- if ("string" == typeof callback) {
- this.deleteFriends([callback], id);
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), id);
- }
- };
- /**
- * @param {undefined} p
- * @param {string} width
- * @return {undefined}
- */
- this.uploadFriendDiscoveries = function(p, width) {
- /** @type {boolean} */
- var t = true;
- var i;
- for (i in p) {
- if (!p[i].hasOwnProperty("friendDiscoveryKey")) {
- /** @type {boolean} */
- t = false;
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), width);
- break;
- }
- }
- if (t) {
- exports.getInstance().uploadFriendDiscoveries(this.getCurrentUserId(), p, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, width);
- } else {
- callback(identifierPositions, null, width);
- }
- });
- }
- };
- /**
- * @param {?} fp
- * @param {boolean} str
- * @return {undefined}
- */
- this.deleteFriendDiscoveries = function(fp, str) {
- if (Array.isArray(fp)) {
- exports.getInstance().deleteFriendDiscoveries(this.getCurrentUserId(), fp, function(identifierPositions, exisObj) {
- if (exisObj) {
- callback(null, exisObj, str);
- } else {
- callback(identifierPositions, null, str);
- }
- });
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), str);
- }
- };
- /**
- * @param {?} q
- * @param {undefined} hash
- * @return {undefined}
- */
- this.deleteFriendDiscovery = function(q, hash) {
- if ("string" == typeof q) {
- this.deleteFriendDiscoveries([q], hash);
- } else {
- callback(null, new Date("Invalid arguments.", concat.INVALID_PARAMETER), hash);
- }
- };
- /**
- * @param {string} p
- * @param {string} c
- * @return {?}
- */
- this.getFriendChangeLogsByToken = function(p, c) {
- if ("function" == typeof p && (c = p, p = null), "function" != typeof c) {
- return null;
- }
- exports.getInstance().getFriendChangeLogsByToken(this.getCurrentUserId(), p, function(result, exisObj) {
- if (exisObj) {
- callback(null, exisObj, c);
- } else {
- var s = result.updated.map(function($scope) {
- return new client(client.build($scope.user_id, $scope.nickname, $scope.profile_url, $scope.is_online, $scope.last_seen_at, $scope.metadata, $scope.is_active, $scope.friend_discovery_key, $scope.friend_name));
- });
- var deleted = result.deleted;
- var courseSections = result.has_more;
- var token = result.next;
- callback({
- updatedUsers : s,
- deletedUserIds : deleted,
- hasMore : courseSections,
- token : token
- }, null, c);
- }
- });
- };
- /**
- * @return {?}
- */
- this.createFriendListQuery = function() {
- return new transform;
- };
- };
- /** @type {null} */
- var ue = null;
- return setup.getInstance = function() {
- return null === ue ? null : ue;
- }, {
- SendBird : setup
- };
- };
- /** @type {null} */
- var self = null;
- return function() {
- /**
- * @param {!Object} options
- * @return {?}
- */
- var Class = function(options) {
- if (options.newInstance || !self) {
- var fhirball = new init;
- self = new fhirball.SendBird(options);
- } else {
- if (self && options.appId !== self.getApplicationId() && self.getConnectionState() === self.connectionState.CLOSED) {
- fhirball = new init;
- self = new fhirball.SendBird(options);
- }
- }
- return self;
- };
- return Class.getInstance = function() {
- return null === self ? null : self;
- }, Class.version = "3.0.69", {
- SendBird : Class
- };
- }().SendBird;
- }();
- },
- "./node_modules/websocket/lib/browser.js" : function(module, metadata, packageSuccess) {
- var global = function() {
- return this;
- }();
- var ariaDomEvent = global.WebSocket || global.MozWebSocket;
- var ELECTRON_VERSION = packageSuccess("./node_modules/websocket/lib/version.js");
- module.exports = {
- w3cwebsocket : ariaDomEvent ? function(event, templatesWrapper) {
- return templatesWrapper ? new ariaDomEvent(event, templatesWrapper) : new ariaDomEvent(event);
- } : null,
- version : ELECTRON_VERSION
- };
- },
- "./node_modules/websocket/lib/version.js" : function(u, name, api) {
- u.exports = api("./node_modules/websocket/package.json").version;
- },
- "./node_modules/websocket/package.json" : function(module) {
- module.exports = {
- name : "websocket",
- description : "Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",
- keywords : ["websocket", "websockets", "socket", "networking", "comet", "push", "RFC-6455", "realtime", "server", "client"],
- version : "1.0.24",
- repository : {
- type : "git",
- url : "https://github.com/theturtle32/WebSocket-Node.git"
- },
- homepage : "https://github.com/theturtle32/WebSocket-Node",
- engines : {
- node : ">=0.8.0"
- },
- dependencies : {
- debug : "^2.2.0",
- nan : "^2.3.3",
- "typedarray-to-buffer" : "^3.1.2",
- yaeti : "^0.0.6"
- },
- devDependencies : {
- "buffer-equal" : "^1.0.0",
- faucet : "^0.0.1",
- gulp : "git+https://github.com/gulpjs/gulp.git#4.0",
- "gulp-jshint" : "^2.0.4",
- "jshint-stylish" : "^2.2.1",
- jshint : "^2.0.0",
- tape : "^4.0.1"
- },
- config : {
- verbose : false
- },
- scripts : {
- install : "(node-gyp rebuild 2> builderror.log) || (exit 0)",
- test : "faucet test/unit",
- gulp : "gulp"
- },
- main : "index",
- directories : {
- lib : "./lib"
- },
- browser : "lib/browser.js",
- license : "Apache-2.0"
- };
- },
- "./node_modules/xhr2/lib/browser.js" : function(module, data) {
- /** @type {function(new:XMLHttpRequest): ?} */
- module.exports = XMLHttpRequest;
- }
- }]);
Add Comment
Please, Sign In to add comment