1
0
Эх сурвалжийг харах

[bgufix] add channel members
[bugfix] comments on message does not have users
[bugfix] NaN version

B Thibault 8 жил өмнө
parent
commit
bf05227892

+ 5 - 3
srv/src/slack.js

@@ -109,7 +109,8 @@ Slack.prototype.connect = function(cb) {
                 team: body["team"],
                 users: body["users"],
                 bots: body["bots"],
-                self: body["self"]
+                self: body["self"],
+                channels: body["channels"]
             }, Date.now());
             _this.connectRtm(body.url);
         }
@@ -639,6 +640,7 @@ Slack.prototype.sendMsg = function(channel, text, attachments) {
             +"?token=" +this.token
             +"&channel=" +channel.remoteId
             +"&text=" +text.join("\n")
+            +"&link_names=true"
             + (attachments ? ("&attachments=" +encodeURIComponent(JSON.stringify(attachments))) : "")
             +"&as_user=true");
     } else {
@@ -753,8 +755,8 @@ Slack.prototype.fetchHistory = function(target, cb, count, firstMsgId) {
             if (!target.pins || target.pins.length !== resp["pin_count"]) {
                 if (!resp["pin_count"]) {
                     target.pins = [];
-                    target.v = Math.max(target.v, Date.now());
-                    _this.data.staticV = Math.max(_this.data.staticV, target.v);
+                    target.version = Math.max(target.version, Date.now());
+                    _this.data.staticV = Math.max(_this.data.staticV, target.version);
                 } else {
                     _this.fetchPinned(target);
                 }

+ 6 - 2
srv/src/slackHistory.js

@@ -47,8 +47,12 @@ SlackHistory.prototype.prepareMessage = function(ev, targetId) {
 }
 
 SlackHistory.prototype.messageFactory = function(ev, ts) {
-    if (!ev["user"])
-        ev["user"] = ev["bot_id"];
+    if (!ev["user"]) {
+        if (ev["bot_id"])
+            ev["user"] = ev["bot_id"];
+        if (ev["comment"] && ev["comment"]["user"])
+            ev["user"] = ev["comment"]["user"];
+    }
     ev["user"] = this.idPrefix +ev["user"];
     if (ev["reactions"]) {
         ev["reactions"].forEach((r) => {