فهرست منبع

[bugfix][slack] api no longer send lastMsg information
[quickfix] jshint

B Thibault 8 سال پیش
والد
کامیت
eb9152aeb8
12فایلهای تغییر یافته به همراه172 افزوده شده و 103 حذف شده
  1. 8 2
      cli/data.js
  2. 1 2
      cli/dom.js
  3. 1 0
      cli/ui.js
  4. 3 3
      cli/workflow.js
  5. 37 37
      srv/public/slack.min.js
  6. 3 5
      srv/src/context.js
  7. 2 4
      srv/src/httpServ.js
  8. 4 0
      srv/src/message.js
  9. 1 2
      srv/src/room.js
  10. 86 44
      srv/src/slack.js
  11. 17 4
      srv/src/slackData.js
  12. 9 0
      srv/src/slackManager.js

+ 8 - 2
cli/data.js

@@ -190,8 +190,14 @@ function onMsgReceived(ctx, chan, msg) {
 function markRoomAsRead(room) {
     var highlightIndex = HIGHLIGHTED_CHANS.indexOf(room);
     if (room.lastMsg > room.lastRead) {
-        sendReadMArker(room, room.lastMsg);
-        room.lastRead = room.lastMsg;
+        var history = DATA.history[room.id];
+        if (history) {
+            var lastMsg = history.last();
+            if (lastMsg) {
+                sendReadMarker(room, lastMsg.id);
+                room.lastRead = lastMsg.ts;
+            }
+        }
     }
     if (highlightIndex >= 0) {
         HIGHLIGHTED_CHANS.splice(highlightIndex, 1);

+ 1 - 2
cli/dom.js

@@ -86,8 +86,7 @@ function createImsListItem(ims) {
 
     if (ims.lastMsg > ims.lastRead) {
         dom.classList.add(R.klass.unread);
-        if (HIGHLIGHTED_CHANS.indexOf(ims) >= 0)
-            dom.classList.add(R.klass.unreadHi);
+        dom.classList.add(R.klass.unreadHi); // Always HI on private message
     }
     return dom;
 }

+ 1 - 0
cli/ui.js

@@ -46,6 +46,7 @@ function onContextUpdated() {
                         priv.push(chanListItem);
                 }
             }
+            //FIXME else remove
         } else {
             if ((chanListItem = createChanListItem(chan))) {
                 if (chan.starred)

+ 3 - 3
cli/workflow.js

@@ -304,11 +304,11 @@ function removeMsg(chan, msg) {
 
 /**
  * @param {Room} chan
- * @param {number} ts
+ * @param {string} id
 **/
-function sendReadMArker(chan, ts) {
+function sendReadMarker(chan, id) {
     var xhr = new XMLHttpRequest();
-    var url = 'api/markread?room=' +chan.id +"&ts=" +ts;
+    var url = 'api/markread?room=' +chan.id +"&id=" +id;
     xhr.open('POST', url, true);
     xhr.send(null);
 }

+ 37 - 37
srv/public/slack.min.js

@@ -1,49 +1,49 @@
 "use strict";(function(){
 var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function ba(a){this.a=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.T=a.category}function ca(){this.ga={};this.w=[];this.version=0}
-ca.prototype.update=function(a,b){this.ga=JSON.parse(a.emoji_use);a.highlight_words?this.w=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.w=a.highlights);this.version=Math.max(this.version,b)};function da(){this.b=null;this.j={};this.m={};this.self=null;this.a={version:0,data:{}};this.i={version:0,data:{}};this.o={};this.B=0}
+ca.prototype.update=function(a,b){this.ga=JSON.parse(a.emoji_use);a.highlight_words?this.w=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.w=a.highlights);this.version=Math.max(this.version,b)};function da(){this.b=null;this.j={};this.m={};this.self=null;this.a={version:0,data:{}};this.i={version:0,data:{}};this.o={};this.D=0}
 function ea(a,b,c){var d=d||"";b.team&&(a.b||(a.b=new aa(b.team.id)),a.b.update(b.team,c));if(b.users)for(var e=0,g=b.users.length;e<g;e++){var f=a.m[d+b.users[e].id];f||(f=a.m[d+b.users[e].id]=new fa(b.users[e].id));f.update(b.users[e],c)}if(b.channels)for(e=0,g=b.channels.length;e<g;e++){f=a.j[d+b.channels[e].id];if(!f){var f=a.j,n=d+b.channels[e].id;var h=b.channels[e];h=h.pv?new r(h.id,a.m[h.user]):new t(h.id);f=f[n]=h}f.update(b.channels[e],a,c,d)}b.emojis&&(a.a.data=b.emojis,a.a.version=c);
-if(void 0!==b.commands){a.i.data={};for(e in b.commands)a.i.data[e]=new ba(b.commands[e]);a.i.version=c}a.B=Math.max(a.B,c);b.self&&(a.self=a.m[d+b.self.id]||null,a.self&&b.self.prefs?(a.self.N||(a.self.N=new ca),a.self.N.update(b.self.prefs,c)):a.B=0)}"undefined"!==typeof module&&(module.I.Ta=da,module.I.Ua=aa,module.I.Wa=ba);function t(a){this.id=a;this.J=!1;this.C=0;this.A=-1;this.m={};this.version=0}
-t.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.Y=a.is_archived);void 0!==a.is_member&&(this.i=a.is_member);void 0!==a.last_read&&(this.C=Math.max(parseFloat(a.last_read),this.C));void 0!==a.last_msg&&(this.A=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);a.latest&&(this.A=parseFloat(a.latest.ts));void 0!==a.is_starred&&(this.J=a.is_starred);if(a.members&&(this.m={},a.members))for(var e=0,g=a.members.length;e<g;e++){var f=
-b.m[d+a.members[e]];this.m[f.id]=f;f.j[this.id]=this}this.version=Math.max(this.version,c)};function r(a,b){t.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.na=this}r.prototype=Object.create(t.prototype);r.prototype.constructor=r;"undefined"!==typeof module&&(module.I.bb=t,module.I.ab=r);function x(a,b){this.H=a.user;this.username=a.username;this.id=a.id||a.ts;this.l=parseFloat(a.ts);this.text="";this.s=[];this.i=this.F=this.J=!1;this.D={};this.version=b;this.update(a,b)}function B(a,b){x.call(this,a,b)}function C(a,b){x.call(this,a,b)}
-x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.J=!!a.is_starred,this.F=void 0===a.edited?!1:a.edited,this.i=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.D=c}}else this.i=!0;this.version=b};function D(a,b,c,d){this.id="string"===typeof a?a:a.id;this.a=[];this.i=b;c&&ga(this,c,d)}
+if(void 0!==b.commands){a.i.data={};for(e in b.commands)a.i.data[e]=new ba(b.commands[e]);a.i.version=c}b.self&&(a.self=a.m[d+b.self.id]||null,b.self.prefs&&(a.self.N||(a.self.N=new ca),a.self.N.update(b.self.prefs,c)));a.D=Math.max(a.D,c)}"undefined"!==typeof module&&(module.H.Ta=da,module.H.Ua=aa,module.H.Wa=ba);function t(a){this.id=a;this.J=!1;this.A=0;this.m={};this.version=0}
+t.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.Y=a.is_archived);void 0!==a.is_member&&(this.i=a.is_member);void 0!==a.last_read&&(this.A=Math.max(parseFloat(a.last_read),this.A));void 0!==a.last_msg&&(this.I=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);void 0!==a.is_starred&&(this.J=a.is_starred);if(a.members&&(this.m={},a.members))for(var e=0,g=a.members.length;e<g;e++){var f=b.m[d+a.members[e]];this.m[f.id]=
+f;f.j[this.id]=this}this.version=Math.max(this.version,c)};function r(a,b){t.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.na=this}r.prototype=Object.create(t.prototype);r.prototype.constructor=r;"undefined"!==typeof module&&(module.H.bb=t,module.H.ab=r);function x(a,b){this.G=a.user;this.username=a.username;this.id=a.id||a.ts;this.l=parseFloat(a.ts);this.text="";this.s=[];this.i=this.C=this.J=!1;this.B={};this.version=b;this.update(a,b)}function B(a,b){x.call(this,a,b)}function C(a,b){x.call(this,a,b)}
+x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.J=!!a.is_starred,this.C=void 0===a.edited?!1:a.edited,this.i=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.B=c}}else this.i=!0;this.version=b};function D(a,b,c,d){this.id="string"===typeof a?a:a.id;this.a=[];this.i=b;c&&ga(this,c,d)}
 function ga(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ha(a)}D.prototype.b=function(a,b){return!0===a.isMeMessage?new B(a,b):!0===a.isNotice?new C(a,b):new x(a,b)};D.prototype.push=function(a,b){for(var c,d=!1,e,g=0,f=this.a.length;g<f;g++)if(c=this.a[g],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.l);for(;this.a.length>this.i;)this.a.shift();return e||0};function ia(a){return a.a[a.a.length-1]}
-function ja(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}function ha(a){a.a.sort(function(a,c){return a.l-c.l})}B.prototype=Object.create(x.prototype);B.prototype.constructor=B;C.prototype=Object.create(x.prototype);C.prototype.constructor=C;"undefined"!==typeof module&&(module.I={Ya:x,Xa:B,$a:C,cb:D});function fa(a){this.id=a;this.j={};this.na=this.N=null;this.version=0}fa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Da=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.presence&&(this.a="away"!==a.presence);void 0!==a.isPresent&&(this.a=a.isPresent);a.isBot&&(this.Oa=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.I.Va=fa);function ka(){this.a=[]}ka.prototype.push=function(a){this.a.push(a)};function la(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ma(a.a[c]))return a.a[c];return null}function na(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],g;for(g in e.j)if(!0===b(e.j[g],g))return}}function oa(a){for(var b=E.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function G(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].j[b])return a.a[c];return null}
-function H(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}function pa(a){for(var b=E.context,c=[],d=0,e=b.a.length;d<e;d++){var g=b.a[d].j,f;for(f in g)a&&!a(g[f],b.a[d],f)||c.push(f)}return c}function I(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].m[a];if(e)return e}return null}function qa(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++)if(b.a[c].self.id===a)return!0;return!1}"undefined"!==typeof module&&(module.I.Za=ka);var J={},L;function ra(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(J.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}L=J[c];console.log("Loading language pack: "+c);if(L.c)for(var d in L.c)document.getElementById(d).textContent=L.c[d]};J.fr={Sa:"Utilisateur inconnu",Ra:"Channel inconnu",Ha:"Nouveau message",Ga:"Reseau",Ia:"(visible seulement par vous)",J:"Favoris",j:"Discutions",Ka:"Discutions priv\u00e9es",ok:"Ok",Ea:"Annuler",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"hier, "+a.toLocaleTimeString():a.toLocaleString()},c:{fileUploadCancel:"Annuler",
-neterror:"Impossible de se connecter au chat !"}};J.fr.F=function(a){return"(edit&eacute; "+J.fr.V(a)+")"};J.en={Sa:"Unknown member",Ra:"Unknown channel",Ha:"New message",Ga:"Network",Ia:"(only visible to you)",J:"Starred",j:"Channels",Ka:"Direct messages",ok:"Ok",Ea:"Cancel",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"yesterday, "+a.toLocaleTimeString():a.toLocaleString()},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !"}};
-J.en.F=function(a){return"(edited "+J.en.V(a)+")"};var sa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.R=c;this.f=null;this.h=[];this.a=d||"";this.ba="<"===this.a;this.la="*"===this.a;this.ra="_"===this.a;this.ca="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.W=":"===this.a;this.ma="`"===this.a;this.Ba="```"===this.a;this.oa="\n"===this.a;this.qa=void 0!==d&&-1!==m.w.indexOf(d);this.g=b;this.da=null;this.b=this.oa||this.qa?c+d.length-1:!1;this.qa&&(this.f=new a(this),this.h.push(this.f),this.f.text=d)}
+function ja(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}function ha(a){a.a.sort(function(a,c){return a.l-c.l})}B.prototype=Object.create(x.prototype);B.prototype.constructor=B;C.prototype=Object.create(x.prototype);C.prototype.constructor=C;"undefined"!==typeof module&&(module.H={Ya:x,Xa:B,$a:C,cb:D});function fa(a){this.id=a;this.j={};this.na=this.N=null;this.version=0}fa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Da=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.presence&&(this.a="away"!==a.presence);void 0!==a.isPresent&&(this.a=a.isPresent);a.isBot&&(this.Oa=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.H.Va=fa);function ka(){this.a=[]}ka.prototype.push=function(a){this.a.push(a)};function la(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ma(a.a[c]))return a.a[c];return null}function na(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],g;for(g in e.j)if(!0===b(e.j[g],g))return}}function oa(a){for(var b=E.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function G(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].j[b])return a.a[c];return null}
+function H(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}function pa(a){for(var b=E.context,c=[],d=0,e=b.a.length;d<e;d++){var g=b.a[d].j,f;for(f in g)a&&!a(g[f],b.a[d],f)||c.push(f)}return c}function I(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].m[a];if(e)return e}return null}function qa(a){for(var b=E.context,c=0,d=b.a.length;c<d;c++)if(b.a[c].self.id===a)return!0;return!1}"undefined"!==typeof module&&(module.H.Za=ka);var K={},L;function ra(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(K.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}L=K[c];console.log("Loading language pack: "+c);if(L.c)for(var d in L.c)document.getElementById(d).textContent=L.c[d]};K.fr={Sa:"Utilisateur inconnu",Ra:"Channel inconnu",Ha:"Nouveau message",Ga:"Reseau",Ia:"(visible seulement par vous)",J:"Favoris",j:"Discutions",Ka:"Discutions priv\u00e9es",ok:"Ok",Ea:"Annuler",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"hier, "+a.toLocaleTimeString():a.toLocaleString()},c:{fileUploadCancel:"Annuler",
+neterror:"Impossible de se connecter au chat !"}};K.fr.C=function(a){return"(edit&eacute; "+K.fr.V(a)+")"};K.en={Sa:"Unknown member",Ra:"Unknown channel",Ha:"New message",Ga:"Network",Ia:"(only visible to you)",J:"Starred",j:"Channels",Ka:"Direct messages",ok:"Ok",Ea:"Cancel",V:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"yesterday, "+a.toLocaleTimeString():a.toLocaleString()},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !"}};
+K.en.C=function(a){return"(edited "+K.en.V(a)+")"};var sa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.R=c;this.f=null;this.h=[];this.a=d||"";this.ba="<"===this.a;this.la="*"===this.a;this.ra="_"===this.a;this.ca="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.W=":"===this.a;this.ma="`"===this.a;this.Ba="```"===this.a;this.oa="\n"===this.a;this.qa=void 0!==d&&-1!==m.w.indexOf(d);this.g=b;this.da=null;this.b=this.oa||this.qa?c+d.length-1:!1;this.qa&&(this.f=new a(this),this.h.push(this.f),this.f.text=d)}
 function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153".indexOf(a)}function d(a){a=a||h;for(var c=0,e=a.h.length;c<e;c++){var k=
 a.h[c];if(k instanceof b)if(k.b){if(k=d(k))return k}else return k}return null}function e(a,c){a.g instanceof b&&(a.g.h.splice(a.g.h.indexOf(a)+(c?1:0)),a.g.f=a.g.h[a.g.h.length-1],e(a.g,!0))}function g(a){return a}function f(a){return{link:a,text:a,Fa:!1}}var n,h,m={w:[],U:g,aa:g,Z:f};b.prototype.ta=function(){return this.la&&!!this.b||this.g instanceof b&&this.g.ta()};b.prototype.wa=function(){return this.ra&&!!this.b||this.g instanceof b&&this.g.wa()};b.prototype.xa=function(){return this.ca&&!!this.b||
 this.g instanceof b&&this.g.xa()};b.prototype.ja=function(){return this.W&&!!this.b||this.g instanceof b&&this.g.ja()};b.prototype.va=function(){return this.qa&&!!this.b||this.g instanceof b&&this.g.va()};b.prototype.ua=function(){return this.ma&&!!this.b||this.g instanceof b&&this.g.ua()};b.prototype.ia=function(){return this.Ba&&!!this.b||this.g instanceof b&&this.g.ia()};b.prototype.ya=function(){for(var a=0,c=this.h.length;a<c;a++)if(this.h[a]instanceof b&&(!this.h[a].b||this.h[a].ya()))return!0;
 return!1};b.prototype.za=function(a){if("<"===this.a&&">"===n[a])return!0;var b=c(n[a-1]);if(!this.i&&n.substr(a,this.a.length)===this.a){if(!b&&(this.la||this.ra||this.ca))return!1;if(this.f&&this.ya())return this.f.Ca();if(this.La())return!0}return"\n"===n[a]&&this.i?!0:!1};b.prototype.La=function(){for(var a=this;a;){for(var c=0,d=a.h.length;c<d;c++)if(a.h[c]instanceof b||a.h[c].text.length)return!0;a=a.da}return!1};b.prototype.Ca=function(){var a=new b(this.g,this.R,this.a);a.da=this;this.f&&
 this.f instanceof b&&(a.f=this.f.Ca(),a.h=[a.f]);return a};b.prototype.Ma=function(a){return this.W&&(" "===n[a]||"\t"===n[a])||(this.W||this.ba||this.la||this.ra||this.ca||this.ma)&&"\n"===n[a]?!1:!0};b.prototype.Na=function(b){if(this.ma||this.W||this.Ba||this.ba)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(n[b-1]),e=c(n[b+1]);if("```"===n.substr(b,3))return"```";var f=h.ka();if(void 0===f||f){if("&gt;"===n.substr(b,4))return"&gt;";if(">"===n[b])return n[b]}if("`"===n[b]&&!d||
-"\n"===n[b]||-1!==["*","~","-","_"].indexOf(n[b])&&(e||-1!=="*~-_<&".split("").indexOf(n[b+1]))&&(d||-1!=="*~-_<&".split("").indexOf(n[b-1]))||-1!==[":"].indexOf(n[b])&&e||-1!==["<"].indexOf(n[b]))return n[b];d=0;for(e=m.w.length;d<e;d++)if(f=m.w[d],n.substr(b,f.length)===f)return f}return null};a.prototype.ka=function(){if(""!==this.text.trim())return!1};b.prototype.ka=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].ka();if(void 0!==b)return b}if(this.oa||this.i)return!0};a.prototype.B=
-function(a){this.text+=n[a];return 1};b.prototype.B=function(c){var d=this.f&&!this.f.b&&this.f.za?this.f.za(c):null;if(d){var e=this.f.a.length;this.f.sa(c);d instanceof b&&(this.f=d,this.h.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.Ma(c)){if(d=this.Na(c))return this.f=new b(this,c,d),this.h.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.h.push(this.f);return this.f.B(c)}d=this.f.R+1;h.ha(this.f.R);this.f=new a(this);this.f.B(d-1);this.h.pop();
+"\n"===n[b]||-1!==["*","~","-","_"].indexOf(n[b])&&(e||-1!=="*~-_<&".split("").indexOf(n[b+1]))&&(d||-1!=="*~-_<&".split("").indexOf(n[b-1]))||-1!==[":"].indexOf(n[b])&&e||-1!==["<"].indexOf(n[b]))return n[b];d=0;for(e=m.w.length;d<e;d++)if(f=m.w[d],n.substr(b,f.length)===f)return f}return null};a.prototype.ka=function(){if(""!==this.text.trim())return!1};b.prototype.ka=function(){for(var a=this.h.length-1;0<=a;a--){var b=this.h[a].ka();if(void 0!==b)return b}if(this.oa||this.i)return!0};a.prototype.D=
+function(a){this.text+=n[a];return 1};b.prototype.D=function(c){var d=this.f&&!this.f.b&&this.f.za?this.f.za(c):null;if(d){var e=this.f.a.length;this.f.sa(c);d instanceof b&&(this.f=d,this.h.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.Ma(c)){if(d=this.Na(c))return this.f=new b(this,c,d),this.h.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.h.push(this.f);return this.f.D(c)}d=this.f.R+1;h.ha(this.f.R);this.f=new a(this);this.f.D(d-1);this.h.pop();
 this.h.push(this.f);return d-c};b.prototype.sa=function(a){for(var b=this;b;)b.b=a,b=b.da};b.prototype.ha=function(a){this.b&&this.b>=a&&(this.b=!1);this.h.forEach(function(c){c instanceof b&&c.ha(a)})};a.prototype.innerHTML=function(){if(this.g.ja()){for(var a=this.g;a&&!a.W;)a=a.g;if(a){var a=a.a+this.text+a.a,b=m.U(a);return b?b:a}return(a=m.U(this.text))?a:this.text}if(this.g.ia()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,tabReplace:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),
 a&&hljs.getLanguage(a[0])?hljs.fixMarkup(hljs.highlight(a[0],this.text.substr(a[0].length)).value):hljs.fixMarkup(hljs.highlightAuto(this.text).value)}catch(q){console.error(q)}return this.text.replace(/\n/g,"<br/>")}return m.aa(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ia()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.ua()?(b.push("code"),d=this.innerHTML()):(this.g.ba&&(d=m.Z(this.text))?(a="a",c=' href="'+d.link+'"',d.Fa||(c+=' target="_blank"'),
 d=m.aa(d.text)):d=this.innerHTML(),this.g.ta()&&b.push("bold"),this.g.wa()&&b.push("italic"),this.g.xa()&&b.push("strike"),this.g.ja()&&b.push("emoji"),this.g.va()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.i&&(a+='<span class="quote">');this.oa&&(a+="<br/>");this.h.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.Aa=function(a){this.i&&!this.b&&this.sa(a);this.h.forEach(function(c){c instanceof
-b&&c.Aa(a)})};return function(c,l){l||(l={});m.w=l.w||[];m.U=l.U||g;m.aa=l.aa||g;m.Z=l.Z||f;n=c;h=new b(this,0);l=0;c=n.length;do{for(;l<c;)l+=h.B(l);h.Aa(n.length);if(l=d()){e(l,!1);h.ha(l.R);var k=new a(l.g);k.B(l.R);l.g.h.push(k);l.g.f=k;l=l.R+1}else l=void 0}while(void 0!==l);return h.outerHTML()}}();window._formatText=function(a,b){return sa(a,{w:b?b.highlights:void 0})};"undefined"!==typeof module&&(module.I.u=sa);function ta(a,b){this.i=a;this.content=b;this.c=ua(this);this.b=va(this);this.a=[];this.B=[]}
+b&&c.Aa(a)})};return function(c,l){l||(l={});m.w=l.w||[];m.U=l.U||g;m.aa=l.aa||g;m.Z=l.Z||f;n=c;h=new b(this,0);l=0;c=n.length;do{for(;l<c;)l+=h.D(l);h.Aa(n.length);if(l=d()){e(l,!1);h.ha(l.R);var k=new a(l.g);k.D(l.R);l.g.h.push(k);l.g.f=k;l=l.R+1}else l=void 0}while(void 0!==l);return h.outerHTML()}}();window._formatText=function(a,b){return sa(a,{w:b?b.highlights:void 0})};"undefined"!==typeof module&&(module.H.u=sa);function ta(a,b){this.i=a;this.content=b;this.c=ua(this);this.b=va(this);this.a=[];this.D=[]}
 function ua(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),g=document.createElement("div"),f=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.i;"string"==typeof a.content?g.innerHTML=a.content:g.appendChild(a.content);c.className=wa;d.className=xa;e.className=ya;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);g.className=
-za;b.appendChild(g);b.b.className=Aa;b.b.textContent=L.Ea;b.b.addEventListener("click",function(){M(a,!1)});e.addEventListener("click",function(){M(a,!1)});b.a.addEventListener("click",function(){M(a,!0)});f.appendChild(b.b);b.a.className=Aa;b.a.textContent=L.ok;f.appendChild(b.a);f.className=Ba+" "+Ca;b.appendChild(f);b.className=Da;return b}function M(a,b){(b?a.a:a.B).forEach(function(a){a()});a.close()}
+za;b.appendChild(g);b.b.className=Aa;b.b.textContent=L.Ea;b.b.addEventListener("click",function(){M(a,!1)});e.addEventListener("click",function(){M(a,!1)});b.a.addEventListener("click",function(){M(a,!0)});f.appendChild(b.b);b.a.className=Aa;b.a.textContent=L.ok;f.appendChild(b.a);f.className=Ba+" "+Ca;b.appendChild(f);b.className=Da;return b}function M(a,b){(b?a.a:a.D).forEach(function(a){a()});a.close()}
 function va(a){var b=document.createElement("div");b.className=Ea;b.addEventListener("click",function(){M(this,!1)}.bind(a));return b}function Fa(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}ta.prototype.$=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};ta.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ga(a,b){a.a.push(b);return a};var Aa="button",Ba="button-container",Da="dialog",Ea="dialog-overlay",wa="dialog-title",xa="dialog-title-label",ya="dialog-title-close",za="dialog-body",Ca="dialog-footer";var Ha=[],Ia=0;
 function Ja(){var a=document.createDocumentFragment(),b=pa(function(a){return!a.Y&&!1!==a.i}),c=[],d=[],e=[],g=[];b.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:H(a).name.localeCompare(H(b).name)});b.forEach(function(a){a=H(a);if(a instanceof r){var b;if(b=!a.a.Da){var f=document.createElement("li");b=document.createElement("a");f.id="room_"+a.id;b.href="#"+a.id;f.className="slack-context-room slack-ims";b.textContent=a.a.name;f.appendChild(Ka());f.appendChild(b);a.a.a||f.classList.add("away");N===
-a&&f.classList.add("selected");a.A>a.C&&(f.classList.add("unread"),0<=O.indexOf(a)&&f.classList.add("unreadHi"));b=f}b&&(a.J?c.push(f):g.push(f))}else f=document.createElement("li"),b=document.createElement("a"),f.id="room_"+a.id,b.href="#"+a.id,a.b?(f.className="slack-context-room slack-group",f.dataset.count=Object.keys(a.m||{}).length):f.className="slack-context-room slack-channel",N===a&&f.classList.add("selected"),b.textContent=a.name,f.appendChild(Ka()),f.appendChild(b),a.A>a.C&&(f.classList.add("unread"),
-0<=O.indexOf(a)&&f.classList.add("unreadHi")),f&&(a.J?c.push(f):a.b?e.push(f):d.push(f))});c.length&&a.appendChild(La(L.J));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(La(L.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});g.length&&a.appendChild(La(L.Ka));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ma();P();Q&&Na(Q.b.id,Q.m,function(a){document.getElementById("slackCtx").style.backgroundImage=
+a&&f.classList.add("selected");a.I>a.A&&(f.classList.add("unread"),f.classList.add("unreadHi"));b=f}b&&(a.J?c.push(f):g.push(f))}else f=document.createElement("li"),b=document.createElement("a"),f.id="room_"+a.id,b.href="#"+a.id,a.b?(f.className="slack-context-room slack-group",f.dataset.count=Object.keys(a.m||{}).length):f.className="slack-context-room slack-channel",N===a&&f.classList.add("selected"),b.textContent=a.name,f.appendChild(Ka()),f.appendChild(b),a.I>a.A&&(f.classList.add("unread"),0<=
+O.indexOf(a)&&f.classList.add("unreadHi")),f&&(a.J?c.push(f):a.b?e.push(f):d.push(f))});c.length&&a.appendChild(La(L.J));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(La(L.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});g.length&&a.appendChild(La(L.Ka));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ma();P();Q&&Na(Q.b.id,Q.m,function(a){document.getElementById("slackCtx").style.backgroundImage=
 "url("+a+")"})}function Oa(){oa(function(a){var b=a.o,c;for(c in a.self.j)if(!a.self.j[c].Y){var d=document.getElementById("room_"+c);b[c]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing")}for(var e in a.m)(c=a.m[e].na)&&!c.Y&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("slack-context-typing"):d.classList.remove("slack-context-typing"))});Pa()}
 function Pa(){var a;document.getElementById("whoistyping").textContent="";if(Q&&N&&(a=Q.o[N.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=I(d))?b.appendChild(Qa(a)):c=!0;c&&(E.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ra(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");P()}
 function Sa(){var a=N.name||(N.a?N.a.name:void 0);if(!a){var b=[];N.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Ta();R();document.getElementById("fileUploadContainer").classList.add("hidden");Ua();T&&(T=null,U());V&&(V=null,U());Pa()}
 function U(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;U()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(T.L())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
 function W(){if(V){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){V=null;W()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(V.L());document.getElementById("msgInput").value=V.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()}
-window.toggleReaction=function(a,b,c){var d=E.a[a],e,g;(d=E.a[a])&&(e=ja(d,b))&&(g=G(E.context,a))&&(e.D[c]&&-1!==e.D[c].indexOf(g.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):Va(a,b,c))};
+window.toggleReaction=function(a,b,c){var d=E.a[a],e,g;(d=E.a[a])&&(e=ja(d,b))&&(g=G(E.context,a))&&(e.B[c]&&-1!==e.B[c].indexOf(g.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):Va(a,b,c))};
 function Wa(a){a:{var b={};if(Q){var c;for(c=Q;!b[a];){if(c=c.a.data[a])if("alias:"==c.substr(0,6))b[a]=!0,a=c.substr(6);else{a=document.createElement("span");a.className="emoji-custom emoji";a.style.backgroundImage="url('"+c+"')";break a}break}}}"string"===typeof a&&"makeEmoji"in window&&(a=window.makeEmoji(a));return"string"===typeof a?null:a}function Xa(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
-function P(){var a=O.length,b="";if(X)b="!"+L.Ga+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Xa(a,a);else{var c=0;na(E.context,function(a){a.A>a.C&&c++});c&&(b="("+c+") - ");Xa(0,c)}E.context.b&&(b+=E.context.b.name);document.title=b}
+function P(){var a=O.length,b="";if(X)b="!"+L.Ga+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Xa(a,a);else{var c=0;na(E.context,function(a){a.I>a.A&&c++});c&&(b="("+c+") - ");Xa(0,c)}E.context.b&&(b+=E.context.b.name);document.title=b}
 function Ya(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Ia+3E4<a){var b=new Notification(L.Ha);Ia=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function Ta(){var a=document.createDocumentFragment(),b=N.id,c=null,d=0,e=null,g;Ha=[];E.a[b]&&E.a[b].a.forEach(function(b){if(b.i)b.P();else{var f=b.M(),h=!1;c&&c.H===b.H&&b.H?30>Math.abs(d-b.l)&&!(b instanceof B)?e.classList.add("slackmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=N.C)&&b.l>N.C?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof B)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=I(b.H),m=b.username,k=document.createElement("div"),
+function Ta(){var a=document.createDocumentFragment(),b=N.id,c=null,d=0,e=null,g;Ha=[];E.a[b]&&E.a[b].a.forEach(function(b){if(b.i)b.P();else{var f=b.M(),h=!1;c&&c.G===b.G&&b.G?30>Math.abs(d-b.l)&&!(b instanceof B)?e.classList.add("slackmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=N.A)&&b.l>N.A?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof B)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=I(b.G),m=b.username,k=document.createElement("div"),
 l=document.createElement("div"),q=document.createElement("span");k.S=document.createElement("img");k.S.className="slackmsg-author-img";q.className="slackmsg-author-name";h?(q.textContent=h.name,k.S.src="api/avatar?user="+h.id):(q.textContent=m||"?",k.S.src="");l.appendChild(k.S);l.appendChild(q);l.className="slackmsg-author";k.className="slackmsg-authorGroup";k.appendChild(l);k.content=document.createElement("div");k.content.className="slackmsg-author-messages";k.appendChild(k.content);g=k;Ha.push(g);
 a.appendChild(g)}c=b;e=f;g.content.appendChild(f)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;window.hasFocus&&Ua()}
 function Za(a,b){a.classList.contains("slackmsg-hover-reply")?(V&&(V=null,W()),T!==b&&(T=b,U())):a.classList.contains("slackmsg-hover-reaction")?$a.$(document.body,{Qa:N.id,Pa:b.id},function(a){a&&Va(this.Qa,this.Pa,a)}):a.classList.contains("slackmsg-hover-edit")?(T&&(T=null,U()),V!==b&&(V=b,W())):a.classList.contains("slackmsg-hover-remove")&&(T&&(T=null,U()),V&&(V=null,W()),ab(b))}
 function bb(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("slackmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("slackmsg-hover");){var d;if(c.parentElement&&c.classList.contains("slackmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,g=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==g){d=d.substr(d.lastIndexOf("_")+1);(a=ja(E.a[N.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[g]&&
 cb(a,a.s[e],a.s[e].actions[g]);break}}if(c.parentElement&&c.parentElement.classList.contains("slackmsg-hover")){if(d=b(a,c))d=d.substr(d.lastIndexOf("_")+1),(a=ja(E.a[N.id],d))&&Za(c,a);break}c=c.parentElement}}
-function cb(a,b,c){function d(){var d={actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof C,message_ts:a.id},f=new XMLHttpRequest;f.open("POST","api/attachmentAction?serviceId="+a.H);f.send(JSON.stringify(d))}var e=N.id;c.confirm?Ga(Fa(new ta(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).$():d()}function R(){document.getElementById("msgInput").focus()}
+function cb(a,b,c){function d(){var d={actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof C,message_ts:a.id},f=new XMLHttpRequest;f.open("POST","api/attachmentAction?serviceId="+a.G);f.send(JSON.stringify(d))}var e=N.id;c.confirm?Ga(Fa(new ta(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).$():d()}function R(){document.getElementById("msgInput").focus()}
 function Ma(){var a=document.location.hash.substr(1),b=H(a);b&&b!==N?db(b):(a=I(a))&&a.b&&db(a.b)}function eb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Ha.forEach(function(b){var c=b.S,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}
 document.addEventListener("DOMContentLoaded",function(){ra();fb();document.getElementById("chatWindow").addEventListener("click",bb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&Ma()});document.getElementById("fileUploadCancel").addEventListener("click",function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value=
 "";return!1});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),gb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});
@@ -51,10 +51,10 @@ document.getElementById("attachFile").addEventListener("click",function(a){a.pre
 !1});window.addEventListener("focus",function(){window.hasFocus=!0;Ia=0;N&&Ua();R()});document.getElementById("chatWindow").addEventListener("scroll",eb);var a=0;document.getElementById("msgInput").addEventListener("input",function(){if(N){var b=Date.now();a+3E3<b&&(Q.self.a||N instanceof r)&&(ib(),a=b);var b=[],c=this.value;if("/"===this.value[0]){var d=c.indexOf(" "),e=-1!==d,d=-1===d?c.length:d,c=c.substr(0,d),g=Q?Q.i.data:{};for(n in g){var f=g[n];(!e&&f.name.substr(0,d)===c||e&&f.name===c)&&
 b.push(f)}}b.sort(function(a,b){return a.T.localeCompare(b.T)||a.name.localeCompare(b.name)});var n=document.getElementById("slashList");var d=document.createDocumentFragment();n.textContent="";e=0;for(c=b.length;e<c;e++){g=b[e];if(h!==g.T){var h=g.T;d.appendChild(jb(g.T))}d.appendChild(kb(g))}n.appendChild(d)}});window.hasFocus=!0;(function(){var a=document.getElementById("emojiButton");if("makeEmoji"in window){var c=window.makeEmoji("smile");c?a.innerHTML="<span class='emoji-small'>"+c.outerHTML+
 "</span>":a.style.backgroundImage='url("smile.svg")';(c=window.makeEmoji("paperclip"))?document.getElementById("attachFile").innerHTML="<span class='emoji-small'>"+c.outerHTML+"</span>":document.getElementById("attachFile").style.backgroundImage='url("public/paperclip.svg")';a.addEventListener("click",function(){Q&&$a.$(document.body,Q,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");R()})})}else a.classList.add("hidden")})();lb()});function Ka(){var a=document.createElement("span"),b=document.createElement("span"),c=document.createElement("span"),d=document.createElement("span");a.className="typing-container";b.className="typing-dot1";c.className="typing-dot2";d.className="typing-dot3";b.textContent=c.textContent=d.textContent=".";a.appendChild(b);a.appendChild(c);a.appendChild(d);return a}var La=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function mb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul"),g=document.createElement("li");c.s=document.createElement("ul");c.D=document.createElement("ul");c.l=document.createElement("div");c.pa=document.createElement("div");c.fa=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.l.className="slackmsg-ts";c.pa.className="slackmsg-msg";c.fa.className="slackmsg-author-name";e.className="slackmsg-hover";g.className=
-"slackmsg-hover-reply";e.appendChild(g);if("makeEmoji"in window){var f=document.createElement("li"),n=window.makeEmoji("arrow_heading_down"),h=window.makeEmoji("smile"),m=window.makeEmoji("pencil2"),b=window.makeEmoji("x");f.className="slackmsg-hover-reaction";h?(f.classList.add("emoji-small"),f.appendChild(h)):f.style.backgroundImage='url("smile.svg")';n?(g.classList.add("emoji-small"),g.appendChild(n)):g.style.backgroundImage='url("repl.svg")';e.appendChild(f);qa(a.H)&&(a=document.createElement("li"),
-a.className="slackmsg-hover-edit",m?a.classList.add("emoji-small"):a.style.backgroundImage='url("edit.svg")',a.appendChild(m),e.appendChild(a),a=document.createElement("li"),a.className="slackmsg-hover-remove",b?a.classList.add("emoji-small"):a.style.backgroundImage='url("remove.svg")',a.appendChild(b),e.appendChild(a))}else g.style.backgroundImage='url("repl.svg")',qa(a.H)&&(a=document.createElement("li"),a.className="slackmsg-hover-edit",a.style.backgroundImage='url("edit.svg")',e.appendChild(a),
-a=document.createElement("li"),a.className="slackmsg-hover-remove",a.style.backgroundImage='url("remove.svg")',e.appendChild(a));d.appendChild(c.fa);d.appendChild(c.pa);d.appendChild(c.l);d.appendChild(c.s);c.F=document.createElement("div");c.F.className="slackmsg-edited";d.appendChild(c.F);d.appendChild(c.D);d.className="slackmsg-content";c.s.className="slackmsg-attachments";c.D.className="slackmsg-reactions";c.appendChild(d);c.appendChild(e);return c}
+function mb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul"),g=document.createElement("li");c.s=document.createElement("ul");c.B=document.createElement("ul");c.l=document.createElement("div");c.pa=document.createElement("div");c.fa=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.l.className="slackmsg-ts";c.pa.className="slackmsg-msg";c.fa.className="slackmsg-author-name";e.className="slackmsg-hover";g.className=
+"slackmsg-hover-reply";e.appendChild(g);if("makeEmoji"in window){var f=document.createElement("li"),n=window.makeEmoji("arrow_heading_down"),h=window.makeEmoji("smile"),m=window.makeEmoji("pencil2"),b=window.makeEmoji("x");f.className="slackmsg-hover-reaction";h?(f.classList.add("emoji-small"),f.appendChild(h)):f.style.backgroundImage='url("smile.svg")';n?(g.classList.add("emoji-small"),g.appendChild(n)):g.style.backgroundImage='url("repl.svg")';e.appendChild(f);qa(a.G)&&(a=document.createElement("li"),
+a.className="slackmsg-hover-edit",m?a.classList.add("emoji-small"):a.style.backgroundImage='url("edit.svg")',a.appendChild(m),e.appendChild(a),a=document.createElement("li"),a.className="slackmsg-hover-remove",b?a.classList.add("emoji-small"):a.style.backgroundImage='url("remove.svg")',a.appendChild(b),e.appendChild(a))}else g.style.backgroundImage='url("repl.svg")',qa(a.G)&&(a=document.createElement("li"),a.className="slackmsg-hover-edit",a.style.backgroundImage='url("edit.svg")',e.appendChild(a),
+a=document.createElement("li"),a.className="slackmsg-hover-remove",a.style.backgroundImage='url("remove.svg")',e.appendChild(a));d.appendChild(c.fa);d.appendChild(c.pa);d.appendChild(c.l);d.appendChild(c.s);c.C=document.createElement("div");c.C.className="slackmsg-edited";d.appendChild(c.C);d.appendChild(c.B);d.className="slackmsg-content";c.s.className="slackmsg-attachments";c.B.className="slackmsg-reactions";c.appendChild(d);c.appendChild(e);return c}
 function nb(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
 function ob(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),g=document.createElement("div"),f=document.createElement("a"),n=document.createElement("div"),h=document.createElement("img"),m=document.createElement("a"),k=document.createElement("div"),l=document.createElement("div"),q=document.createElement("div"),y=document.createElement("img"),u=document.createElement("div");d.className="slackmsg-attachment";e.style.borderColor=nb(b.color||"");e.className="slackmsg-attachment-block";
 g.className="slackmsg-attachment-pretext";b.pretext?g.innerHTML=a.u(b.pretext):g.classList.add("hidden");f.target="_blank";b.title?(f.innerHTML=a.u(b.title),b.title_link&&(f.href=b.title_link),f.className="slackmsg-attachment-title"):f.className="hidden slackmsg-attachment-title";m.target="_blank";n.className="slackmsg-author";b.author_name&&(m.innerHTML=a.u(b.author_name),m.href=b.author_link||"",m.className="slackmsg-author-name",h.className="slackmsg-author-img",b.author_icon&&(h.src=b.author_icon,
@@ -65,32 +65,32 @@ b.actions.length)for(f=document.createElement("ul"),f.className="slackmsg-attach
 function pb(a,b,c){var d=document.createElement("li"),e=nb(c.style);d.textContent=c.text;e!==nb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="slackmsg-attachment-actions-item "+Aa;return d}function Qa(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.name;b.appendChild(Ka());b.appendChild(c);return b}
 function jb(a){var b=document.createElement("lh");b.textContent=a;b.className="slack-command-header";return b}
 function kb(a){var b=document.createElement("li"),c=document.createElement("span"),d=document.createElement("span"),e=document.createElement("span");c.textContent=a.name;d.textContent=a.usage;e.textContent=a.a;b.appendChild(c);b.appendChild(d);b.appendChild(e);b.className="slack-command-item";c.className="slack-command-name";d.className="slack-command-usage";e.className="slack-command-desc";return b};var $a=function(){function a(a,b){for(a=a.target;a!==h&&a&&"LI"!==a.nodeName;)a=a.parentElement;a&&"LI"===a.nodeName&&a.id&&"emojibar-"===a.id.substr(0,9)?b(a.id.substr(9)):b(null)}function b(){if(!c())return!1;F&&F(null);return!0}function c(){return h.parentElement?(h.parentElement.removeChild(m),h.parentElement.removeChild(h),!0):!1}function d(a){var b=0;a=void 0===a?y.value:a;if(n()){var c=0,d=window.searchEmojis(a),f=e(d,S.self.N.ga),h;for(k in u)u[k].visible&&(u[k].visible=!1,l.removeChild(u[k].c));
-var k=0;for(h=f.length;k<h;k++){var z=f[k].name,m=u[z];if(!m){var m=u,K=z;var F=z;var z=window.makeEmoji(d[z]),w=document.createElement("span");w.appendChild(z);w.className="emoji-medium";F=g(F,w);m=m[K]=F}m.visible||(m.visible=!0,l.appendChild(m.c));c++}b+=c}k=b;var c=0;for(A in v)v[A].visible&&(v[A].visible=!1,q.removeChild(v[A].c));d=e(S.a.data,S.self.N.ga);var A=0;for(b=d.length;A<b;A++)K=d[A].name,""!==a&&K.substr(0,a.length)!==a||"alias:"===S.a.data[K].substr(0,6)||(f=v[K],f||(f=v,m=h=K,K=S.a.data[K],
-F=document.createElement("span"),z=document.createElement("span"),F.className="emoji emoji-custom",F.style.backgroundImage='url("'+K+'")',z.appendChild(F),z.className="emoji-medium",m=g(m,z),f=f[h]=m),f.visible||(f.visible=!0,q.appendChild(f.c)),c++);return k+c}function e(a,b){var c=[],d;for(d in a){var e={name:d,Ja:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.Ja-b.Ja})}function g(a,
+var k=0;for(h=f.length;k<h;k++){var z=f[k].name,m=u[z];if(!m){var m=u,J=z;var F=z;var z=window.makeEmoji(d[z]),w=document.createElement("span");w.appendChild(z);w.className="emoji-medium";F=g(F,w);m=m[J]=F}m.visible||(m.visible=!0,l.appendChild(m.c));c++}b+=c}k=b;var c=0;for(A in v)v[A].visible&&(v[A].visible=!1,q.removeChild(v[A].c));d=e(S.a.data,S.self.N.ga);var A=0;for(b=d.length;A<b;A++)J=d[A].name,""!==a&&J.substr(0,a.length)!==a||"alias:"===S.a.data[J].substr(0,6)||(f=v[J],f||(f=v,m=h=J,J=S.a.data[J],
+F=document.createElement("span"),z=document.createElement("span"),F.className="emoji emoji-custom",F.style.backgroundImage='url("'+J+'")',z.appendChild(F),z.className="emoji-medium",m=g(m,z),f=f[h]=m),f.visible||(f.visible=!0,q.appendChild(f.c)),c++);return k+c}function e(a,b){var c=[],d;for(d in a){var e={name:d,Ja:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.Ja-b.Ja})}function g(a,
 b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function f(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";return c}function n(){return"searchEmojis"in window}var h=document.createElement("div"),m=document.createElement("div"),k=document.createElement("div"),l=document.createElement("ul"),q=document.createElement("ul"),y=document.createElement("input"),
 u={},v={},w=document.createElement("div"),A=document.createElement("span"),z=document.createElement("span"),F,S;m.addEventListener("click",function(a){var c=h.getBoundingClientRect();(a.screenY<c.top||a.screenY>c.bottom||a.screenX<c.left||a.screenX>c.right)&&b()});m.className="emojibar-overlay";h.className="emojibar";k.className="emojibar-emojis";w.className="emojibar-detail";A.className="emojibar-detail-img";z.className="emojibar-detail-name";l.className=q.className="emojibar-list";y.className="emojibar-search";
 w.appendChild(A);w.appendChild(z);k.appendChild(f(window.emojiProviderHeader));k.appendChild(l);k.appendChild(f("emojicustom.png"));k.appendChild(q);h.appendChild(k);h.appendChild(w);h.appendChild(y);y.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?u[a]||v[a]:null;b?(A.innerHTML=b.c.outerHTML,z.textContent=":"+a+":"):(A.textContent="",z.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&F&&F(a)})});return{isSupported:n,
 $:function(a,b,c){return n()?(S=b,F=c,a.appendChild(m),a.appendChild(h),y.value="",d(),y.focus(),!0):!1},search:d,close:b}}();var E,O=[];function qb(){da.call(this)}qb.prototype=Object.create(da.prototype);qb.prototype.constructor=qb;function ma(a){return a.b?a.b.id:null}function rb(){this.b=0;this.context=new ka;this.a={}}
-rb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(e in a["static"]){var c=la(this.context,e);c||(c=new qb,this.context.push(c));ea(c,a["static"][e],b)}na(this.context,function(a){a.A===a.C&&(a=O.indexOf(a),-1!==a&&O.splice(a,1))});if(a.live){for(e in a.live)(c=this.a[e])?ga(c,a.live[e],b):c=this.a[e]=new Y(e,250,a.live[e],b);for(var d in a.live){var e=G(this.context,d);(c=e.j[d])?(this.a[d].a.length&&(c.A=Math.max(c.A,ia(this.a[d]).l)),c.Y||(sb(e,c,a.live[d]),N&&
+rb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(e in a["static"]){var c=la(this.context,e);c||(c=new qb,this.context.push(c));ea(c,a["static"][e],b)}na(this.context,function(a){a.I===a.A&&(a=O.indexOf(a),-1!==a&&O.splice(a,1))});if(a.live){for(e in a.live)(c=this.a[e])?ga(c,a.live[e],b):c=this.a[e]=new Y(e,250,a.live[e],b);for(var d in a.live){var e=G(this.context,d);(c=e.j[d])?(this.a[d].a.length&&(c.I=Math.max(c.I,ia(this.a[d]).l)),c.Y||(sb(e,c,a.live[d]),N&&
 a.live[N.id]&&Ta())):E.b=0}}a["static"]&&Ja();var g=!1;a.typing&&this.context.a.forEach(function(c){var d=g,e=a.typing,f=!1;if(c.o)for(var k in c.o)e[k]||(delete c.o[k],f=!0);if(e)for(k in e)if(c.j[k]){c.o[k]||(c.o[k]={});for(var l in e[k])c.o[k][l]||(f=!0),c.o[k][l]=b}g=d|f},this);(a["static"]||g)&&Oa()};
 setInterval(function(){var a=!1,b=Date.now();oa(function(c){var d=!1,e;for(e in c.o){var g=!0,f;for(f in c.o[e])c.o[e][f]+3E3<b?(delete c.o[e][f],d=!0):g=!1;g&&(delete c.o[e],d=!0)}d&&(a=!0)});a&&Oa()},1E3);
-function sb(a,b,c){if(b!==N||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,g=!1,f=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)){g=!0;var h;if(!(h=b instanceof r)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.N.w;for(var m=0,k=h.length;m<k;m++)if(-1!==c.text.indexOf(h[m])){h=!0;break a}h=!1}h&&(-1===O.indexOf(b)&&(f=!0,O.push(b)),e=!0)}});if(g){P();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Ya()}}}
-function Ua(){var a=N,b=O.indexOf(a);if(a.A>a.C){var c=new XMLHttpRequest;c.open("POST","api/markread?room="+a.id+"&ts="+a.A,!0);c.send(null);a.C=a.A}0<=b&&(O.splice(b,1),P());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new rb;var Na=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<m-40;e+=l)for(var g=0;g+l<=k;g+=l)f(a,c[d],e,g),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.X?b.X?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].X){d(a[e].src,function(d){a[e].X=d;c(a,b)});return}var g=[];a.forEach(function(a){a.X&&g.push(a.X)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
+function sb(a,b,c){if(b!==N||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,g=!1,f=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.A)){g=!0;var h;if(!(h=b instanceof r)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.N.w;for(var m=0,k=h.length;m<k;m++)if(-1!==c.text.indexOf(h[m])){h=!0;break a}h=!1}h&&(-1===O.indexOf(b)&&(f=!0,O.push(b)),e=!0)}});if(g){P();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Ya()}}}
+function Ua(){var a=N,b=O.indexOf(a);if(a.I>a.A){var c=E.a[a.id];if(c&&(c=c.a[c.a.length-1])){var d=new XMLHttpRequest;d.open("POST","api/markread?room="+a.id+"&id="+c.id,!0);d.send(null);a.A=c.l}}0<=b&&(O.splice(b,1),P());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}E=new rb;var Na=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<m-40;e+=l)for(var g=0;g+l<=k;g+=l)f(a,c[d],e,g),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.X?b.X?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].X){d(a[e].src,function(d){a[e].X=d;c(a,b)});return}var g=[];a.forEach(function(a){a.X&&g.push(a.X)});b(g)}function d(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
 c.readyState)if(c.response){var a=new Image;a.onload=function(){var c=document.createElement("canvas");c.height=c.width=u;c=c.getContext("2d");c.drawImage(a,0,0,u,u);var c=c.getImageData(0,0,u,u),d=0,e;for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=(c.data[e]+c.data[e+1]+c.data[e+2])/3,c.data[e+3]=50,d+=c.data[e];if(50>d/(c.height*c.width))for(e=0;e<c.width*c.height*4;e+=4)c.data[e]=c.data[e+1]=c.data[e+2]=255-c.data[e];b(c)};a.onerror=function(){b(null)};a.src=window.URL.createObjectURL(c.response)}else b(null)};
 c.open("GET",a,!0);c.send(null)}function e(){var a=h.createLinearGradient(0,0,0,k);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");h.fillStyle=a;h.fillRect(0,0,m,k);return h.getImageData(0,0,m,k)}function g(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function f(a,b,c,d){var e=Math.floor(d);a=[a.data[e*m*4+0],a.data[e*m*4+1],a.data[e*m*4+2]];h.fillStyle=
 "#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);h.beginPath();h.moveTo(c+l/2,d+q);h.lineTo(c-q+l,d+l/2);h.lineTo(c+l/2,d-q+l);h.lineTo(c+q,d+l/2);h.closePath();h.fill();h.putImageData(g(h.getImageData(c+q,d+q,y,y),b),c+q,d+q)}var n=document.createElement("canvas"),h=n.getContext("2d"),m=n.width=250,k=n.height=290,l=(m-40)/3,q=.1*l,y=Math.floor(l-2*q),u=.5*y,v={},w={},A={};return function(b,d,f){if(v[b])f(v[b]);else if(A[b])w[b]?w[b].push(f):w[b]=[f];else{var g=e(),h=[];A[b]=!0;w[b]?w[b].push(f):
 w[b]=[f];for(var k in d)d[k].Da||d[k].Oa||h.push({src:"api/avatar?user="+d[k].id});c(h,function(c){a(g,c);v[b]=n.toDataURL();w[b].forEach(function(a){a(v[b])})})}}}();var X=0,N=null,Q=null,T=null,V=null;function fb(){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(){if(4===a.readyState){var b=document.createElement("script");b.innerHTML=a.response;b.language="text/javascript";document.head.innerHTML+='<link href="hljs-androidstudio.css" rel="stylesheet"/>';document.body.appendChild(b)}};a.open("GET","highlight.pack.js",!0);a.send(null)}function tb(){var a=new XMLHttpRequest;a.open("GET","api/hist?room="+N.id,!0);a.send(null)}
 function ub(a){var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState)if(b.status){var c=null,d=2===Math.floor(b.status/100);if(d){X&&(X=0,Ra(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else X?(X+=Math.floor((X||5)/2),X=Math.min(60,X)):(X=5,Ra(!1));a(d,c)}else X&&(X=0,Ra(!0)),ub(a)};b.open("GET","api?v="+E.b,!0);b.send(null)}function ib(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+N.id,!0);a.send(null)}
-function vb(a,b){a?(b&&E.update(b),lb()):setTimeout(lb,1E3*X)}function lb(){ub(vb)}function db(a){N&&document.getElementById("room_"+N.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");N=a;Q=G(E.context,a.id);Sa();Na(Q.b.id,Q.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});N.A&&!E.a[N.id]&&tb()}
+function vb(a,b){a?(b&&E.update(b),lb()):setTimeout(lb,1E3*X)}function lb(){ub(vb)}function db(a){N&&document.getElementById("room_"+N.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");N=a;Q=G(E.context,a.id);Sa();Na(Q.b.id,Q.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});N.I&&!E.a[N.id]&&tb()}
 function gb(a,b,c){var d=N;new FileReader;var e=new FormData,g=new XMLHttpRequest;e.append("file",b);e.append("filename",a);g.onreadystatechange=function(){4===g.readyState&&(204===g.status?c(null):c(g.statusText))};g.open("POST","api/file?room="+d.id);g.send(e)}
 function hb(a){if(V){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+N.id+"&ts="+V.id+"&text="+encodeURIComponent(a),!0);b.send(null);return!0}if("/"===a[0]){var c=a.indexOf(" "),b=a.substr(0,-1===c?void 0:c);a=-1===c?"":a.substr(c);return(b=(c=Q)?c.i.data[b]:null)?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+N.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}var b=N,c=T,d=new XMLHttpRequest;a="api/msg?room="+b.id+"&text="+
-encodeURIComponent(a);if(c){var e=I(c.H);a+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:"<@"+e.id+"|"+e.name+">",text:c.text,footer:b.b?"Private message":b.name,ts:c.l}]))}d.open("POST",a,!0);d.send(null);return!0}function ab(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+N.id+"&ts="+a.id,!0);b.send(null)}function Va(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)};function Y(a,b,c,d){D.call(this,a,b,c,d)}Y.prototype=Object.create(D.prototype);Y.prototype.constructor=Y;Y.prototype.b=function(a,b){return!0===a.isMeMessage?new wb(this.id,a,b):!0===a.isNotice?new xb(this.id,a,b):new yb(this.id,a,b)};
+encodeURIComponent(a);if(c){var e=I(c.G);a+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:"<@"+e.id+"|"+e.name+">",text:c.text,footer:b.b?"Private message":b.name,ts:c.l}]))}d.open("POST",a,!0);d.send(null);return!0}function ab(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+N.id+"&ts="+a.id,!0);b.send(null)}function Va(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)};function Y(a,b,c,d){D.call(this,a,b,c,d)}Y.prototype=Object.create(D.prototype);Y.prototype.constructor=Y;Y.prototype.b=function(a,b){return!0===a.isMeMessage?new wb(this.id,a,b):!0===a.isNotice?new xb(this.id,a,b):new yb(this.id,a,b)};
 var Z=function(){function a(a,d){return sa(d,{w:a.context.self.N.w,U:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=Wa(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},Z:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|");if(-1===c)var d=b;else{d=b.substr(0,c);var f=b.substr(c+1)}if("@"===d[0])if(d=ma(a.context)+"|"+d.substr(1),f=I(d))a=!0,d="#"+f.na.id,f="@"+f.name;else return null;else if("#"===
-d[0])if(d=ma(a.context)+"|"+d.substr(1),f=H(d))a=!0,d="#"+d,f="#"+f.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:f||d,Fa:a}}return{G:function(a){a.O=!0;return a},P:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.O&&(a.O=!1,a.K()):a.ea().K();return a.c},K:function(b){var c=I(b.H);b.c.l.innerHTML=L.V(b.l);b.c.pa.innerHTML=a(b,b.text);b.c.fa.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),
-e=0,g=b.s.length;e<g;e++){var f=b.s[e];f&&(f=ob(b,f,e))&&c.appendChild(f)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var n in b.D){var g=c,f=b.id,h=n,m=b.D[n],k=Wa(h);if(k){for(var l=document.createElement("li"),q=document.createElement("a"),y=document.createElement("span"),u=document.createElement("span"),v=[],w=0,A=m.length;w<A;w++){var z=I(m[w]);z&&v.push(z.name)}v.sort();u.textContent=v.join(", ");y.appendChild(k);y.className="emoji-small";q.href=
-"javascript:toggleReaction('"+g+"', '"+f+"', '"+h+"')";q.appendChild(y);q.appendChild(u);l.className="slackmsg-reaction-item";l.appendChild(q);g=l}else console.warn("Reaction id not found: "+h),g=null;g&&e.appendChild(g)}b.c.D.textContent="";b.c.D.appendChild(e);b.F&&(b.c.F.innerHTML=L.F(b.F),b.c.classList.add("edited"));return b},L:function(a){return a.c.cloneNode(!0)},u:function(b,d){return a(b,d)}}}();
-function wb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.O=Z.O}wb.prototype=Object.create(B.prototype);p=wb.prototype;p.constructor=wb;p.G=function(){return Z.G(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){return Z.P(this)};p.M=function(){return Z.M(this)};p.ea=function(){this.c=mb(this);this.c.classList.add("slackmsg-me_message");return this};p.L=function(){return Z.L(this)};p.K=function(){Z.K(this);return this};
-p.update=function(a,b){B.prototype.update.call(this,a,b);this.G()};function yb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.O=Z.O}yb.prototype=Object.create(x.prototype);p=yb.prototype;p.constructor=yb;p.G=function(){return Z.G(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){return Z.P(this)};p.M=function(){return Z.M(this)};p.ea=function(){this.c=mb(this);return this};p.L=function(){return Z.L(this)};p.K=function(){Z.K(this);return this};
-p.update=function(a,b){x.prototype.update.call(this,a,b);this.G()};function xb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.a=null;this.O=!0}xb.prototype=Object.create(C.prototype);p=xb.prototype;p.constructor=xb;p.G=function(){return Z.G(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.M=function(){Z.M(this);return this.a};p.L=function(){return this.a.cloneNode(!0)};
-p.ea=function(){this.c=mb(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=L.Ia;this.a.appendChild(this.c);return this};p.K=function(){Z.K(this);return this};p.update=function(a,b){C.prototype.update.call(this,a,b);this.G()};
+d[0])if(d=ma(a.context)+"|"+d.substr(1),f=H(d))a=!0,d="#"+d,f="#"+f.name;else return null;else{if(!d.match(/^(https?|mailto):\/\//i))return null;a=!1}return{link:d,text:f||d,Fa:a}}return{F:function(a){a.O=!0;return a},P:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.O&&(a.O=!1,a.K()):a.ea().K();return a.c},K:function(b){var c=I(b.G);b.c.l.innerHTML=L.V(b.l);b.c.pa.innerHTML=a(b,b.text);b.c.fa.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),
+e=0,g=b.s.length;e<g;e++){var f=b.s[e];f&&(f=ob(b,f,e))&&c.appendChild(f)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.B)for(var n in b.B){var g=c,f=b.id,h=n,m=b.B[n],k=Wa(h);if(k){for(var l=document.createElement("li"),q=document.createElement("a"),y=document.createElement("span"),u=document.createElement("span"),v=[],w=0,A=m.length;w<A;w++){var z=I(m[w]);z&&v.push(z.name)}v.sort();u.textContent=v.join(", ");y.appendChild(k);y.className="emoji-small";q.href=
+"javascript:toggleReaction('"+g+"', '"+f+"', '"+h+"')";q.appendChild(y);q.appendChild(u);l.className="slackmsg-reaction-item";l.appendChild(q);g=l}else console.warn("Reaction id not found: "+h),g=null;g&&e.appendChild(g)}b.c.B.textContent="";b.c.B.appendChild(e);b.C&&(b.c.C.innerHTML=L.C(b.C),b.c.classList.add("edited"));return b},L:function(a){return a.c.cloneNode(!0)},u:function(b,d){return a(b,d)}}}();
+function wb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.O=Z.O}wb.prototype=Object.create(B.prototype);p=wb.prototype;p.constructor=wb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){return Z.P(this)};p.M=function(){return Z.M(this)};p.ea=function(){this.c=mb(this);this.c.classList.add("slackmsg-me_message");return this};p.L=function(){return Z.L(this)};p.K=function(){Z.K(this);return this};
+p.update=function(a,b){B.prototype.update.call(this,a,b);this.F()};function yb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.c=Z.c;this.O=Z.O}yb.prototype=Object.create(x.prototype);p=yb.prototype;p.constructor=yb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){return Z.P(this)};p.M=function(){return Z.M(this)};p.ea=function(){this.c=mb(this);return this};p.L=function(){return Z.L(this)};p.K=function(){Z.K(this);return this};
+p.update=function(a,b){x.prototype.update.call(this,a,b);this.F()};function xb(a,b,c){x.call(this,b,c);this.context=G(E.context,a);this.b=a;this.a=null;this.O=!0}xb.prototype=Object.create(C.prototype);p=xb.prototype;p.constructor=xb;p.F=function(){return Z.F(this)};p.u=function(a){return Z.u(this,a)};p.P=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};p.M=function(){Z.M(this);return this.a};p.L=function(){return this.a.cloneNode(!0)};
+p.ea=function(){this.c=mb(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=L.Ia;this.a.appendChild(this.c);return this};p.K=function(){Z.K(this);return this};p.update=function(a,b){C.prototype.update.call(this,a,b);this.F()};
 })();

+ 3 - 5
srv/src/context.js

@@ -173,17 +173,15 @@ ChatContext.prototype.updateStatic = function(data, t, idPrefix) {
         }
         this.commands.version = t;
     }
-    this.staticV = Math.max(this.staticV, t);
     if (data["self"]) {
         this.self = this.users[idPrefix +data["self"]["id"]] || null;
-        if (this.self && data["self"]["prefs"]) {
+        if (data["self"]["prefs"]) {
             if (!this.self.prefs)
                 this.self.prefs = new SelfPreferences();
             this.self.prefs.update(data["self"]["prefs"], t);
-        } else {
-            this.staticV = 0;
         }
     }
+    this.staticV = Math.max(this.staticV, t);
 };
 
 ChatContext.prototype.updateTyping = function(typing, now) {
@@ -221,7 +219,7 @@ ChatContext.prototype.toStatic = function(t) {
         "team": this.team.toStatic(t)
         ,"self": {
             "id": this.self.id
-            ,"prefs": this.self.prefs.toStatic(t)
+            ,"prefs": this.self.prefs ? this.self.prefs.toStatic(t) : undefined
         }
         ,"emojis": this.emojis.version > t ? this.emojis.data : undefined
     };

+ 2 - 4
srv/src/httpServ.js

@@ -196,17 +196,15 @@ Server.prototype.onRequest = function(req, res) {
                 res.end();
             }
         } else if (req.urlObj.match(["api", "markread"])) {
-            if (!req.urlObj.queryTokens.room || !req.urlObj.queryTokens.ts) {
+            if (!req.urlObj.queryTokens.room || !req.urlObj.queryTokens.id) {
                 res.writeHeader("400", "Bad request");
                 res.end();
             } else {
                 var ctx = res.chatContext.getChannelContext(req.urlObj.queryTokens.room[0])
-                    ,ts = parseFloat(req.urlObj.queryTokens.ts[0]);
+                    ,ts = req.urlObj.queryTokens.id[0];
 
                 if (!ctx) {
                     res.writeHeader("404", "Chan Not Found");
-                } else if (isNaN(ts)) {
-                    res.writeHeader("400", "Invalid date");
                 } else {
                     ctx.markRead(ctx.getChatContext().channels[req.urlObj.queryTokens.room[0]], ts);
                     res.writeHeader("204", "No Content");

+ 4 - 0
srv/src/message.js

@@ -294,6 +294,10 @@ RoomHistory.prototype.getMessageById = function(id) {
     return null;
 };
 
+RoomHistory.prototype.last = function() {
+    return this.messages[this.messages.length -1];
+};
+
 /**
  * @return {Array.<*>}
 **/

+ 1 - 2
srv/src/room.js

@@ -20,7 +20,7 @@ function Room(id) {
     /** @type {number} */
     this.lastRead = 0;
     /** @type {number} */
-    this.lastMsg = -1;
+    this.lastMsg;
     /** @type {Object.<string, Chatter>} */
     this.users = {};
     /** @type {string|undefined} */
@@ -104,7 +104,6 @@ Room.prototype.update = function(chanData, ctx, t, idPrefix) {
     if (chanData["last_read"] !== undefined) this.lastRead = Math.max(parseFloat(chanData["last_read"]), this.lastRead);
     if (chanData["last_msg"] !== undefined) this.lastMsg = parseFloat(chanData["last_msg"]);
     if (chanData["is_private"] !== undefined) this.isPrivate = chanData["is_private"];
-    if (chanData["latest"]) this.lastMsg = parseFloat(chanData["latest"]["ts"]);
     if (chanData["is_starred"] !== undefined) this.starred = chanData["is_starred"];
     if (chanData["members"]) {
         this.users = {};

+ 86 - 44
srv/src/slack.js

@@ -58,9 +58,12 @@ function Slack(sess, manager) {
     this.sessId = sess.id;
     this.manager = manager;
     this.rtm = null;
+    this.rtmId = 1;
     this.data = new SlackData(this);
     this.history = {};
     this.pendingRtm = {};
+    this.pendingMessages = [];
+    this.pendingPing = false;
     this.connected = false;
     this.closing = false;
 }
@@ -82,13 +85,14 @@ function httpsRequest(url, cb) {
                 cb(res.statusCode, null);
                 return;
             }
-            var body = null;
+            var body = [];
             res.on('data', (chunk) => {
-                body = body ? Buffer.concat([body, chunk], body.length +chunk.length) : Buffer.from(chunk);
+                body.push(chunk);
             });
             res.on('end', () => {
+                body = Buffer.concat(body).toString();
                 try {
-                    body = JSON.parse(body.toString("utf8"));
+                    body = JSON.parse(body);
                 } catch (e) {}
                 cb && cb(res.statusCode, body);
             });
@@ -110,29 +114,19 @@ Slack.prototype.connect = function(cb) {
             _this.connected = false;
             console.error("Slack api responded " +status);
             cb && cb(_this);
-            return;
-        }
-        if (!body) {
+        } else if (!body || !body.ok) {
             _this.error = "Slack API error";
             _this.connected = false;
             cb && cb(_this);
-            return;
-        }
-        if (!body.ok) {
-            _this.error = body.error;
-            _this.connected = false;
-            console.error("Slack api responded !ok with ", body);
-            cb && cb(_this);
-            return;
+        } else {
+            _this.data.updateStatic({
+                team: body["team"],
+                users: body["users"],
+                bots: body["bots"],
+                self: body["self"]
+            }, Date.now());
+            _this.connectRtm(body.url);
         }
-        _this.getEmojis((emojis) => {
-            _this.getSlashCommands((commands) => {
-                body.emojis = emojis;
-                body.commands = commands;
-                _this.data.updateStatic(body, Date.now());
-                _this.connectRtm(body.url);
-            });
-        });
     });
 };
 
@@ -208,30 +202,56 @@ Slack.prototype.getLiveUpdates = function(knownVersion) {
     return undefined;
 };
 
+Slack.prototype.unstackPendingMessages = function() {
+    for (var i = this.pendingMessages.length -1; i >= 0; i--) {
+        this.onMessage(this.pendingMessages[0], Date.now());
+        this.pendingMessages.unshift();
+    }
+};
+
 Slack.prototype.onMessage = function(msg, t) {
-    if (msg["ok"] === true && msg["reply_to"] && this.pendingRtm[msg["reply_to"]]) {
+    if (msg["reply_to"] && this.pendingRtm[msg["reply_to"]]) {
         var ts = msg["ts"]
             ,rtmId = msg["reply_to"];
         msg = this.pendingRtm[rtmId];
         msg["ts"] = ts;
         delete this.pendingRtm[rtmId];
     }
-    this.data.onMessage(msg, t);
-    if ((msg["channel"] || msg["channel_id"] || (msg["item"] && msg["item"]["channel"])) && msg["type"] && UPDATE_LIVE.indexOf(msg["type"]) !== -1) {
-        var channelId = this.data.team.id +'|' +(msg["channel"] || msg["channel_id"] || msg["item"]["channel"])
-            ,channel = this.data.channels[channelId]
-            ,histo = this.history[channelId];
-        // FIXME remove typing for user
-        if (histo) {
-            var lastMsg = histo.push(msg, t);
-            if (lastMsg)
-                this.data.liveV = t;
-            histo.resort();
-            if (channel)
-                channel.setLastMsg(lastMsg, t);
-        } else if (channel) {
-            this.fetchHistory(channel);
+    if (msg["type"] === "hello" && msg["start"] && msg["start"]["rtm_start"]) {
+        var _this = this;
+        _this.getEmojis((emojis) => {
+            _this.getSlashCommands((commands) => {
+                var msgContent = msg.start.rtm_start;
+                msgContent.self = msg.self;
+                msgContent.emojis = emojis;
+                msgContent.commands = commands;
+
+                _this.data.updateStatic(msgContent, Date.now());
+                _this.unstackPendingMessages();
+                _this.connected = true;
+                _this.unstackPendingMessages();
+            });
+        });
+    } else if (this.connected) {
+        this.data.onMessage(msg, t);
+        if ((msg["channel"] || msg["channel_id"] || (msg["item"] && msg["item"]["channel"])) && msg["type"] && UPDATE_LIVE.indexOf(msg["type"]) !== -1) {
+            var channelId = this.data.team.id +'|' +(msg["channel"] || msg["channel_id"] || msg["item"]["channel"])
+                ,channel = this.data.channels[channelId]
+                ,histo = this.history[channelId];
+            // FIXME remove typing for user
+            if (histo) {
+                var lastMsg = histo.push(msg, t);
+                if (lastMsg)
+                    this.data.liveV = t;
+                histo.resort();
+                if (channel)
+                    channel.setLastMsg(lastMsg, t);
+            } else if (channel) {
+                this.fetchHistory(channel);
+            }
         }
+    } else {
+        this.pendingMessages.push(msg);
     }
 };
 
@@ -239,7 +259,7 @@ Slack.prototype.onMessage = function(msg, t) {
  * @param {SlackChan|SlackGroup|SlackIms} chan
  * @param {number} ts
 **/
-Slack.prototype.markRead = function(chan, ts) {
+Slack.prototype.markRead = function(chan, id) {
     var apiURI;
 
     if (chan.remoteId[0] === 'C')
@@ -252,22 +272,30 @@ Slack.prototype.markRead = function(chan, ts) {
     httpsRequest(apiURI
         +"?token=" +this.token
         +"&channel="+chan.remoteId
-        +"&ts="+ts / 1000);
+        +"&ts="+id);
 };
 
 Slack.prototype.connectRtm = function(url, cb) {
     var _this = this;
 
-    this.rtmId = 0;
+    this.rtmId = 1;
+    var protocol = url.substr(0, url.indexOf('://') +3);
+    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&mpim_aware=false&canonical_avatars=true")
     this.rtm = new WebSocket(url);
     this.rtm.on("message", function(msg) {
         if (!_this.connected && cb) {
             cb();
         }
-        if (!_this.connected) {
-            _this.connected = true;
+        try {
+            msg = JSON.parse(msg);
+        } catch (ex) {
+            console.error("WTF invalid JSON ", msg);
         }
-        _this.onMessage(JSON.parse(msg), Date.now());
+        _this.onMessage(msg, Date.now());
     });
     this.rtm.once("error", function(e) {
         _this.connected = false;
@@ -289,6 +317,20 @@ Slack.prototype.ping = function() {
         +"?token=" +this.token);
 };
 
+Slack.prototype.rtmPing = function() {
+    if (this.connected) {
+        if (this.pendingPing && this.pendingRtm[this.pendingPing]) {
+            //FIXME timeout
+            console.error("Ping timeout");
+        } else {
+            var rtmId = this.rtmId++;
+            this.pendingRtm[rtmId] = { type: 'ping' };
+            this.pendingPing = rtmId;
+            this.rtm.send('{"id":' +rtmId +',"type":"ping"}');
+        }
+    }
+};
+
 Slack.prototype.close = function() {
     if (!this.closing) {
         this.closing = true;

+ 17 - 4
srv/src/slackData.js

@@ -81,7 +81,10 @@ SlackChan.prototype.setNameFromMembers = function() {
  * @param {string=} idPrefix
 **/
 SlackChan.prototype.update = function(chanData, ctx, t, idPrefix) {
-    chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    if (chanData["last_read"] !== undefined)
+        chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    if (chanData["latest"] !== undefined)
+        chanData["last_msg"] = parseFloat(chanData["latest"]) * 1000;
     return Room.prototype.update.call(this, chanData, ctx, t, idPrefix);
 };
 
@@ -107,7 +110,10 @@ SlackIms.prototype.constructor = SlackIms;
  * @param {string=} idPrefix
 **/
 SlackIms.prototype.update = function(chanData, ctx, t, idPrefix) {
-    chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    if (chanData["last_read"] !== undefined)
+        chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    if (chanData["latest"] !== undefined)
+        chanData["last_msg"] = parseFloat(chanData["latest"]) * 1000;
     return PrivateMessageRoom.prototype.update.call(this, chanData, ctx, t, idPrefix);
 };
 
@@ -232,8 +238,15 @@ SlackData.prototype.updateStatic = function(data, t) {
             this.channels[this.team.id +'|' +data["ims"][i]["id"]].update(data["ims"][i], this, t, this.team.id +'|');
         }
     }
-    for (var i =0, nbGroups = data["groups"].length; i < nbGroups; i++) {
-        var groupData = data["groups"][i]
+    if (data["groups"])
+        this.updateGroups(data["groups"], t);
+    if (data["mpims"])
+        this.updateGroups(data["mpims"], t);
+};
+
+SlackData.prototype.updateGroups = function(groupsData, t) {
+    for (var i =0, nbGroups = groupsData.length; i < nbGroups; i++) {
+        var groupData = groupsData[i]
             ,groupObj = this.channels[this.team.id +'|' +groupData["id"]];
 
         if (!groupObj)

+ 9 - 0
srv/src/slackManager.js

@@ -2,6 +2,7 @@
 const Slack = require('./slack.js').Slack
     ,INACTIVE_DELAY = 120000
     ,PING_DELAY = 600000
+    ,RTM_PING_DELAY = 15000
 ;
 
 function SlackManager() {
@@ -17,6 +18,14 @@ setInterval(function() {
     });
 }, PING_DELAY);
 
+setInterval(function() {
+    var keys = instance.cache.keys();
+    keys.forEach(function(instKey) {
+        instance.cache.get(instKey).rtmPing();
+    });
+}, RTM_PING_DELAY);
+
+
 SlackManager.prototype.getScope = function() {
     return [
         "client"