|
|
@@ -49,7 +49,7 @@ function SlackChan(chanData, slackData) {
|
|
|
/** @type {boolean} */
|
|
|
this.isMember = chanData["is_member"];
|
|
|
/** @type {number} */
|
|
|
- this.lastRead = chanData["last_read"];
|
|
|
+ this.lastRead = parseFloat(chanData["last_read"]);
|
|
|
/** @type {Object.<string, SlackBot|SlackUser>} */
|
|
|
this.members = {};
|
|
|
if (chanData["members"]) for (var i =0, nbMembers = chanData["members"].length; i < nbMembers; i++) {
|
|
|
@@ -108,7 +108,7 @@ function SlackGroup(slack, groupData) {
|
|
|
/** @type {boolean} */
|
|
|
this.archived = groupData["is_archived"];
|
|
|
/** @type {number} */
|
|
|
- this.lastRead = groupData["last_read"];
|
|
|
+ this.lastRead = parseFloat(groupData["last_read"]);
|
|
|
/** @type {string|undefined} */
|
|
|
this.topic;
|
|
|
/** @type {number|undefined} */
|
|
|
@@ -146,7 +146,7 @@ function SlackIms(user, imsData) {
|
|
|
/** @type {SlackUser|SlackBot} */
|
|
|
this.user = user;
|
|
|
/** @type {number} */
|
|
|
- this.lastRead = imsData["last_read"];
|
|
|
+ this.lastRead = parseFloat(imsData["last_read"]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -210,16 +210,6 @@ function SlackBot(botData) {
|
|
|
this.ims = null;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @constructor
|
|
|
-**/
|
|
|
-function SlackHistory(target) {
|
|
|
- this.id = target.id;
|
|
|
- this.target = target;
|
|
|
- this.v = 0;
|
|
|
- this.messages = [];
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @constructor
|
|
|
**/
|
|
|
@@ -238,8 +228,6 @@ function SlackData(slack) {
|
|
|
this.self = null;
|
|
|
/** @type {Object.<string, SlackBot>} */
|
|
|
this.bots = {};
|
|
|
- // channel/ims id -> array of events
|
|
|
- this.history = {};
|
|
|
|
|
|
/**
|
|
|
* Node serv handler
|
|
|
@@ -272,14 +260,6 @@ SlackTeam.prototype.toStatic = function() {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-SlackHistory.prototype.update = function(messages) {
|
|
|
- // TODO
|
|
|
-};
|
|
|
-
|
|
|
-SlackHistory.prototype.getUpdates = function(knownVersion) {
|
|
|
- // TODO
|
|
|
-};
|
|
|
-
|
|
|
/**
|
|
|
* @return {Object}
|
|
|
**/
|
|
|
@@ -412,42 +392,6 @@ SlackData.prototype.updateStatic = function(data) {
|
|
|
if (!this.slack) {
|
|
|
return;
|
|
|
}
|
|
|
- /*
|
|
|
- var fetchHistory = {}
|
|
|
- ,doFetch = false;
|
|
|
- for (var i in this.channels)
|
|
|
- if (!this.history[i]) {
|
|
|
- doFetch = true;
|
|
|
- fetchHistory[i] = this.channels[i];
|
|
|
- }
|
|
|
- for (var i in this.users)
|
|
|
- if (!this.history[this.users[i].ims.id]) {
|
|
|
- doFetch = true;
|
|
|
- fetchHistory[i] = this.users[i].ims.id;
|
|
|
- }
|
|
|
- //TODO fetch group history
|
|
|
- if (!doFetch)
|
|
|
- callback();
|
|
|
- else for (var i in fetchHistory) {
|
|
|
- var _this = this;
|
|
|
- this.slack.fetchHistory(i, function(currentUpdated, data) {
|
|
|
- if (data != null) {
|
|
|
- _this.setHistory(fetchHistory[currentUpdated], data);
|
|
|
- fetchHistory[currentUpdated] = null;
|
|
|
- for (var i in fetchHistory) {
|
|
|
- if (fetchHistory[i])
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- */
|
|
|
-};
|
|
|
-
|
|
|
-SlackData.prototype.setHistory = function(target, data) {
|
|
|
- if (!this.history[target.id])
|
|
|
- this.history[target.id] = new SlackHistory(target);
|
|
|
- this.history[target.id].update(data);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -473,19 +417,6 @@ SlackData.prototype.getMember = function(mId) {
|
|
|
return this.users[mId] || this.bots[mId] || null;
|
|
|
};
|
|
|
|
|
|
-/**
|
|
|
- * @param {number} knownVersion
|
|
|
- * @return {Object}
|
|
|
-**/
|
|
|
-SlackData.prototype.buildLive = function(knownVersion) {
|
|
|
- var res = {};
|
|
|
- //TODO include presence/typing stream
|
|
|
- for (var i in this.history)
|
|
|
- if (this.history[i].v > knownVersion)
|
|
|
- res[i] = this.history[i].getUpdates(knownVersion);
|
|
|
- return res;
|
|
|
-};
|
|
|
-
|
|
|
/** @return {Object} */
|
|
|
SlackData.prototype.buildStatic = function() {
|
|
|
var res = {
|
|
|
@@ -515,20 +446,21 @@ SlackData.prototype.buildStatic = function() {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * @param {Object} msg
|
|
|
+ * @return {boolean}
|
|
|
+**/
|
|
|
+SlackData.prototype.onMessage = function(msg) {
|
|
|
+ //TODO
|
|
|
+ return false;
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* @param {number} knownVersion
|
|
|
- * @return {{live: (Object|undefined), static: (Object|undefined)}}
|
|
|
+ * @return {Object|undefined}
|
|
|
**/
|
|
|
SlackData.prototype.getUpdates = function(knownVersion) {
|
|
|
- var res = {};
|
|
|
-
|
|
|
- if (this.liveV > knownVersion) {
|
|
|
- res["live"] = this.buildLive(knownVersion);
|
|
|
- }
|
|
|
- if (this.staticV > knownVersion) {
|
|
|
- res["static"] = this.buildStatic();
|
|
|
- }
|
|
|
- return res;
|
|
|
+ return (this.staticV > knownVersion) ? this.buildStatic() : undefined;
|
|
|
};
|
|
|
|
|
|
/** @suppress {undefinedVars,checkTypes} */
|