|
@@ -0,0 +1,60 @@
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @constructor
|
|
|
|
|
+**/
|
|
|
|
|
+function SlackHistory(target) {
|
|
|
|
|
+ this.id = target.id;
|
|
|
|
|
+ this.target = target;
|
|
|
|
|
+ this.v = 0;
|
|
|
|
|
+ this.messages = [];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+SlackData.prototype.setHistory = function(target, data) {
|
|
|
|
|
+ if (!this.history[target.id])
|
|
|
|
|
+ this.history[target.id] = new SlackHistory(target);
|
|
|
|
|
+ this.history[target.id].update(data);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+SlackHistory.prototype.update = function(messages) {
|
|
|
|
|
+ // TODO
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+SlackHistory.prototype.getUpdates = function(knownVersion) {
|
|
|
|
|
+ // TODO
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+module.exports.SlackHistory = SlackHistory;
|
|
|
|
|
+
|