isundil 6 rokov pred
rodič
commit
ea953e189f
3 zmenil súbory, kde vykonal 24 pridanie a 15 odobranie
  1. 1 1
      cli/httpRequest.js
  2. 15 13
      srv/public/mimouchat.min.js
  3. 8 1
      srv/src/slack.js

+ 1 - 1
cli/httpRequest.js

@@ -273,6 +273,6 @@ function HttpRequestWrapper(urlOrMethod, url) {
 }
 
 HttpRequestWrapper.encode = function(str) {
-	return encodeURIComponnent(str);
+	return encodeURIComponent(str);
 }
 

+ 15 - 13
srv/public/mimouchat.min.js

@@ -44,11 +44,11 @@ function $a(a){var b,c=document.getElementById("slashList");c.dataset.cursor&&de
 k-f-1),g){var m=g[h].getName();m.length>=b.length&&m.substr(0,b.length)===b&&d.push(g[h])}else if(":"===e[f]&&window.searchEmojis){b=e.substr(f+1,k-f-1);m=window.searchEmojis(b);for(g in m){var m=window.makeEmoji(g,!1),n=document.createElement("span");n.appendChild(m);n.className="emoji-small";d.push({name:":"+g+":",Ea:n,ra:ab.name})}for(h in Q.b.data)h.length>=b.length&&h.substr(0,b.length)===b&&(g=document.createElement("span"),g.className="emoji-small",g.appendChild(bb(h)),d.push({name:":"+h+":",
 Ea:g,ra:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([f,k]))}}if(!d.length&&"/"===e[0]){h=e.indexOf(" ");f=-1!==h;h=-1===h?e.length:h;b=e.substr(0,h);f?(a=cb.bb(b))&&d.push(a):(d=cb.xb(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=Q?Q.h.data:{};for(var l in a)e=a[l],(!f&&e.name.substr(0,h)===b||f&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.X.localeCompare(b.X)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();h=0;for(a=
 d.length;h<a;h++)if(e=d[h],e instanceof ga){if(!p){var p=!0;l.appendChild(Ya(J.pa))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+pa(e)+'")';l.appendChild(Za("@"+e.getName(),b))}else e instanceof u?(p||(p=!0,l.appendChild(Ya(J.j))),l.appendChild(Za("#"+e.name))):e.Ea?(p!==e.ra&&(p=e.ra,l.appendChild(Ya(e.ra))),l.appendChild(Za(e.name,e.Ea))):(p!==e.X&&(p=e.X,l.appendChild(Ya(e.X))),l.appendChild(Za(e)));c.appendChild(l)}}
-function db(a){if(S)return P("PUT","api/msg?room="+R.id+"&ts="+S.id+"&text="+encodeURIComponent(a)).a(),!0;if("/"===a[0]){var b=a.indexOf(" "),c=a.substr(0,-1===b?void 0:b);a=-1===b?"":a.substr(b);var b=Q,d=cb.bb(c);if(d)return a=a.trim(),d.exec(b,R,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)eb(R,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=Q,f=e,k=[];"#"===f[0]&&(f=f.substr(1));for(var g in d.j)d.j[g].name===f&&k.push(d.j[g]);if(k.length)var h=k[0];else{g=
-[];"@"===e[0]&&(e=e.substr(1));for(h in d.i)d.i[h].getName()===e&&g.push(d.j[h]);if(g.length)for(h=0,d=g.length;h<d;h++)if(g[h].O){h=g[h].O;break a}h=null}}h&&eb(h,b[2],!1)}P("POST","api/cmd?room="+R.id+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)).a();return!0}return!1}h=eb(R,a,!1);fb(R,a,h,T);return!0}function gb(){document.getElementById("msgInput").focus()}
+function db(a){if(S)return P("PUT","api/msg?room="+encodeURIComponent(R.id)+"&ts="+S.id+"&text="+encodeURIComponent(a)).a(),!0;if("/"===a[0]){var b=a.indexOf(" "),c=a.substr(0,-1===b?void 0:b);a=-1===b?"":a.substr(b);var b=Q,d=cb.bb(c);if(d)return a=a.trim(),d.exec(b,R,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)eb(R,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=Q,f=e,k=[];"#"===f[0]&&(f=f.substr(1));for(var g in d.j)d.j[g].name===f&&k.push(d.j[g]);if(k.length)var h=
+k[0];else{g=[];"@"===e[0]&&(e=e.substr(1));for(h in d.i)d.i[h].getName()===e&&g.push(d.j[h]);if(g.length)for(h=0,d=g.length;h<d;h++)if(g[h].O){h=g[h].O;break a}h=null}}h&&eb(h,b[2],!1)}P("POST","api/cmd?room="+encodeURIComponent(R.id)+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)).a();return!0}return!1}h=eb(R,a,!1);fb(R,a,h,T);return!0}function gb(){document.getElementById("msgInput").focus()}
 function hb(a){for(var b=1,c=0,d=a.value.length;c<d;c++)"\n"===a.value[c]&&b++;for(a.rows=Math.min(5,b);5>a.rows&&a.scrollHeight>a.clientHeight;)a.rows++}
-function ib(){var a=0,b=document.getElementById("msgInput");b.addEventListener("input",function(){if(R){var b=Date.now();a+3E3<b&&(Q.self.N||R instanceof t)&&(P("POST","api/typing?room="+R.id).a(),a=b);$a(this);hb(this)}});b.addEventListener("keydown",function(a){if(9===a.keyCode)return a.preventDefault(),!1;if(13===a.keyCode)return a.preventDefault(),a.shiftKey||a.altKey||a.ctrlKey?(a=this.selectionStart,this.value=this.value.substr(0,a)+"\n"+this.value.substr(this.selectionEnd),hb(this),this.selectionStart=
-this.selectionEnd=a+1):jb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(R){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;c.value.length<=a[1]&&(b+=" ");c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);c.selectionStart=c.selectionEnd=a[0]+b.length;$a(c);c.focus();break}b=b.parentElement}}})};var kb=[],lb=0;
+function ib(){var a=0,b=document.getElementById("msgInput");b.addEventListener("input",function(){if(R){var b=Date.now();a+3E3<b&&(Q.self.N||R instanceof t)&&(P("POST","api/typing?room="+encodeURIComponent(R.id)).a(),a=b);$a(this);hb(this)}});b.addEventListener("keydown",function(a){if(9===a.keyCode)return a.preventDefault(),!1;if(13===a.keyCode)return a.preventDefault(),a.shiftKey||a.altKey||a.ctrlKey?(a=this.selectionStart,this.value=this.value.substr(0,a)+"\n"+this.value.substr(this.selectionEnd),
+hb(this),this.selectionStart=this.selectionEnd=a+1):jb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(R){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;c.value.length<=a[1]&&(b+=" ");c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);c.selectionStart=c.selectionEnd=a[0]+b.length;$a(c);c.focus();break}b=b.parentElement}}})};var kb=[],lb=0;
 function mb(){var a=document.createDocumentFragment(),b=xa(function(a){return!a.ia&&!1!==a.ba}),c=[],d=[],e=[],f=[],k={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=D(C.context,a),d=D(C.context,b);a=c.j[a];b=d.j[b];return a.name===b.name?(k[a.id]=J.Da(c.a.name,a.name),k[b.id]=J.Da(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=va(a);if(a instanceof t){var b;if(b=!a.a.Za){var g=k[a.id];b=document.createElement("li");var n=document.createElement("a");
 b.id="room_"+a.id;n.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";n.textContent=g||a.a.getName();b.appendChild(nb());b.appendChild(n);a.a.N||b.classList.add("presence-away");R===a&&b.classList.add("selected");a.I!==a.D&&void 0!==a.I&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=g=b}b&&(a.A?c.push(g):f.push(g))}else if(g=k[a.id],b=document.createElement("li"),n=document.createElement("a"),b.id="room_"+a.id,n.href="#"+a.id,a.h?(b.className="chat-context-room chat-group",
 b.dataset.count=Object.keys(a.i||{}).length):b.className="chat-context-room chat-channel",R===a&&b.classList.add("selected"),n.textContent=g||a.name,b.appendChild(nb()),b.appendChild(n),a.I!==a.D&&void 0!==a.I&&(b.classList.add("unread"),0<=U.indexOf(a)&&b.classList.add("unreadHi")),g=b)a.A?c.push(g):a.h?e.push(g):d.push(g)});c.length&&a.appendChild(ob(J.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(ob(J.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
@@ -58,16 +58,16 @@ function tb(){var a;document.getElementById("whoistyping").textContent="";if(Q&&
 function xb(){var a=R.name||(R.a?R.a.getName():void 0);if(!a){console.error("No name provided for ",R);var a=[],b;for(b in R.i)a.push(R.i[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;yb();gb();document.getElementById("fileUploadContainer").classList.add("hidden");zb();T&&(T=null,V());S&&(S=null,V());tb()}
 function V(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;V()});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="";gb()}
 function Ab(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;Ab()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.L());document.getElementById("msgInput").value=S.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";gb()}
-window.toggleReaction=function(a,b,c){var d=C.a[a],e,f;(d=C.a[a])&&(e=oa(d,b))&&(f=D(C.context,a))&&(e.F[c]&&-1!==e.F[c].indexOf(f.self.id)?P("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)).a():Bb(a,b,c))};function Cb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
+window.toggleReaction=function(a,b,c){var d=C.a[a],e,f;(d=C.a[a])&&(e=oa(d,b))&&(f=D(C.context,a))&&(e.F[c]&&-1!==e.F[c].indexOf(f.self.id)?P("DELETE","api/reaction?room="+encodeURIComponent(a)+"&msg="+b+"&reaction="+encodeURIComponent(c)).a():Bb(a,b,c))};function Cb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
 function wb(){var a=U.length,b="";if(W)b="!"+J.gb+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",Cb(a,a);else{var c=0;ta(C.context,function(a){a.I>a.D&&c++});c&&(b="("+c+")");Cb(0,c)}!b.length&&R&&(b=R.name);b=b.length?b:"Mimouchat";document.title=b;Db(b)}
 function Eb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(lb+3E4<a){var b=new Notification(J.hb);lb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
 function yb(){var a=document.createDocumentFragment(),b=R.id,c=null,d=0,e=null,f;R.A?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");kb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.Z();else{var g=b.M(),k=!1;c&&c.K===b.K&&b.K?30>Math.abs(d-b.m)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,k=!0);(!c||c.m<=R.D)&&b.m>R.D?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
 if(b instanceof z)e=c=null,d=0,a.appendChild(g),f=null;else{if(k||!f)f=Fb(F(b.K),b.username),kb.push(f),a.appendChild(f);c=b;e=g;f.content.appendChild(g)}}});var k=!0;Gb.forEach(function(b){b.channel===R.id&&(k&&(f=Fb(Q.self,""),a.appendChild(f),k=!1),f.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;wb();window.hasFocus&&zb()}
-function Hb(a,b){if(a.classList.contains("chatmsg-hover-reply"))S&&(S=null,Ab()),T!==b&&(T=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=R.id,d=b.id;Ib.ta(document.body,Q,function(a){a&&Bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,V()),S!==b&&(S=b,Ab())):a.classList.contains("chatmsg-hover-star")?b.A?P("DELETE","api/starMsg?room="+R.id+"&msgId="+b.id).a():P("POST","api/starMsg?room="+R.id+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-pin")?
-b.pinned?Jb(R,b):P("POST","api/pinMsg?room="+R.id+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-remove")&&(T&&(T=null,V()),S&&(S=null,Ab()),P("DELETE","api/msg?room="+R.id+"&ts="+b.id).a())}function eb(a,b,c){b={channel:a.id,text:b.trim(),Fa:c,c:Kb(b,c)};Gb.push(b);a===R&&yb();return b}
+function Hb(a,b){if(a.classList.contains("chatmsg-hover-reply"))S&&(S=null,Ab()),T!==b&&(T=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=R.id,d=b.id;Ib.ta(document.body,Q,function(a){a&&Bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,V()),S!==b&&(S=b,Ab())):a.classList.contains("chatmsg-hover-star")?b.A?P("DELETE","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():P("POST","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():
+a.classList.contains("chatmsg-hover-pin")?b.pinned?Jb(R,b):P("POST","api/pinMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-remove")&&(T&&(T=null,V()),S&&(S=null,Ab()),P("DELETE","api/msg?room="+encodeURIComponent(R.id)+"&ts="+b.id).a())}function eb(a,b,c){b={channel:a.id,text:b.trim(),Fa:c,c:Kb(b,c)};Gb.push(b);a===R&&yb();return b}
 function Lb(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("chatmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("chatmsg-hover");){var d;if(c.parentElement&&c.classList.contains("chatmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,f=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(a=oa(C.a[R.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
 Mb(a,a.s[e],a.s[e].actions[f]);break}}if(c.parentElement&&c.parentElement.classList.contains("chatmsg-hover")){if(d=b(a,c))d=d.substr(d.lastIndexOf("_")+1),(a=oa(C.a[R.id],d))&&Hb(c,a);break}c=c.parentElement}}
-function Mb(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 B,message_ts:a.id};P("POST","api/attachmentAction?serviceId="+a.K).a(JSON.stringify(d))}var e=R.id;c.confirm?Xa(Wa(new Ja(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ta():d()}
+function Mb(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 B,message_ts:a.id};P("POST","api/attachmentAction?serviceId="+encodeURIComponent(a.K)).a(JSON.stringify(d))}var e=R.id;c.confirm?Xa(Wa(new Ja(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ta():d()}
 function Nb(){if(!1!==X.a&&!1!==X.b){var a=document.getElementById("chatWindow").getBoundingClientRect().top;kb.forEach(function(b){var c=b.ja,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}}function Ob(){var a=document.getElementById("chatCtx");a.classList.contains("opened")?a.classList.remove("opened"):a.classList.add("opened")}
 document.addEventListener("DOMContentLoaded",function(){za();Pb();ib();var a=document.getElementById("chanSearch");a.addEventListener("input",pb);a.addEventListener("blur",pb);document.getElementById("chatWindow").addEventListener("click",Lb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&qb()});document.addEventListener("mouseover",function(a){a=a.target;if(Qb.Db(a))Qb.aa();else{for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,d=b.indexOf("#");
 if(0<=d){b=b.substr(d+1);if(d=D(C.context,b)){Qb.kb(d,d.j[b]).show(a);return}a:{for(var d=C.context,e=0,f=d.a.length;e<f;e++)if(d.a[e].i[b]){d=d.a[e];break a}d=null}if(d&&(b=d.i[b].O)){Qb.kb(d,b).show(a);return}}}a=a.parentElement}Qb.Ab()}});document.getElementById("chatCtxButton").addEventListener("click",Ob);document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();R&&(R.A?Rb(R):Sb(R));return!1});document.getElementById("fileUploadCancel").addEventListener("click",
@@ -110,18 +110,20 @@ hc.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"
 b}m=d|f},this);(a["static"]||m)&&sb();a.config&&(X=new jc(a.config),Yb());if(Q&&R&&a["static"]&&a["static"][Q.a.id]&&a["static"][Q.a.id].channels&&a["static"][Q.a.id].channels)for(g=a["static"][Q.a.id].channels,h=0,c=g.length;h<c;h++)if(g[h].id===R.id){yb();break}};setInterval(function(){var a=!1,b=Date.now();ua(function(c){var d=!1,e;for(e in c.u){var f=!0,k;for(k in c.u[e])c.u[e][k]+6500<b?(delete c.u[e][k],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&sb()},1E3);
 function ic(a,b,c){var d;if(b!==R||!window.hasFocus){var e=(d=a.self?a.self.id:null)?new RegExp("<@"+d):null,f=!1,k=!1,g=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.D)&&c.user!==a.self.id){k=!0;var d;if(!(d=b instanceof t)&&(d=c.text)&&!(d=e&&c.text.match(e)))a:{d=a.self.T.C;for(var h=0,m=d.length;h<m;h++)if(-1!==c.text.indexOf(d[h])){d=!0;break a}d=!1}d&&(-1===U.indexOf(b)&&(g=!0,U.push(b)),f=!0)}});if(k){wb();var h=document.getElementById("room_"+b.id);h&&(h.classList.add("unread"),f&&h.classList.add("unreadHi"));
 g&&!window.hasFocus&&Eb()}}c.forEach(function(a){if(!d||d===a.K)for(var c=0,e=Gb.length;c<e;c++){var f=Gb[c];if(f.channel===b.id&&!!a.isMeMessage===f.Fa&&(a.pendingId===f.qa&&f.qa||!f.qa&&a.text.trim()===f.text)){Gb.splice(c,1);break}}})}
-function zb(){var a=R,b=U.indexOf(a);if(a.I>a.D){var c=C.a[a.id];c&&(c=na(c))&&(P("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m).a(),a.D=c.m)}0<=b&&(U.splice(b,1),wb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}function kc(){for(var a in C.a)lc(C.a[a]);R&&yb()}C=new hc;var rb=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 f=0;f+l<=n;f+=l)k(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.S?b.S?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].S){d(a[e].src,function(d){a[e].S=d;c(a,b)});return}var g=[];a.forEach(function(a){a.S&&g.push(a.S)});b(g)}function d(a,b){Da(N(P(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=document.createElement("canvas");
+function zb(){var a=R,b=U.indexOf(a);if(a.I>a.D){var c=C.a[a.id];c&&(c=na(c))&&(P("POST","api/markread?room="+encodeURIComponent(a.id)+"&id="+c.id+"&ts="+c.m).a(),a.D=c.m)}0<=b&&(U.splice(b,1),wb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}function kc(){for(var a in C.a)lc(C.a[a]);R&&yb()}C=new hc;var rb=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 f=0;f+l<=n;f+=l)k(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.S?b.S?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].S){d(a[e].src,function(d){a[e].S=d;c(a,b)});return}var g=[];a.forEach(function(a){a.S&&g.push(a.S)});b(g)}function d(a,b){Da(N(P(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=document.createElement("canvas");
 a.height=a.width=A;a=a.getContext("2d");a.drawImage(e,0,0,A,A);var a=a.getImageData(0,0,A,A),c=0,d;for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=(a.data[d]+a.data[d+1]+a.data[d+2])/3,a.data[d+3]=50,c+=a.data[d];if(50>c/(a.height*a.width))for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=255-a.data[d];b(a)};e.onerror=function(){b(null)};e.src=window.URL.createObjectURL(d)}else b(null)}),function(){b(null)}).h("blob").a()}function e(){var a=h.createLinearGradient(0,
 0,0,n);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");h.fillStyle=a;h.fillRect(0,0,m,n);return h.getImageData(0,0,m,n)}function f(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 k(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+p);h.lineTo(c-p+l,d+l/2);h.lineTo(c+l/2,d-p+l);h.lineTo(c+p,d+l/2);h.closePath();h.fill();h.putImageData(f(h.getImageData(c+p,d+p,w,w),b),c+p,d+p)}var g=document.createElement("canvas"),h=g.getContext("2d"),m=g.width=250,n=g.height=290,l=(m-40)/3,p=.1*l,w=Math.floor(l-2*p),A=.5*w,x={},y={},L={};return function(b,d,f){if(x[b])f(x[b]);else if(L[b])y[b]?y[b].push(f):y[b]=[f];else{var h=e(),k=[];L[b]=!0;y[b]?y[b].push(f):y[b]=[f];for(var l in d)d[l].Za||d[l].Cb||k.push({src:pa(d[l])});
 c(k,function(c){a(h,c);x[b]=g.toDataURL();y[b].forEach(function(a){a(x[b])})})}}}();var W=0,R=null,Q=null,T=null,S=null,Gb=[];function Pb(){Da(N(P("highlight.pack.js"),function(a,b,c){a=document.createElement("script");b=document.createElement("link");a.innerHTML=c;a.language="text/javascript";b.href="hljs-androidstudio.css";b.rel="stylesheet";document.head.appendChild(b);document.body.appendChild(a)}),function(){console.error("Failure loading hljs required files")}).o(6E4).a()}
-function mc(){var a=R;Ca(N(P("api/hist?room="+a.id).h("json"),function(b,c,d){if(d){b=C.a[a.id];var e=Date.now();b?c=!!la(b,d,e):(b=C.a[a.id]=new Y(a,100,d,e),c=!0);c&&(b.a.length&&ha(a,na(b).m,e),ic(D(C.context,a.id),a,d),a===R&&yb())}}),function(){}).a()}
+function mc(){var a=R;Ca(N(P("api/hist?room="+encodeURIComponent(a.id)).h("json"),function(b,c,d){if(d){b=C.a[a.id];var e=Date.now();b?c=!!la(b,d,e):(b=C.a[a.id]=new Y(a,100,d,e),c=!0);c&&(b.a.length&&ha(a,na(b).m,e),ic(D(C.context,a.id),a,d),a===R&&yb())}}),function(){}).a()}
 function Yb(){a:{var a=X.U;for(var b in a)if(a.hasOwnProperty(b)){a=!1;break a}a=!0}a&&Ub.Jb(!1).display(Ub.Gb.U);a=X.o;nc(a&&Zb[a]?Zb[a]:oc);!1!==X.b?(document.getElementById("chatWindow").addEventListener("scroll",Nb),Nb()):(kc(),document.getElementById("chatWindow").removeEventListener("scroll",Nb));document.getElementById("customsheet").innerHTML=pc()}
 function Wb(){var a=qc;IS_LOCAL||Ca(P("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?W&&(W=0,vb(!0)):W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,vb(!1));a(b,d)}).h("json").o(6E4).a()}function qc(a,b){a?(b&&C.update(b),Wb()):setTimeout(rc,1E3*W)}function rc(){Wb()}function Db(a){if(Ia()){var b=!(!Q||!Q.W.starChannel);__native.setTitle(a,b,b?R.A:!1)}}
 function sc(a){R&&(document.getElementById("room_"+R.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"));document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");R=a;Q=D(C.context,a.id);Ia()&&__native.setCurrentChannel(a.id);xb();Qb.zb();rb(Q.a.id,Q.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!C.a[R.id]||100>C.a[R.id].a.length)&&mc();document.getElementById("chatSystemContainer").classList.remove("no-room-selected");
-document.getElementById("chatCtx").classList.remove("opened")}function qb(){var a=document.location.hash.substr(1),b=va(a);return b&&b!==R?(sc(b),!0):(a=F(a))&&a.O?(sc(a.O),!0):!1}function Sb(a){P("POST","api/starChannel?room="+a.id).a()}function Rb(a){P("POST","api/unstarChannel?room="+a.id).a()}function Vb(a,b,c){var d=R;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);Da(N(P("POST","api/file?room="+d.id),function(){c(null)}),function(a,b){c(b)}).a(e)}
-function fb(a,b,c,d){b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);d&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:d.text,author_name:F(d.K).getName(),text:d.text,footer:a.h?J.message:a.name,ts:d.m}])));N(P("POST",b).h("json"),function(a,b,d){d&&void 0!==d.pendingId&&(c.qa=d.pendingId)}).a()}function Jb(a,b){P("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id).a()}function Bb(a,b,c){P("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)).a()}
-function Tb(){P("POST","api/logout").a();document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload();Ia()&&__native.logout()}function pb(){var a={},b=[],c=this.value;ta(C.context,function(b){a[b.id]=ia(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].pa+a[d].wa+a[d].sa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Zb={noemoji:{Ga:"noemoji.js",la:null,name:"None"},emojione_v2_3:{Ga:"emojione_v2.3.sprites.js",la:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ga:"emojione_v3.sprites.js",la:"emojione_v3.sprites.css",name:"Emojione v3"}},oc=Zb.emojione_v2_3,ab;
+document.getElementById("chatCtx").classList.remove("opened")}function qb(){var a=document.location.hash.substr(1),b=va(a);return b&&b!==R?(sc(b),!0):(a=F(a))&&a.O?(sc(a.O),!0):!1}function Sb(a){P("POST","api/starChannel?room="+encodeURIComponent(a.id)).a()}function Rb(a){P("POST","api/unstarChannel?room="+encodeURIComponent(a.id)).a()}
+function Vb(a,b,c){var d=R;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);Da(N(P("POST","api/file?room="+encodeURIComponent(d.id)),function(){c(null)}),function(a,b){c(b)}).a(e)}
+function fb(a,b,c,d){b="api/msg?room="+encodeURIComponent(a.id)+"&text="+encodeURIComponent(b);d&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:d.text,author_name:F(d.K).getName(),text:d.text,footer:a.h?J.message:a.name,ts:d.m}])));N(P("POST",b).h("json"),function(a,b,d){d&&void 0!==d.pendingId&&(c.qa=d.pendingId)}).a()}function Jb(a,b){P("DELETE","api/pinMsg?room="+encodeURIComponent(a.id)+"&msgId="+b.id).a()}
+function Bb(a,b,c){P("POST","api/reaction?room="+encodeURIComponent(a)+"&msg="+b+"&reaction="+encodeURIComponent(c)).a()}function Tb(){P("POST","api/logout").a();document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload();Ia()&&__native.logout()}
+function pb(){var a={},b=[],c=this.value;ta(C.context,function(b){a[b.id]=ia(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].pa+a[d].wa+a[d].sa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Zb={noemoji:{Ga:"noemoji.js",la:null,name:"None"},emojione_v2_3:{Ga:"emojione_v2.3.sprites.js",la:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ga:"emojione_v3.sprites.js",la:"emojione_v3.sprites.css",name:"Emojione v3"}},oc=Zb.emojione_v2_3,ab;
 function nc(a){ab!==a&&(console.log("Loading emoji pack "+a.name),N(P(a.Ga),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.la&&(d=document.createElement("link"),d.href=a.la,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");kc();Ib.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}).o(6E4).a(),ab=a)};var Qb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",m.textContent=(r.a.nb||(r.a.ab||"")+" "+r.a.eb).trim(),k.classList.add("presence-indicator"),r.a.N?k.classList.remove("presence-away"):k.classList.add("presence-away"),h.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.Hb||"",w.textContent=r.a.yb||"",p.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
 E;a.W.topic?(h.classList.remove("hidden"),m.textContent=r.wa||"",n.textContent=r.B?J.Ka(r.B,r.ea):""):h.classList.add("hidden");a.W.purpose?(p.classList.remove("hidden"),w.textContent=r.sa||"",A.textContent=r.o?J.Ka(r.o,r.da):""):p.classList.add("hidden");f.style.backgroundImage="";k.classList.remove("presence-indicator");L.textContent=J.pb(r.i?Object.keys(r.i).length:0);a=[];if(r.i)for(var b in r.i)a.push(r.i[b]);a.sort(function(a,b){return a.N&&!b.N?-1:b.N&&!a.N?1:a.getName().localeCompare(b.getName())});
 var c=document.createDocumentFragment();a.forEach(function(a){var b=document.createElement("li"),d=document.createElement("a");d.href="#"+a.id;d.textContent=a.getName();b.appendChild(d);b.classList.add("presence-indicator");a.N||b.classList.add("presence-away");c.appendChild(b)});H.textContent="";H.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){k.textContent=r.name;if(r.b){x.textContent=J.jb(r.b.length);x.classList.remove("hidden");y.classList.remove("hidden");

+ 8 - 1
srv/src/slack.js

@@ -288,10 +288,16 @@ Slack.prototype.onMessage = function(msg, t) {
     if (msg["reply_to"] !== undefined) {
         let rtmId = msg["reply_to"];
         if (this.pendingRtm[rtmId]) {
+            /*
             let ts = msg["ts"]
             msg = this.pendingRtm[rtmId];
             msg["ts"] = ts;
             msg["pendingId"] = this.data.team.id +'_' +rtmId;
+            */
+            for (var i in this.pendingRtm[rtmId])
+                if (msg[i] === undefined)
+                    msg[i] = this.pendingRtm[rtmId][i];
+            msg["pendingId"] = this.data.team.id +'_' +rtmId;
             delete this.pendingRtm[rtmId];
         } else {
             delete msg["reply_to"];
@@ -646,6 +652,7 @@ Slack.prototype.openUploadFileStream = function(channel, contentType, callback)
     });
     return req;
 };
+
 /**
  * @param {SlackChan|SlackGroup|SlackIms} channel
  * @param {string} msgId
@@ -654,7 +661,7 @@ Slack.prototype.openUploadFileStream = function(channel, contentType, callback)
 Slack.prototype.addReaction = function(channel, msgId, reaction) {
     httpsRequest(SLACK_ENDPOINT +GETAPI.addReaction
         +"?token=" +this.token
-        +"&name=" +reaction
+        +"&name=" +encodeURIComponent(reaction)
         +"&channel="+channel.remoteId
         +"&timestamp="+msgId);
 }