Bläddra i källkod

[bugfix] send typing updates independently from live and static
[bugfix] do not send static self pref when not updated
[bugfix] self pref version
[bugfix] Changed typing from 3 to 6 seconds for slack
[bugfix] resolve 3XX http GET when fetching avatar
[bugfix] versions now exprimed in ms instead of nano
[bugfix] send topic creator's name correctly prefixed
[bugfix] do not send medium's relative data in any way
[bugfix][slack] last read ts in millis
[bugfix] do not round ts (may cause troubles with last read ts)

B Thibault 8 år sedan
förälder
incheckning
364808d1c5
12 ändrade filer med 186 tillägg och 115 borttagningar
  1. 10 6
      cli/data.js
  2. 1 1
      cli/ui.js
  3. 1 1
      cli/workflow.js
  4. 41 40
      srv/public/slack.min.js
  5. 42 17
      srv/src/context.js
  6. 23 8
      srv/src/httpServ.js
  7. 1 1
      srv/src/message.js
  8. 23 9
      srv/src/multichatManager.js
  9. 3 3
      srv/src/room.js
  10. 11 6
      srv/src/slack.js
  11. 29 22
      srv/src/slackData.js
  12. 1 1
      srv/src/slackHistory.js

+ 10 - 6
cli/data.js

@@ -40,7 +40,7 @@ SimpleChatSystem.prototype.fetchHistory = function(chan) { console.error("unimpl
 SimpleChatSystem.prototype.sendTyping = function(chan) { console.error("unimplemented"); };
 SimpleChatSystem.prototype.markRead = function(chan, ts) { console.error("unimplemented"); };
 SimpleChatSystem.prototype.sendCommand = function(chan, cmd, args) { console.error("unimplemented"); };
-SimpleChatSystem.prototype.poll = function(knownVersion) { console.error("unimplemented"); return null; };
+SimpleChatSystem.prototype.poll = function(knownVersion, now) { console.error("unimplemented"); return null; };
 
 /**
  * @constructor
@@ -104,12 +104,16 @@ SlackWrapper.prototype.update = function(data) {
     }
     if (data["static"]) {
         onContextUpdated();
-        for (var i in data["static"])
-            if (data["static"][i]["typing"]) {
-                onTypingUpdated();
-                break;
-            }
     }
+    var typingUpdated = false;
+    if (data["typing"]) {
+        this.context.contexts.forEach(function(ctx) {
+            var chatCtx = ctx.getChatContext();
+            typingUpdated |= chatCtx.updateTyping(data["typing"], now);
+        }, this);
+    }
+    if (data["static"] || typingUpdated)
+        onTypingUpdated();
 };
 
 setInterval(function() {

+ 1 - 1
cli/ui.js

@@ -124,7 +124,7 @@ function updateTypingChat() {
     if (SELECTED_CONTEXT && SELECTED_ROOM && (typing = SELECTED_CONTEXT.getChatContext().typing[SELECTED_ROOM.id])) {
         var areTyping = document.createDocumentFragment()
             ,isOutOfSync = false;
-        for (var i in typing[SELECTED_ROOM.id]) {
+        for (var i in typing) {
             var member = DATA.context.getUser(i);
             if (member)
                 areTyping.appendChild(makeUserIsTypingDom(member));

+ 1 - 1
cli/workflow.js

@@ -139,7 +139,7 @@ function selectRoom(room) {
     createContextBackground(SELECTED_CONTEXT.getChatContext().team.id, SELECTED_CONTEXT.getChatContext().users, function(imgData) {
         document.getElementById(R.id.context).style.backgroundImage = 'url(' +imgData +')';
     });
-    if (SELECTED_ROOM.lastMsg && !DATA.history[SELECTED_ROOM.id])
+    if (SELECTED_ROOM.lastMsg !== 0 && !DATA.history[SELECTED_ROOM.id])
         fetchHistory(SELECTED_ROOM, function(success) {});
 }
 

+ 41 - 40
srv/public/slack.min.js

@@ -1,47 +1,47 @@
 "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.u=[]}
-ca.prototype.update=function(a,b){this.ga=JSON.parse(a.emoji_use);a.highlight_words?this.u=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.u=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.F={};this.A=0}
+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}
 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,k=d+b.channels[e].id;var h=b.channels[e];h=h.pv?new q(h.id,a.m[h.user]):new r(h.id);f=f[k]=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.A=Math.max(a.A,c);b.self&&(a.self=a.m[d+b.self.id]||null,a.self?(a.self.N||(a.self.N=new ca),a.self.N.update(b.self.prefs,c)):a.A=0);if(void 0!==b.typing)for(e in a.F={},b.typing){a.F[e]={};for(var n in b.typing[e])a.F[e][n]=c}}"undefined"!==typeof module&&(module.I.Ra=da,module.I.Sa=aa,module.I.Ua=ba);function r(a){this.id=a;this.J=!1;this.w=this.B=0;this.m={};this.version=0}
-r.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.B=Math.max(parseFloat(a.last_read),this.B));void 0!==a.last_msg&&(this.w=parseFloat(a.last_msg));void 0!==a.is_private&&(this.b=a.is_private);a.latest&&(this.w=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 q(a,b){r.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.Ja=this}q.prototype=Object.create(r.prototype);q.prototype.constructor=q;"undefined"!==typeof module&&(module.I.$a=r,module.I.Za=q);function x(a,b){this.H=a.user;this.username=a.username;this.id=a.id||a.ts;this.l=a.ts;this.text="";this.o=[];this.i=this.D=this.J=!1;this.C={};this.version=b;this.update(a,b)}function z(a,b){x.call(this,a,b)}function A(a,b){x.call(this,a,b)}
-x.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.o=a.attachments),this.J=!!a.is_starred,this.D=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.C=c}}else this.i=!0;this.version=b};function B(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}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.Ra=da,module.I.Sa=aa,module.I.Ua=ba);function r(a){this.id=a;this.J=!1;this.C=0;this.A=-1;this.m={};this.version=0}
+r.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 q(a,b){r.call(this,a);this.a=b;this.name=this.a.name;this.b=!0;b.Ja=this}q.prototype=Object.create(r.prototype);q.prototype.constructor=q;"undefined"!==typeof module&&(module.I.$a=r,module.I.Za=q);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 z(a,b){x.call(this,a,b)}function A(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 B(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)}B.prototype.b=function(a,b){return!0===a.isMeMessage?new z(a,b):!0===a.isNotice?new A(a,b):new x(a,b)};B.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})}z.prototype=Object.create(x.prototype);z.prototype.constructor=z;A.prototype=Object.create(x.prototype);A.prototype.constructor=A;"undefined"!==typeof module&&(module.I={Wa:x,Va:z,Ya:A,ab:B});function fa(a){this.id=a;this.j={};this.Ja=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.Ca=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.Na=a.isBot);this.version=Math.max(this.version,b)};"undefined"!==typeof module&&(module.I.Ta=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=C.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function E(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 F(a){for(var b=C.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=C.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 H(a){for(var b=C.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=C.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.Xa=ka);var I={},K;function ra(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(I.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}K=I[c];console.log("Loading language pack: "+c);if(K.c)for(a in K.c)document.getElementById(a).textContent=K.c[a]};I.fr={Qa:"Utilisateur inconnu",Pa:"Channel inconnu",Fa:"Nouveau message",Ea:"Reseau",Ga:"(visible seulement par vous)",J:"Favoris",j:"Discutions",Ia:"Discutions priv\u00e9es",ok:"Ok",Da:"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 !"}};I.fr.D=function(a){return"(edit&eacute; "+I.fr.V(a)+")"};I.en={Qa:"Unknown member",Pa:"Unknown channel",Fa:"New message",Ea:"Network",Ga:"(only visible to you)",J:"Starred",j:"Channels",Ia:"Direct messages",ok:"Ok",Da:"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 !"}};
-I.en.D=function(a){return"(edited "+I.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.qa="_"===this.a;this.ca="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.W=":"===this.a;this.ma="`"===this.a;this.Aa="```"===this.a;this.na="\n"===this.a;this.pa=void 0!==d&&-1!==n.u.indexOf(d);this.g=b;this.da=null;this.b=this.na||this.pa?c+d.length-1:!1;this.pa&&(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 l=
-a.h[c];if(l instanceof b)if(l.b){if(l=d(l))return l}else return l}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,Oa:!1}}var k,h,n={u:[],U:g,aa:g,Z:f};b.prototype.sa=function(){return this.la&&!!this.b||this.g instanceof b&&this.g.sa()};b.prototype.va=function(){return this.qa&&!!this.b||this.g instanceof b&&this.g.va()};b.prototype.wa=function(){return this.ca&&!!this.b||
+neterror:"Impossible de se connecter au chat !"}};I.fr.F=function(a){return"(edit&eacute; "+I.fr.V(a)+")"};I.en={Qa:"Unknown member",Pa:"Unknown channel",Fa:"New message",Ea:"Network",Ga:"(only visible to you)",J:"Starred",j:"Channels",Ia:"Direct messages",ok:"Ok",Da:"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 !"}};
+I.en.F=function(a){return"(edited "+I.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.qa="_"===this.a;this.ca="~"===this.a||"-"===this.a;this.i=">"===this.a||"&gt;"===this.a;this.W=":"===this.a;this.ma="`"===this.a;this.Aa="```"===this.a;this.na="\n"===this.a;this.pa=void 0!==d&&-1!==n.w.indexOf(d);this.g=b;this.da=null;this.b=this.na||this.pa?c+d.length-1:!1;this.pa&&(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,l=a.h.length;c<l;c++){var e=
+a.h[c];if(e instanceof b)if(e.b){if(e=d(e))return e}else return e}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,Oa:!1}}var k,h,n={w:[],U:g,aa:g,Z:f};b.prototype.sa=function(){return this.la&&!!this.b||this.g instanceof b&&this.g.sa()};b.prototype.va=function(){return this.qa&&!!this.b||this.g instanceof b&&this.g.va()};b.prototype.wa=function(){return this.ca&&!!this.b||
 this.g instanceof b&&this.g.wa()};b.prototype.ja=function(){return this.W&&!!this.b||this.g instanceof b&&this.g.ja()};b.prototype.ua=function(){return this.pa&&!!this.b||this.g instanceof b&&this.g.ua()};b.prototype.ta=function(){return this.ma&&!!this.b||this.g instanceof b&&this.g.ta()};b.prototype.ia=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.ia()};b.prototype.xa=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].xa()))return!0;
 return!1};b.prototype.ya=function(a){if("<"===this.a&&">"===k[a])return!0;var b=c(k[a-1]);if(!this.i&&k.substr(a,this.a.length)===this.a){if(!b&&(this.la||this.qa||this.ca))return!1;if(this.f&&this.xa())return this.f.Ba();if(this.Ka())return!0}return"\n"===k[a]&&this.i?!0:!1};b.prototype.Ka=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.Ba=function(){var a=new b(this.g,this.R,this.a);a.da=this;this.f&&
 this.f instanceof b&&(a.f=this.f.Ba(),a.h=[a.f]);return a};b.prototype.La=function(a){return this.W&&(" "===k[a]||"\t"===k[a])||(this.W||this.ba||this.la||this.qa||this.ca||this.ma)&&"\n"===k[a]?!1:!0};b.prototype.Ma=function(b){if(this.ma||this.W||this.Aa||this.ba)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(k[b-1]),e=c(k[b+1]);if("```"===k.substr(b,3))return"```";var f=h.ka();if(void 0===f||f){if("&gt;"===k.substr(b,4))return"&gt;";if(">"===k[b])return k[b]}if("`"===k[b]&&!d||
-"\n"===k[b]||-1!==["*","~","-","_"].indexOf(k[b])&&(e||-1!=="*~-_<&".split("").indexOf(k[b+1]))&&(d||-1!=="*~-_<&".split("").indexOf(k[b-1]))||-1!==[":"].indexOf(k[b])&&e||-1!==["<"].indexOf(k[b]))return k[b];d=0;for(e=n.u.length;d<e;d++)if(f=n.u[d],k.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.na||this.i)return!0};a.prototype.A=
-function(a){this.text+=k[a];return 1};b.prototype.A=function(c){var d=this.f&&!this.f.b&&this.f.ya?this.f.ya(c):null;if(d){var e=this.f.a.length;this.f.ra(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.La(c)){if(d=this.Ma(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.A(c)}d=this.f.R+1;h.ha(this.f.R);this.f=new a(this);this.f.A(d-1);this.h.pop();
+"\n"===k[b]||-1!==["*","~","-","_"].indexOf(k[b])&&(e||-1!=="*~-_<&".split("").indexOf(k[b+1]))&&(d||-1!=="*~-_<&".split("").indexOf(k[b-1]))||-1!==[":"].indexOf(k[b])&&e||-1!==["<"].indexOf(k[b]))return k[b];d=0;for(e=n.w.length;d<e;d++)if(f=n.w[d],k.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.na||this.i)return!0};a.prototype.B=
+function(a){this.text+=k[a];return 1};b.prototype.B=function(c){var d=this.f&&!this.f.b&&this.f.ya?this.f.ya(c):null;if(d){var e=this.f.a.length;this.f.ra(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.La(c)){if(d=this.Ma(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();
 this.h.push(this.f);return d-c};b.prototype.ra=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(){var a;if(this.g.ja()){for(a=this.g;a&&!a.W;)a=a.g;if(a){var b=a.a+this.text+a.a;return(a=n.U(b))?a:b}return(a=n.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(t){console.error(t)}return this.text.replace(/\n/g,"<br/>")}return n.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.ta()?(b.push("code"),d=this.innerHTML()):(this.g.ba&&(d=n.Z(this.text))?(a="a",c=' href="'+d.link+'"',d.bb&&(c+=' target="_blank"'),
 d=n.aa(d.text)):d=this.innerHTML(),this.g.sa()&&b.push("bold"),this.g.va()&&b.push("italic"),this.g.wa()&&b.push("strike"),this.g.ja()&&b.push("emoji"),this.g.ua()&&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.na&&(a+="<br/>");this.h.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="</span>");return a};b.prototype.za=function(a){this.i&&!this.b&&this.ra(a);this.h.forEach(function(c){c instanceof
-b&&c.za(a)})};return function(c,m){m||(m={});n.u=m.u||[];n.U=m.U||g;n.aa=m.aa||g;n.Z=m.Z||f;k=c;h=new b(this,0);m=0;c=k.length;do{for(;m<c;)m+=h.A(m);h.za(k.length);if(m=d()){e(m,!1);h.ha(m.R);var l=new a(m.g);l.A(m.R);m.g.h.push(l);m.g.f=l;m=m.R+1}else m=void 0}while(void 0!==m);return h.outerHTML()}}();window._formatText=function(a,b){return sa(a,{u:b?b.highlights:void 0})};"undefined"!==typeof module&&(module.I.s=sa);function ta(a,b){this.i=a;this.content=b;this.c=ua(this);this.b=va(this);this.a=[];this.A=[]}
+b&&c.za(a)})};return function(c,m){m||(m={});n.w=m.w||[];n.U=m.U||g;n.aa=m.aa||g;n.Z=m.Z||f;k=c;h=new b(this,0);m=0;c=k.length;do{for(;m<c;)m+=h.B(m);h.za(k.length);if(m=d()){e(m,!1);h.ha(m.R);var l=new a(m.g);l.B(m.R);m.g.h.push(l);m.g.f=l;m=m.R+1}else m=void 0}while(void 0!==m);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=[]}
 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=K.Da;b.b.addEventListener("click",function(){L(a,!1)});e.addEventListener("click",function(){L(a,!1)});b.a.addEventListener("click",function(){L(a,!0)});f.appendChild(b.b);b.a.className=Aa;b.a.textContent=K.ok;f.appendChild(b.a);f.className=Ba+" "+Ca;b.appendChild(f);b.className=Da;return b}function L(a,b){(b?a.a:a.A).forEach(function(a){a()});a.close()}
+za;b.appendChild(g);b.b.className=Aa;b.b.textContent=K.Da;b.b.addEventListener("click",function(){L(a,!1)});e.addEventListener("click",function(){L(a,!1)});b.a.addEventListener("click",function(){L(a,!0)});f.appendChild(b.b);b.a.className=Aa;b.a.textContent=K.ok;f.appendChild(b.a);f.className=Ba+" "+Ca;b.appendChild(f);b.className=Da;return b}function L(a,b){(b?a.a:a.B).forEach(function(a){a()});a.close()}
 function va(a){var b=document.createElement("div");b.className=Ea;b.addEventListener("click",function(){L(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]:F(a).name.localeCompare(F(b).name)});b.forEach(function(a){a=F(a);if(a instanceof q){if(!a.a.Ca){var b=document.createElement("li");var f=document.createElement("a");b.id="room_"+a.id;f.href="#"+a.id;b.className="slack-context-room slack-ims";f.textContent=a.a.name;b.appendChild(Ka());b.appendChild(f);a.a.a||b.classList.add("away");M===
-a&&b.classList.add("selected");a.w>a.B&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi"));b&&(a.J?c.push(b):g.push(b))}}else b=document.createElement("li"),f=document.createElement("a"),b.id="room_"+a.id,f.href="#"+a.id,a.b?(b.className="slack-context-room slack-group",b.dataset.count=Object.keys(a.m||{}).length):b.className="slack-context-room slack-channel",M===a&&b.classList.add("selected"),f.textContent=a.name,b.appendChild(Ka()),b.appendChild(f),a.w>a.B&&(b.classList.add("unread"),
+a&&b.classList.add("selected");a.A>a.C&&(b.classList.add("unread"),0<=N.indexOf(a)&&b.classList.add("unreadHi"));b&&(a.J?c.push(b):g.push(b))}}else b=document.createElement("li"),f=document.createElement("a"),b.id="room_"+a.id,f.href="#"+a.id,a.b?(b.className="slack-context-room slack-group",b.dataset.count=Object.keys(a.m||{}).length):b.className="slack-context-room slack-channel",M===a&&b.classList.add("selected"),f.textContent=a.name,b.appendChild(Ka()),b.appendChild(f),a.A>a.C&&(b.classList.add("unread"),
 0<=N.indexOf(a)&&b.classList.add("unreadHi")),b&&(a.J?c.push(b):a.b?e.push(b):d.push(b))});c.length&&a.appendChild(La(K.J));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(La(K.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});g.length&&a.appendChild(La(K.Ia));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ma();O();P&&Na(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage=
-"url("+a+")"})}function Oa(){oa(function(a){var b=a.F,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].Ja)&&!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(P&&M&&(a=P.F[M.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a[M.id])(a=H(d))?b.appendChild(Qa(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ra(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()}
+"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].Ja)&&!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(P&&M&&(a=P.o[M.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=H(d))?b.appendChild(Qa(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ra(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");O()}
 function Sa(){var a=M.name||(M.a?M.a.name:void 0);if(!a){var b=[];M.m.forEach(function(a){b.push(a.name)});a=b.join(", ")}document.getElementById("currentRoomTitle").textContent=a;Ta();Q();document.getElementById("fileUploadContainer").classList.add("hidden");Ua();S&&(S=null,T());U&&(U=null,T());Pa()}
 function T(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;T()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.L())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";Q()}
 function V(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.L());document.getElementById("msgInput").value=U.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";Q()}
-window.toggleReaction=function(a,b,c){var d=C.a[a],e,g;(d=C.a[a])&&(e=ja(d,b))&&(g=E(C.context,a))&&(e.C[c]&&-1!==e.C[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=C.a[a],e,g;(d=C.a[a])&&(e=ja(d,b))&&(g=E(C.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))};
 function Wa(a){a:{var b={};if(P){var c;for(c=P;!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 O(){var a=N.length,b="";if(W)b="!"+K.Ea+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Xa(a,a);else{var c=0;na(C.context,function(a){a.w>a.B&&c++});c&&(b="("+c+") - ");Xa(0,c)}C.context.b&&(b+=C.context.b.name);document.title=b}
+function O(){var a=N.length,b="";if(W)b="!"+K.Ea+" - ",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+") - ",Xa(a,a);else{var c=0;na(C.context,function(a){a.A>a.C&&c++});c&&(b="("+c+") - ");Xa(0,c)}C.context.b&&(b+=C.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(K.Fa);Ia=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function Ta(){var a=document.createDocumentFragment(),b=M.id,c=null,d=0,e=null,g;Ha=[];C.a[b]&&C.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 z)?e.classList.add("slackmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=M.B)&&b.l>M.B?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof z)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=H(b.H),n=b.username,l=document.createElement("div"),
+function Ta(){var a=document.createDocumentFragment(),b=M.id,c=null,d=0,e=null,g;Ha=[];C.a[b]&&C.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 z)?e.classList.add("slackmsg-same-ts"):d=b.l:(d=b.l,h=!0);(!c||c.l<=M.C)&&b.l>M.C?f.classList.add("slackmsg-first-unread"):f.classList.remove("slackmsg-first-unread");if(b instanceof z)e=c=null,d=0,a.appendChild(f),g=null;else{if(h||!g){var h=H(b.H),n=b.username,l=document.createElement("div"),
 m=document.createElement("div"),t=document.createElement("span");l.S=document.createElement("img");l.S.className="slackmsg-author-img";t.className="slackmsg-author-name";h?(t.textContent=h.name,l.S.src="api/avatar?user="+h.id):(t.textContent=n||"?",l.S.src="");m.appendChild(l.S);m.appendChild(t);m.className="slackmsg-author";l.className="slackmsg-authorGroup";l.appendChild(m);l.content=document.createElement("div");l.content.className="slackmsg-author-messages";l.appendChild(l.content);g=l;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){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,d,e=a.target;e!==a.currentTarget&&e&&!e.classList.contains("slackmsg-hover");){if(e.parentElement&&e.classList.contains("slackmsg-attachment-actions-item")){d=b(a,e);var g=e.dataset.attachmentIndex,f=e.dataset.actionIndex;if(d&&void 0!==g&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(c=ja(C.a[M.id],d))&&c.o[g]&&c.o[g].actions&&c.o[g].actions[f]&&
-$a(c,c.o[g],c.o[g].actions[f]);break}}if(e.parentElement&&e.parentElement.classList.contains("slackmsg-hover")){if(d=b(a,e))d=d.substr(d.lastIndexOf("_")+1),(c=ja(C.a[M.id],d))&&e.classList.contains("slackmsg-hover-reply")?(U&&(U=null,V()),S!==c&&(S=c,T())):c&&e.classList.contains("slackmsg-hover-reaction")?ab.$(document.body,P,function(a){a&&Va(M.id,c.id,a)}):c&&e.classList.contains("slackmsg-hover-edit")?(S&&(S=null,T()),U!==c&&(U=c,V())):c&&e.classList.contains("slackmsg-hover-remove")&&(S&&(S=
+function Za(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,d,e=a.target;e!==a.currentTarget&&e&&!e.classList.contains("slackmsg-hover");){if(e.parentElement&&e.classList.contains("slackmsg-attachment-actions-item")){d=b(a,e);var g=e.dataset.attachmentIndex,f=e.dataset.actionIndex;if(d&&void 0!==g&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(c=ja(C.a[M.id],d))&&c.s[g]&&c.s[g].actions&&c.s[g].actions[f]&&
+$a(c,c.s[g],c.s[g].actions[f]);break}}if(e.parentElement&&e.parentElement.classList.contains("slackmsg-hover")){if(d=b(a,e))d=d.substr(d.lastIndexOf("_")+1),(c=ja(C.a[M.id],d))&&e.classList.contains("slackmsg-hover-reply")?(U&&(U=null,V()),S!==c&&(S=c,T())):c&&e.classList.contains("slackmsg-hover-reaction")?ab.$(document.body,P,function(a){a&&Va(M.id,c.id,a)}):c&&e.classList.contains("slackmsg-hover-edit")?(S&&(S=null,T()),U!==c&&(U=c,V())):c&&e.classList.contains("slackmsg-hover-remove")&&(S&&(S=
 null,T()),U&&(U=null,V()),bb(c));break}e=e.parentElement}}function $a(a,b,c){function d(){var d=JSON.stringify({actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof A,message_ts:a.id}),f=a.H,k=new FormData,h=new XMLHttpRequest;k.append("payload",d);k.append("service_id",f);h.open("POST","api/attachmentAction");h.send(k)}var e=M.id;c.confirm?Ga(Fa(new ta(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).$():d()}
 function Q(){document.getElementById("msgInput").focus()}function Ma(){var a=document.location.hash.substr(1),b=F(a);b&&b!==M?cb(b):(a=H(a))&&a.b&&cb(a.b)}function db(){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();eb();document.getElementById("chatWindow").addEventListener("click",Za);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=
@@ -50,16 +50,16 @@ document.getElementById("attachFile").addEventListener("click",function(a){a.pre
 !1});window.addEventListener("focus",function(){window.hasFocus=!0;Ia=0;M&&Ua();Q()});document.getElementById("chatWindow").addEventListener("scroll",db);var a=0;document.getElementById("msgInput").addEventListener("input",function(){if(M){var b=Date.now();a+3E3<b&&(P.self.a||M instanceof q)&&(hb(),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=P?P.i.data:{};for(k in g){var f=g[k];(!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 k=document.getElementById("slashList");var d=document.createDocumentFragment();k.textContent="";e=0;for(c=b.length;e<c;e++){g=b[e];if(h!==g.T){var h=g.T;d.appendChild(ib(g.T))}d.appendChild(jb(g))}k.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(){P&&ab.$(document.body,P,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");Q()})})}else a.classList.add("hidden")})();kb()});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 lb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("ul"),g=document.createElement("li");c.o=document.createElement("ul");c.C=document.createElement("ul");c.l=document.createElement("div");c.oa=document.createElement("div");c.fa=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.l.className="slackmsg-ts";c.oa.className="slackmsg-msg";c.fa.className="slackmsg-author-name";e.className="slackmsg-hover";g.className=
+function lb(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.oa=document.createElement("div");c.fa=document.createElement("span");c.id=b+"_"+a.id;c.className="slackmsg-item";c.l.className="slackmsg-ts";c.oa.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"),k=window.makeEmoji("arrow_heading_down"),h=window.makeEmoji("smile"),n=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")';k?(g.classList.add("emoji-small"),g.appendChild(k)):g.style.backgroundImage='url("repl.svg")';e.appendChild(f);qa(a.H)&&(a=document.createElement("li"),
 a.className="slackmsg-hover-edit",n?a.classList.add("emoji-small"):a.style.backgroundImage='url("edit.svg")',a.appendChild(n),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.oa);d.appendChild(c.l);d.appendChild(c.o);c.D=document.createElement("div");c.D.className="slackmsg-edited";d.appendChild(c.D);d.appendChild(c.C);d.className="slackmsg-content";c.o.className="slackmsg-attachments";c.C.className="slackmsg-reactions";c.appendChild(d);c.appendChild(e);return c}
+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.oa);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={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
 function nb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),g=document.createElement("div"),f=document.createElement("a"),k=document.createElement("div"),h=document.createElement("img"),n=document.createElement("a"),l=document.createElement("div"),m=document.createElement("div"),t=document.createElement("div"),w=document.createElement("img"),v=document.createElement("div");d.className="slackmsg-attachment";e.style.borderColor=mb(b.color||"");e.className="slackmsg-attachment-block";
-g.className="slackmsg-attachment-pretext";b.pretext?g.innerHTML=a.s(b.pretext):g.classList.add("hidden");f.target="_blank";b.title?(f.innerHTML=a.s(b.title),b.title_link&&(f.href=b.title_link),f.className="slackmsg-attachment-title"):f.className="hidden slackmsg-attachment-title";n.target="_blank";k.className="slackmsg-author";b.author_name&&(n.innerHTML=a.s(b.author_name),n.href=b.author_link||"",n.className="slackmsg-author-name",h.className="slackmsg-author-img",b.author_icon&&(h.src=b.author_icon,
-k.appendChild(h)),k.appendChild(n));t.className="slackmsg-attachment-thumb";b.thumb_url?(h=document.createElement("img"),h.src=b.thumb_url,t.appendChild(h),e.classList.add("has-thumb"),b.video_html&&(t.dataset.video=b.video_html)):t.classList.add("hidden");l.className="slackmsg-attachment-content";h=a.s(b.text||"");m.className="slackmsg-attachment-text";h&&""!=h?m.innerHTML=h:m.classList.add("hidden");w.className="slackmsg-attachment-img";b.image_url?w.src=b.image_url:w.classList.add("hidden");v.className=
-"slackmsg-attachment-footer";b.footer&&(h=document.createElement("span"),h.className="slackmsg-attachment-footer-text",h.innerHTML=a.s(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="slackmsg-attachment-footer-icon",v.appendChild(n)),v.appendChild(h));b.ts&&(h=document.createElement("span"),h.className="slackmsg-ts",h.innerHTML=K.V(b.ts),v.appendChild(h));l.appendChild(t);l.appendChild(m);e.appendChild(f);e.appendChild(k);e.appendChild(l);e.appendChild(w);
-if(b.fields&&b.fields.length){var u=document.createElement("ul");e.appendChild(u);u.className="slackmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),g=document.createElement("div"),f=document.createElement("div");e.className="field";b||e.classList.add("field-long");g.className="field-title";g.textContent=c;f.className="field-text";f.innerHTML=a.s(d);e.appendChild(g);e.appendChild(f);e&&u.appendChild(e)})}if(b.actions&&
+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";n.target="_blank";k.className="slackmsg-author";b.author_name&&(n.innerHTML=a.u(b.author_name),n.href=b.author_link||"",n.className="slackmsg-author-name",h.className="slackmsg-author-img",b.author_icon&&(h.src=b.author_icon,
+k.appendChild(h)),k.appendChild(n));t.className="slackmsg-attachment-thumb";b.thumb_url?(h=document.createElement("img"),h.src=b.thumb_url,t.appendChild(h),e.classList.add("has-thumb"),b.video_html&&(t.dataset.video=b.video_html)):t.classList.add("hidden");l.className="slackmsg-attachment-content";h=a.u(b.text||"");m.className="slackmsg-attachment-text";h&&""!=h?m.innerHTML=h:m.classList.add("hidden");w.className="slackmsg-attachment-img";b.image_url?w.src=b.image_url:w.classList.add("hidden");v.className=
+"slackmsg-attachment-footer";b.footer&&(h=document.createElement("span"),h.className="slackmsg-attachment-footer-text",h.innerHTML=a.u(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="slackmsg-attachment-footer-icon",v.appendChild(n)),v.appendChild(h));b.ts&&(h=document.createElement("span"),h.className="slackmsg-ts",h.innerHTML=K.V(b.ts),v.appendChild(h));l.appendChild(t);l.appendChild(m);e.appendChild(f);e.appendChild(k);e.appendChild(l);e.appendChild(w);
+if(b.fields&&b.fields.length){var u=document.createElement("ul");e.appendChild(u);u.className="slackmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),f=document.createElement("div"),g=document.createElement("div");e.className="field";b||e.classList.add("field-long");f.className="field-title";f.textContent=c;g.className="field-text";g.innerHTML=a.u(d);e.appendChild(f);e.appendChild(g);e&&u.appendChild(e)})}if(b.actions&&
 b.actions.length)for(f=document.createElement("ul"),f.className="slackmsg-attachment-actions "+Ba,e.appendChild(f),k=0,l=b.actions.length;k<l;k++)(m=b.actions[k])&&(m=ob(c,k,m))&&f.appendChild(m);e.appendChild(v);d.appendChild(g);d.appendChild(e);return d}
 function ob(a,b,c){var d=document.createElement("li"),e=mb(c.style);d.textContent=c.text;e!==mb()&&(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 ib(a){var b=document.createElement("lh");b.textContent=a;b.className="slack-command-header";return b}
@@ -70,25 +70,26 @@ c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}funct
 G=document.createElement("span"),Z=document.createElement("span"),D,R;n.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()});n.className="emojibar-overlay";h.className="emojibar";l.className="emojibar-emojis";J.className="emojibar-detail";G.className="emojibar-detail-img";Z.className="emojibar-detail-name";m.className=t.className="emojibar-list";w.className="emojibar-search";J.appendChild(G);J.appendChild(Z);
 l.appendChild(f(window.emojiProviderHeader));l.appendChild(m);l.appendChild(f("emojicustom.png"));l.appendChild(t);h.appendChild(l);h.appendChild(J);h.appendChild(w);w.addEventListener("keyup",function(){d()});h.addEventListener("mousemove",function(b){a(b,function(a){var b=a?v[a]||u[a]:null;b?(G.innerHTML=b.c.outerHTML,Z.textContent=":"+a+":"):(G.textContent="",Z.textContent="")})});h.addEventListener("click",function(b){a(b,function(a){a&&c()&&D&&D(a)})});return{isSupported:k,$:function(a,b,c){return k()?
 (R=b,D=c,a.appendChild(n),a.appendChild(h),w.value="",d(),w.focus(),!0):!1},search:d,close:b}}();var C,N=[];function pb(){da.call(this)}pb.prototype=Object.create(da.prototype);pb.prototype.constructor=pb;function ma(a){return a.b?a.b.id:null}function qb(){this.b=0;this.context=new ka;this.a={}}
-qb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(var c in a["static"]){var d=la(this.context,c);d||(d=new pb,this.context.push(d));ea(d,a["static"][c],b)}na(this.context,function(a){a.w===a.B&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(c in a.live)(d=this.a[c])?ga(d,a.live[c],b):d=this.a[c]=new X(c,250,a.live[c],b);for(var e in a.live)d=E(this.context,e),(b=d.j[e])?(this.a[e].a.length&&(b.w=Math.max(b.w,ia(this.a[e]).l)),b.Y||(rb(d,b,a.live[e]),M&&
-a.live[M.id]&&Ta())):C.b=0}if(a["static"])for(c in Ja(),a["static"])if(a["static"][c].typing){Oa();break}};setInterval(function(){var a=!1,b=Date.now();oa(function(c){var d=!1,e;for(e in c.F){var g=!0,f;for(f in c.F[e])c.F[e][f]+3E3<b?(delete c.F[e][f],d=!0):g=!1;g&&(delete c.F[e],d=!0)}d&&(a=!0)});a&&Oa()},1E3);
-function rb(a,b,c){if(b!==M||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,g=!1,f=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.B)){g=!0;var h;if(!(h=b instanceof q)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.N.u;for(var k=0,l=h.length;k<l;k++)if(-1!==c.text.indexOf(h[k])){h=!0;break a}h=!1}h&&(-1===N.indexOf(b)&&(f=!0,N.push(b)),e=!0)}});if(g){O();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Ya()}}}
-function Ua(){var a=M,b=N.indexOf(a);if(a.w>a.B){var c=new XMLHttpRequest;c.open("POST","api/markread?room="+a.id+"&ts="+a.w,!0);c.send(null);a.B=a.w}0<=b&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new qb;var Na=function(){function a(a,b){b.sort(function(){return Math.random()-.5});for(var c=0,d=20;d<h-40;d+=l)for(var e=0;e+l<=n;e+=l)g(a,b[c],d,e),c++,c===b.length&&(b.sort(function(a,b){return a.X?b.X?Math.random()-.5:-1:1}),c=0)}function b(a,d){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].X){c(a[e].src,function(c){a[e].X=c;b(a,d)});return}var g=[];a.forEach(function(a){a.X&&g.push(a.X)});d(g)}function c(a,b){var c=new XMLHttpRequest;c.responseType="blob";c.onreadystatechange=function(){if(4===
+qb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(var c in a["static"]){var d=la(this.context,c);d||(d=new pb,this.context.push(d));ea(d,a["static"][c],b)}na(this.context,function(a){a.A===a.C&&(a=N.indexOf(a),-1!==a&&N.splice(a,1))});if(a.live){for(c in a.live)(d=this.a[c])?ga(d,a.live[c],b):d=this.a[c]=new X(c,250,a.live[c],b);for(var e in a.live)d=E(this.context,e),(c=d.j[e])?(this.a[e].a.length&&(c.A=Math.max(c.A,ia(this.a[e]).l)),c.Y||(rb(d,c,a.live[e]),M&&
+a.live[M.id]&&Ta())):C.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 l in c.o)e[l]||(delete c.o[l],f=!0);if(e)for(l in e)if(c.j[l]){c.o[l]||(c.o[l]={});for(var m in e[l])c.o[l][m]||(f=!0),c.o[l][m]=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 rb(a,b,c){if(b!==M||!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 q)&&(h=c.text)&&!(h=c.text.match(d)))a:{h=a.self.N.w;for(var k=0,l=h.length;k<l;k++)if(-1!==c.text.indexOf(h[k])){h=!0;break a}h=!1}h&&(-1===N.indexOf(b)&&(f=!0,N.push(b)),e=!0)}});if(g){O();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");f&&!window.hasFocus&&Ya()}}}
+function Ua(){var a=M,b=N.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&&(N.splice(b,1),O());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new qb;var Na=function(){function a(a,b){b.sort(function(){return Math.random()-.5});for(var c=0,d=20;d<h-40;d+=l)for(var e=0;e+l<=n;e+=l)g(a,b[c],d,e),c++,c===b.length&&(b.sort(function(a,b){return a.X?b.X?Math.random()-.5:-1:1}),c=0)}function b(a,d){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].X){c(a[e].src,function(c){a[e].X=c;b(a,d)});return}var g=[];a.forEach(function(a){a.X&&g.push(a.X)});d(g)}function c(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=w;c=c.getContext("2d");c.drawImage(a,0,0,w,w);for(var c=c.getImageData(0,0,w,w),d=0,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 d(){var a=k.createLinearGradient(0,0,0,n);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");k.fillStyle=a;k.fillRect(0,0,h,n);return k.getImageData(0,0,h,n)}function e(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 g(a,b,c,d){var f=Math.floor(d);a=[a.data[f*h*4+0],a.data[f*h*4+1],a.data[f*h*4+2]];k.fillStyle=
 "#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);k.beginPath();k.moveTo(c+l/2,d+m);k.lineTo(c-m+l,d+l/2);k.lineTo(c+l/2,d-m+l);k.lineTo(c+m,d+l/2);k.closePath();k.fill();k.putImageData(e(k.getImageData(c+m,d+m,t,t),b),c+m,d+m)}var f=document.createElement("canvas"),k=f.getContext("2d"),h=f.width=250,n=f.height=290,l=(h-40)/3,m=.1*l,t=Math.floor(l-2*m),w=.5*t,v={},u={},J={};return function(c,e,g){if(v[c])g(v[c]);else if(J[c])u[c]?u[c].push(g):u[c]=[g];else{var h=d(),k=[];J[c]=!0;u[c]?u[c].push(g):
 u[c]=[g];for(var l in e)e[l].Ca||e[l].Na||k.push({src:"api/avatar?user="+e[l].id});b(k,function(b){a(h,b);v[c]=f.toDataURL();u[c].forEach(function(a){a(v[c])})})}}}();var W=0,M=null,P=null,S=null,U=null;function eb(){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 sb(){var a=new XMLHttpRequest;a.open("GET","api/hist?room="+M.id,!0);a.send(null)}
 function tb(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){W&&(W=0,Ra(!0));c=b.response;try{c=JSON.parse(c)}catch(e){c=null}}else W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,Ra(!1));a(d,c)}else W&&(W=0,Ra(!0)),tb(a)};b.open("GET","api?v="+C.b,!0);b.send(null)}function hb(){var a=new XMLHttpRequest;a.open("POST","api/typing?room="+M.id,!0);a.send(null)}
-function ub(a,b){a?(b&&C.update(b),kb()):setTimeout(kb,1E3*W)}function kb(){tb(ub)}function cb(a){M&&document.getElementById("room_"+M.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");M=a;P=E(C.context,a.id);Sa();Na(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});M.w&&!C.a[M.id]&&sb()}
+function ub(a,b){a?(b&&C.update(b),kb()):setTimeout(kb,1E3*W)}function kb(){tb(ub)}function cb(a){M&&document.getElementById("room_"+M.id).classList.remove("selected");document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");M=a;P=E(C.context,a.id);Sa();Na(P.b.id,P.m,function(a){document.getElementById("slackCtx").style.backgroundImage="url("+a+")"});M.A&&!C.a[M.id]&&sb()}
 function fb(a,b,c){var d=M;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 gb(a){if(U){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+M.id+"&ts="+U.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=P)?c.i.data[b]:null)?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+M.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}var b=M,c=S,d=new XMLHttpRequest;a="api/msg?room="+b.id+"&text="+
 encodeURIComponent(a);if(c){var e=H(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 bb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+M.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 X(a,b,c,d){B.call(this,a,b,c,d)}X.prototype=Object.create(B.prototype);X.prototype.constructor=X;X.prototype.b=function(a,b){return!0===a.isMeMessage?new vb(this.id,a,b):!0===a.isNotice?new wb(this.id,a,b):new xb(this.id,a,b)};
-var Y=function(){function a(a,c){return sa(c,{u:a.context.self.N.u,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(b){a:{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=H(d))b=!0,f="@"+f.name;else{d=null;break a}else if("#"===d[0])if(d=ma(a.context)+"|"+d.substr(1),
-f=F(d))b=!0,f="#"+f.name;else{d=null;break a}else b=!1;d={link:d,text:f||d,Oa:b}}return d}})}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=H(b.H);b.c.l.innerHTML=K.V(b.l);b.c.oa.innerHTML=a(b,b.text);b.c.fa.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),d=0,e=b.o.length;d<e;d++){var g=b.o[d];g&&(g=nb(b,g,d))&&c.appendChild(g)}b.c.o.textContent=
-"";b.c.o.appendChild(c);c=b.b;d=document.createDocumentFragment();if(b.C)for(var f in b.C){var e=c,g=b.id,k=f,h=b.C[f],n=Wa(k);if(n){for(var l=document.createElement("li"),m=document.createElement("a"),t=document.createElement("span"),w=document.createElement("span"),v=[],u=0,J=h.length;u<J;u++){var G=H(h[u]);G&&v.push(G.name)}v.sort();w.textContent=v.join(", ");t.appendChild(n);t.className="emoji-small";m.href="javascript:toggleReaction('"+e+"', '"+g+"', '"+k+"')";m.appendChild(t);m.appendChild(w);
-l.className="slackmsg-reaction-item";l.appendChild(m);e=l}else console.warn("Reaction id not found: "+k),e=null;e&&d.appendChild(e)}b.c.C.textContent="";b.c.C.appendChild(d);b.D&&(b.c.D.innerHTML=K.D(b.D),b.c.classList.add("edited"));return b},L:function(a){return a.c.cloneNode(!0)},s:function(b,c){return a(b,c)}}}();function vb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}vb.prototype=Object.create(z.prototype);p=vb.prototype;p.constructor=vb;p.G=function(){return Y.G(this)};
-p.s=function(a){return Y.s(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=lb(this);this.c.classList.add("slackmsg-me_message");return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){z.prototype.update.call(this,a,b);this.G()};function xb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}xb.prototype=Object.create(x.prototype);p=xb.prototype;p.constructor=xb;p.G=function(){return Y.G(this)};
-p.s=function(a){return Y.s(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=lb(this);return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){x.prototype.update.call(this,a,b);this.G()};function wb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.a=null;this.O=!0}wb.prototype=Object.create(A.prototype);p=wb.prototype;p.constructor=wb;p.G=function(){return Y.G(this)};
-p.s=function(a){return Y.s(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(){Y.M(this);return this.a};p.L=function(){return this.a.cloneNode(!0)};p.ea=function(){this.c=lb(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=K.Ga;this.a.appendChild(this.c);return this};p.K=function(){Y.K(this);return this};
+var Y=function(){function a(a,c){return sa(c,{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(b){a:{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=H(d))b=!0,f="@"+f.name;else{d=null;break a}else if("#"===d[0])if(d=ma(a.context)+"|"+d.substr(1),
+f=F(d))b=!0,f="#"+f.name;else{d=null;break a}else b=!1;d={link:d,text:f||d,Oa:b}}return d}})}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=H(b.H);b.c.l.innerHTML=K.V(b.l);b.c.oa.innerHTML=a(b,b.text);b.c.fa.textContent=c?c.name:b.username||"?";for(var c=document.createDocumentFragment(),d=0,e=b.s.length;d<e;d++){var g=b.s[d];g&&(g=nb(b,g,d))&&c.appendChild(g)}b.c.s.textContent=
+"";b.c.s.appendChild(c);c=b.b;d=document.createDocumentFragment();if(b.D)for(var f in b.D){var e=c,g=b.id,k=f,h=b.D[f],n=Wa(k);if(n){for(var l=document.createElement("li"),m=document.createElement("a"),t=document.createElement("span"),w=document.createElement("span"),v=[],u=0,J=h.length;u<J;u++){var G=H(h[u]);G&&v.push(G.name)}v.sort();w.textContent=v.join(", ");t.appendChild(n);t.className="emoji-small";m.href="javascript:toggleReaction('"+e+"', '"+g+"', '"+k+"')";m.appendChild(t);m.appendChild(w);
+l.className="slackmsg-reaction-item";l.appendChild(m);e=l}else console.warn("Reaction id not found: "+k),e=null;e&&d.appendChild(e)}b.c.D.textContent="";b.c.D.appendChild(d);b.F&&(b.c.F.innerHTML=K.F(b.F),b.c.classList.add("edited"));return b},L:function(a){return a.c.cloneNode(!0)},u:function(b,c){return a(b,c)}}}();function vb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}vb.prototype=Object.create(z.prototype);p=vb.prototype;p.constructor=vb;p.G=function(){return Y.G(this)};
+p.u=function(a){return Y.u(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=lb(this);this.c.classList.add("slackmsg-me_message");return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){z.prototype.update.call(this,a,b);this.G()};function xb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.c=Y.c;this.O=Y.O}xb.prototype=Object.create(x.prototype);p=xb.prototype;p.constructor=xb;p.G=function(){return Y.G(this)};
+p.u=function(a){return Y.u(this,a)};p.P=function(){return Y.P(this)};p.M=function(){return Y.M(this)};p.ea=function(){this.c=lb(this);return this};p.L=function(){return Y.L(this)};p.K=function(){Y.K(this);return this};p.update=function(a,b){x.prototype.update.call(this,a,b);this.G()};function wb(a,b,c){x.call(this,b,c);this.context=E(C.context,a);this.b=a;this.a=null;this.O=!0}wb.prototype=Object.create(A.prototype);p=wb.prototype;p.constructor=wb;p.G=function(){return Y.G(this)};
+p.u=function(a){return Y.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(){Y.M(this);return this.a};p.L=function(){return this.a.cloneNode(!0)};p.ea=function(){this.c=lb(this);this.a=document.createElement("span");this.c.classList.add("slackmsg-notice");this.a.className="slackmsg-notice";this.a.textContent=K.Ga;this.a.appendChild(this.c);return this};p.K=function(){Y.K(this);return this};
 p.update=function(a,b){A.prototype.update.call(this,a,b);this.G()};
 })();

+ 42 - 17
srv/src/context.js

@@ -63,6 +63,9 @@ function SelfPreferences() {
 
     /** @type {Array.<string>} */
     this.highlights = [];
+
+    /** @type {number} */
+    this.version = 0;
 };
 
 /**
@@ -80,7 +83,7 @@ SelfPreferences.prototype.update = function(prefs, t) {
 };
 
 SelfPreferences.prototype.toStatic = function(t) {
-    return this.version > t ? null : {
+    return this.version <= t ? undefined : {
         "emoji_use": JSON.stringify(this.favoriteEmojis)
         ,"highlights": this.highlights
     };
@@ -173,7 +176,7 @@ ChatContext.prototype.updateStatic = function(data, t, idPrefix) {
     this.staticV = Math.max(this.staticV, t);
     if (data["self"]) {
         this.self = this.users[idPrefix +data["self"]["id"]] || null;
-        if (this.self) {
+        if (this.self && data["self"]["prefs"]) {
             if (!this.self.prefs)
                 this.self.prefs = new SelfPreferences();
             this.self.prefs.update(data["self"]["prefs"], t);
@@ -181,21 +184,37 @@ ChatContext.prototype.updateStatic = function(data, t, idPrefix) {
             this.staticV = 0;
         }
     }
-    if (data["typing"] !== undefined) {
-        this.typing = {};
-        for (var i in data["typing"]) {
-            this.typing[i] = {};
-            for (var j in data["typing"][i])
-                this.typing[i][j] = t;
+};
+
+ChatContext.prototype.updateTyping = function(typing, now) {
+    var updated = false;
+
+    if (this.typing)
+        for (var i in this.typing)
+            if (!typing[i]) {
+                delete (this.typing[i]);
+                updated = true;
+            }
+    if (typing) {
+        for (var i in typing) {
+            if (this.channels[i]) {
+                if (!this.typing[i])
+                    this.typing[i] = {};
+                for (var j in typing[i]) {
+                    if (!this.typing[i][j])
+                        updated = true;
+                    this.typing[i][j] = now;
+                }
+            }
         }
     }
+    return updated;
 };
 
 /**
  * @param {number} t
- * @param {number} now
 **/
-ChatContext.prototype.toStatic = function(t, now) {
+ChatContext.prototype.toStatic = function(t) {
     var channels = []
         ,users = [];
     var res = {
@@ -226,23 +245,29 @@ ChatContext.prototype.toStatic = function(t, now) {
     }
     if (users.length)
         res["users"] = users;
+    return res;
+};
+
+ChatContext.prototype.getWhoIsTyping = function(now) {
+    var res;
     for (var typingChan in this.typing) {
         var tChan = null;
         for (var typingUser in this.typing[typingChan]) {
-            if (this.typing[typingChan][typingUser] +3000 >= now) {
-                if (!tChan) tChan = {};
+            if (this.typing[typingChan][typingUser] >= now) {
+                if (!tChan)
+                    tChan = {};
                 tChan[typingUser] = 1;
             } else {
                 delete this.typing[typingChan][typingUser];
             }
         }
         if (tChan) {
-            if (res["typing"] === undefined)
-                res["typing"] = {};
-            res["typing"][typingChan] = tChan;
-        }
-        else
+            if (!res)
+                res = {};
+            res[typingChan] = tChan;
+        } else {
             delete this.typing[typingChan];
+        }
     }
     return res;
 };

+ 23 - 8
srv/src/httpServ.js

@@ -73,6 +73,26 @@ function redirectToSlackAuth(res) {
     res.end();
 }
 
+function recursiveGet(url, cb, redirectLoop) {
+    var getFnc = http.get;
+
+    if (url.substr(0, 8) === "https://")
+        getFnc = https.get;
+    getFnc(url, (d) => {
+        if (d.statusCode >= 300 && d.statusCode < 400 && d.headers["location"]) {
+            if (!redirectLoop)
+                redirectLoop = [];
+
+            if (redirectLoop.indexOf(d.headers["location"]) === -1 && redirectLoop.length < 5) {
+                redirectLoop.push(d.headers["location"]);
+                recursiveGet(d.headers["location"], cb, redirectLoop);
+                return;
+            }
+        }
+        cb(d);
+    });
+};
+
 Server.prototype.onRequest = function(req, res) {
     req.reqT = Date.now();
     req.cookies = Server.parseCookies(req);
@@ -208,14 +228,9 @@ Server.prototype.onRequest = function(req, res) {
                     var url = user.getSmallIcon();
                     if (!config.isDebug)
                         res.setHeader('Cache-Control', 'private, max-age=' +60 * 60); // 1 hour cache for avatars
-                    if (url.substr(0, 7) === "http://")
-                        http.get(url, (d) => {
-                            d.pipe(res, { end: true });
-                        });
-                    else if (url.substr(0, 8) === "https://")
-                        https.get(url, (d) => {
-                            d.pipe(res, { end: true });
-                        });
+                    recursiveGet(url, (d) => {
+                        d.pipe(res, { end: true });
+                    });
                 }
             }
             sessionManager.saveSession(req.session);

+ 1 - 1
srv/src/message.js

@@ -15,7 +15,7 @@ function Message(e, ts) {
     this.id = e["id"] || e["ts"];
 
     /** @const @type {number} **/
-    this.ts = e["ts"];
+    this.ts = parseFloat(e["ts"]);
 
     /** @type {string} */
     this.text = "";

+ 23 - 9
srv/src/multichatManager.js

@@ -96,9 +96,10 @@ ChatSystem.prototype.sendCommand = function(chan, cmd, args) {};
 
 /**
  * @param {number} knownVersion
+ * @param {number} nowTs
  * @return {Object|null}
 **/
-ChatSystem.prototype.poll = function(knownVersion) {};
+ChatSystem.prototype.poll = function(knownVersion, nowTs) {};
 
 /**
  * @constructor
@@ -220,25 +221,37 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
         ctx.onRequest();
     });
     setTimeout((function() {
-        var liveFeed = {}
-            ,hasLive = false
-            ,staticFeed = {}
+        //FIXME polling
+        var liveFeed
+            ,staticFeed
+            ,allTyping
             ,v = 0
-            ,updated = false;
+            ,updated = false
+            ,now = Date.now();
 
         this.contexts.forEach(function(ctx) {
             var id = ctx.getId();
             if (id) {
-                var res = ctx.poll(knownVersion);
+                var res = ctx.poll(knownVersion, now);
 
                 if (res) {
-                    if (res["static"])
+                    if (res["static"]) {
+                        if (!staticFeed)
+                            staticFeed = {};
                         staticFeed[id] = res["static"];
+                    }
                     if (res["live"])
+                        if (!liveFeed)
+                            liveFeed = {};
                         for (var i in res["live"]) {
                             liveFeed[i] = res["live"][i];
-                            hasLive = true;
                         }
+                    if (res["typing"]) {
+                        if (!allTyping)
+                            allTyping = {};
+                        for (var i in res["typing"])
+                            allTyping[i] = res["typing"][i];
+                    }
                     v = Math.max(v, (res["v"] || 0));
                     updated = true;
                 }
@@ -246,8 +259,9 @@ MultiChatManager.prototype.poll = function(knownVersion, callback) {
         });
         if (updated)
             callback({
-                "live": hasLive ? liveFeed : undefined,
+                "live": liveFeed,
                 "static": staticFeed,
+                "typing": allTyping,
                 "v": Math.max(v, knownVersion)
             });
         else

+ 3 - 3
srv/src/room.js

@@ -20,7 +20,7 @@ function Room(id) {
     /** @type {number} */
     this.lastRead = 0;
     /** @type {number} */
-    this.lastMsg = 0;
+    this.lastMsg = -1;
     /** @type {Object.<string, Chatter>} */
     this.users = {};
     /** @type {string|undefined} */
@@ -116,12 +116,12 @@ Room.prototype.update = function(chanData, ctx, t, idPrefix) {
     }
     if (chanData["topic"]) {
         this.topic = chanData["topic"]["value"];
-        this.topicCreator = ctx.users[chanData["topic"]["creator"]];
+        this.topicCreator = ctx.users[idPrefix +chanData["topic"]["creator"]];
         this.topicTs = chanData["topic"]["last_set"];
     }
     if (chanData["purpose"]) {
         this.purpose = chanData["purpose"]["value"];
-        this.purposeCreator = ctx.users[chanData["purpose"]["creator"]];
+        this.purposeCreator = ctx.users[idPrefix +chanData["purpose"]["creator"]];
         this.purposeTs = chanData["purpose"]["last_set"];
     }
     this.version = Math.max(this.version, t);

+ 11 - 6
srv/src/slack.js

@@ -169,15 +169,17 @@ Slack.prototype.getEmojis = function(cb) {
     });
 };
 
-Slack.prototype.poll = function(knownVersion) {
+Slack.prototype.poll = function(knownVersion, now) {
     if (this.connected) {
-        var updatedCtx = this.data.getUpdates(knownVersion, Date.now())
+        var updatedCtx = this.data.getUpdates(knownVersion)
+            ,updatedTyping = this.data.getWhoIsTyping(now)
             ,updatedLive = this.getLiveUpdates(knownVersion);
 
-        if (updatedCtx || updatedLive) {
+        if (updatedCtx || updatedLive || updatedTyping) {
             return {
                 "static": updatedCtx,
                 "live": updatedLive,
+                "typing": updatedTyping,
                 "v": Math.max(this.data.liveV, this.data.staticV)
             };
         }
@@ -250,7 +252,7 @@ Slack.prototype.markRead = function(chan, ts) {
     httpsRequest(apiURI
         +"?token=" +this.token
         +"&channel="+chan.remoteId
-        +"&ts="+ts);
+        +"&ts="+ts / 1000);
 };
 
 Slack.prototype.connectRtm = function(url, cb) {
@@ -530,9 +532,12 @@ Slack.prototype.fetchHistory = function(target) {
                 history = _this.history[target.id] = new SlackHistory(target.remoteId, target.id, this.data.team.id +'|', HISTORY_LENGTH);
                 history.isNew = true;
             }
-            var now = Date.now();
-            if (history.pushAll(resp.messages, now))
+            var now = Date.now()
+                ,lastTs = history.pushAll(resp.messages, now);
+
+            if (lastTs)
                 this.data.liveV = now;
+            target.setLastMsg(lastTs, now);
         }
     });
 };

+ 29 - 22
srv/src/slackData.js

@@ -6,6 +6,8 @@ const ChatContext = require('./context.js').ChatContext
     ,Chatter = require('./chatter.js').Chatter
     ,PrivateMessageRoom = require('./room.js').PrivateMessageRoom;
 
+const SLACK_TYPING_DELAY = 6000;
+
 /**
  * @constructor
  * @extends {ChatInfo}
@@ -34,25 +36,6 @@ function SlackTeam(teamId) {
 SlackTeam.prototype = Object.create(ChatInfo.prototype);
 SlackTeam.prototype.constructor = SlackTeam;
 
-SlackTeam.prototype.toStatic = function(t) {
-    var res = ChatInfo.prototype.toStatic.call(this, t);
-    if (res) {
-        res["domain"] = this.domain
-        res["prefs"] = {
-            "calling_app_id": this.callApp
-            ,"calling_app_name": this.callAppName
-            ,"disable_file_uploads": this.fileUploadPermission
-            ,"disable_file_editing": this.fileEditPermission
-            ,"disable_file_deleting": this.fileDeletePermission
-        }
-        res["icon"] = {
-            "small": this.icons.small
-            ,"large": this.icons.large
-        };
-    }
-    return res;
-};
-
 SlackTeam.prototype.update = function(teamData, t) {
     ChatInfo.prototype.update.call(this, teamData, t);
     if (teamData["domain"] !== undefined) this.domain = teamData["domain"];
@@ -91,6 +74,17 @@ SlackChan.prototype.setNameFromMembers = function() {
     this.name = userNames.join(", ");
 };
 
+/**
+ * @param {*} chanData
+ * @param {ChatContext} ctx
+ * @param {number} t
+ * @param {string=} idPrefix
+**/
+SlackChan.prototype.update = function(chanData, ctx, t, idPrefix) {
+    chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    return Room.prototype.update.call(this, chanData, ctx, t, idPrefix);
+};
+
 /**
  * @constructor
  * @extends {PrivateMessageRoom}
@@ -106,6 +100,17 @@ function SlackIms(teamId, id, user) {
 SlackIms.prototype = Object.create(PrivateMessageRoom.prototype);
 SlackIms.prototype.constructor = SlackIms;
 
+/**
+ * @param {*} chanData
+ * @param {ChatContext} ctx
+ * @param {number} t
+ * @param {string=} idPrefix
+**/
+SlackIms.prototype.update = function(chanData, ctx, t, idPrefix) {
+    chanData["last_read"] = parseFloat(chanData["last_read"]) * 1000;
+    return PrivateMessageRoom.prototype.update.call(this, chanData, ctx, t, idPrefix);
+};
+
 /**
  * @constructor
  * @extends {Chatter}
@@ -281,13 +286,15 @@ SlackData.prototype.onMessage = function(msg, t) {
             member.setPresence(msg["presence"], t);
         this.staticV = Math.max(this.staticV, t);
     } else if (msg["type"] === "user_typing") {
-        this.typing[this.team.id +'|' +msg["channel"]] = this.typing[this.team.id +'|' +msg["channel"]] || {};
-        this.typing[this.team.id +'|' +msg["channel"]][this.team.id +'|' +msg["user"]] = t;
+        var chanId = this.team.id +'|' +msg["channel"];
+        if (!this.typing[chanId])
+            this.typing[chanId] = {};
+        this.typing[chanId][this.team.id +'|' +msg["user"]] = t +SLACK_TYPING_DELAY;
         this.staticV = Math.max(this.staticV, t);
     } else if (msg["type"] === "im_marked" || msg["type"] === "channel_marked" || msg["type"] === "group_marked") {
         var channel = this.channels[this.team.id +'|' +msg["channel"]];
         if (channel) {
-            channel.lastRead = parseFloat(msg["ts"]);
+            channel.lastRead = parseFloat(msg["ts"]) * 1000;
             this.staticV = channel.version = Math.max(channel.version, t);
         }
     }

+ 1 - 1
srv/src/slackHistory.js

@@ -69,7 +69,7 @@ SlackHistory.prototype.push = function(ev, t) {
             if (modifArg["edited"])
                 modifArg["edited"] = Math.round(parseFloat(modifArg["edited"]["ts"]) * 1000);
             if (modifArg["ts"])
-                modifArg["ts"] = Math.round(parseFloat(modifArg["ts"]) * 1000);
+                modifArg["ts"] = parseFloat(modifArg["ts"]) * 1000;
             if (!modifArg["id"])
                 modifArg["id"] = targetId;
             if (modifArg["attachments"] && modifArg["attachments"].length)