|
|
@@ -120,7 +120,7 @@ Slack.prototype.connect = function(cb) {
|
|
|
var _this = this;
|
|
|
|
|
|
this.connected = undefined;
|
|
|
- httpsRequest(SLACK_ENDPOINT +GETAPI.rtmStart +"?token=" +this.token, (status, body) => {
|
|
|
+ httpsRequest(SLACK_ENDPOINT +GETAPI.rtmStart +"?batch_presence_aware=1&token=" +this.token, (status, body) => {
|
|
|
if (!body || !body.ok) {
|
|
|
_this.error = "Slack API error";
|
|
|
_this.connected = false;
|
|
|
@@ -321,6 +321,7 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
_this.unstackPendingMessages();
|
|
|
_this.ping();
|
|
|
MultiChatManager.onCtxUpdated(_this);
|
|
|
+ _this.getPresenceForAll();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
@@ -353,6 +354,13 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+Slack.prototype.getPresenceForAll = function() {
|
|
|
+ var userIds = {};
|
|
|
+ for (var i in this.data.users)
|
|
|
+ userIds[this.data.users[i].remoteId] = null;
|
|
|
+ this.send('{"id":' +this.rtmId++ +',"type":"presence_sub","ids":' +JSON.stringify(Object.keys(userIds))+'}');
|
|
|
+};
|
|
|
+
|
|
|
Slack.prototype.removeExpiredMsgs = function(msg) {
|
|
|
// TODO retry
|
|
|
};
|
|
|
@@ -408,7 +416,7 @@ Slack.prototype.connectRtm = function(url, cb) {
|
|
|
url = url.substr(protocol.length);
|
|
|
url = protocol +url.substr(0, url.indexOf('/'))+
|
|
|
"/?flannel=1&token=" +this.token+
|
|
|
- "&start_args=" +encodeURIComponent("?simple_latest=true&presence_sub=true&canonical_avatars=true")
|
|
|
+ "&start_args=" +encodeURIComponent("?simple_latest=true&batch_presence_aware=1&canonical_avatars=true")
|
|
|
this.rtm = new WebSocket(url);
|
|
|
this.rtm.on("message", function(msg) {
|
|
|
if (!_this.connected && cb) {
|