Files
owncast/static/web/_next/static/chunks/9991.14ecac8798f42524.js
2023-06-15 04:36:12 +00:00

1 line
8.1 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9991],{39991:function(e,n,t){"use strict";t.r(n),t.d(n,{ChatModerationActionMenu:function(){return L}});var a=t(85893),s=t(85402),o=t(12461),r=t(66516),l=t(13013),i=t(26713),c=t(67294),d=t(5152),u=t.n(d),h=t(29614),p=t(54907),m=t(71230),x=t(15746),j=t(71577),y=t(11382),f=t(20550),b=t(54398),g=t(58091),v=t(4511),k=class{static async removeMessage(e,n){let t=new URL("/api/chat/messagevisibility",window.location.toString());t.searchParams.append("accessToken",n);let a=t.toString(),s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idArray:[e]})};await fetch(a,s)}static async banUser(e,n){let t=new URL("/api/chat/users/setenabled",window.location.toString());t.searchParams.append("accessToken",n);let a=t.toString(),s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})};await fetch(a,s)}},w=t(78948),M=t.n(w),C=t(37135),_=t(69183);let{Panel:S}=p.default,P=u()(()=>Promise.all([t.e(2074),t.e(7949)]).then(t.t.bind(t,77949,23)),{loadableGenerated:{webpack:()=>[77949]},ssr:!1}),Z=async(e,n)=>{try{k.removeMessage(e,n)}catch(e){console.error(e)}},A=e=>{let{label:n,value:t}=e;return(0,a.jsxs)(m.Z,{justify:"space-around",align:"middle",children:[(0,a.jsx)(x.Z,{span:12,children:n}),(0,a.jsx)(x.Z,{span:12,children:t})]})},N=e=>{let{client:n}=e,{messageCount:t,connectedAt:s,geo:o}=n,r=(0,g.Z)(new Date(s),"PP pp");return(0,a.jsxs)("div",{children:[(0,a.jsx)(A,{label:"Messages Sent",value:"".concat(t)}),"N/A"!==o&&(0,a.jsx)(A,{label:"Geo",value:o}),(0,a.jsx)(A,{label:"Connected At",value:r})]})},O=e=>{let{color:n}=e;return(0,a.jsxs)("div",{className:M().colorBlock,style:{backgroundColor:"var(--theme-color-users-".concat(n,")")},children:["Color ",n]})},D=e=>{let{userId:n,accessToken:t}=e,[s,o]=(0,c.useState)(null),[r,l]=(0,c.useState)(!0),i=async()=>{try{let e=await (await fetch("/api/moderation/chat/user/".concat(n,"?accessToken=").concat(t))).json();o(e),l(!1)}catch(e){console.error(e)}};if((0,c.useEffect)(()=>{i()},[]),!s)return null;let{user:d,connectedClients:u,messages:h}=s,{displayColor:m,createdAt:x,previousNames:k,scopes:w,isBot:M,authenticated:D}=d,T=u.reduce((e,n)=>e+n.messageCount,0),B=(0,g.Z)(new Date(x),"PP pp"),G=[{title:"Message",dataIndex:"body",key:"body"},{title:"Sent At",dataIndex:"timestamp",key:"timestamp",render:e=>(0,g.Z)(new Date(e),"PP pp")},{title:"Delete",key:"delete",render:(e,n)=>(0,a.jsx)(j.Z,{type:"primary",ghost:!0,icon:(0,a.jsx)(P,{}),onClick:()=>Z(n.id,t)})}];return(0,a.jsx)(v.SV,{fallbackRender:e=>{let{error:n,resetErrorBoundary:t}=e;return(0,a.jsx)(_.A,{componentName:"ChatModerationDetailsModal",message:n.message,retryFunction:t})},children:(0,a.jsxs)(y.Z,{spinning:r,children:[(0,a.jsx)(O,{color:m}),null==w?void 0:w.map(e=>(0,a.jsx)(f.Z,{children:e},e)),D&&(0,a.jsx)(f.Z,{children:"Authenticated"}),M&&(0,a.jsx)(f.Z,{children:"Bot"}),(0,a.jsx)(A,{label:"Messages Sent Across Clients",value:T.toString()}),(0,a.jsx)(A,{label:"User Created",value:B}),(0,a.jsx)(A,{label:"Known As",value:k.join(",")}),(0,a.jsxs)(p.default,{accordion:!0,children:[(0,a.jsx)(S,{header:"Currently Connected Clients",children:(0,a.jsx)(p.default,{accordion:!0,children:u.map(e=>(0,a.jsx)(S,{header:(0,C.AB)(e.userAgent),children:(0,a.jsx)(N,{client:e})},e.id))})},"connected-clients"),(0,a.jsx)(p.default,{accordion:!0,children:(0,a.jsx)(S,{header:"Recent Chat Messages",children:(0,a.jsx)(b.Z,{size:"small",pagination:null,columns:G,dataSource:h,rowKey:"id"})},"chat-messages")})]})]})})};var T=t(94318),B=t.n(T);let{confirm:G}=s.default,I=u()(()=>Promise.all([t.e(2074),t.e(4337)]).then(t.t.bind(t,74337,23)),{loadableGenerated:{webpack:()=>[74337]},ssr:!1}),F=u()(()=>Promise.all([t.e(2074),t.e(7039)]).then(t.t.bind(t,67039,23)),{loadableGenerated:{webpack:()=>[67039]},ssr:!1}),R=u()(()=>Promise.all([t.e(2074),t.e(4645)]).then(t.t.bind(t,84645,23)),{loadableGenerated:{webpack:()=>[84645]},ssr:!1}),U=u()(()=>Promise.all([t.e(2074),t.e(500)]).then(t.t.bind(t,40500,23)),{loadableGenerated:{webpack:()=>[40500]},ssr:!1}),L=e=>{let{messageID:n,userID:t,userDisplayName:s,accessToken:d}=e,[u,p]=(0,c.useState)(!1),m=async()=>{try{await k.banUser(t,d)}catch(e){console.error(e),o.ZP.error(e)}},x=async()=>{try{await k.removeMessage(n,d)}catch(e){console.error(e),o.ZP.error(e)}},j=async()=>{G({icon:(0,a.jsx)(F,{}),content:"Are you sure you want to remove this message from ".concat(s,"?"),onOk(){x()}})},y=async()=>{G({icon:(0,a.jsx)(F,{}),content:"Are you sure you want to ban ".concat(s," from chat?"),onOk(){m()}})},f=(0,a.jsx)(r.Z,{onClick:e=>{let{key:n}=e;"hide-message"===n?j():"ban-user"===n?y():"more-info"===n&&p(!0)},items:[{label:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:B().icon,children:(0,a.jsx)(R,{})}),"Hide Message"]}),key:"hide-message"},{label:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:B().icon,children:(0,a.jsx)(I,{})}),"Ban User"]}),key:"ban-user"},{label:(0,a.jsx)("div",{children:"More Info..."}),key:"more-info"}]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{overlay:f,trigger:["click"],children:(0,a.jsx)("button",{type:"button",onClick:e=>e.preventDefault(),children:(0,a.jsx)(i.Z,{children:(0,a.jsx)(U,{})})})}),(0,a.jsx)(h.Modal,{title:s,open:u,handleCancel:()=>{p(!1)},children:(0,a.jsx)(D,{userId:t,accessToken:d})})]})}},29614:function(e,n,t){"use strict";t.r(n),t.d(n,{Modal:function(){return h}});var a=t(85893),s=t(85402),o=t(26303),r=t(11382),l=t(67294),i=t(4511),c=t(69183),d=t(70051),u=t.n(d);let h=e=>{let{title:n,url:t,open:d,handleOk:h,handleCancel:p,afterClose:m,height:x,width:j,children:y}=e,[f,b]=(0,l.useState)(!!t),g="100%",v="520px";t&&(g="70vh",v="900px");let k={padding:"0px",minHeight:x,height:null!=x?x:g},w=t&&(0,a.jsx)("iframe",{title:n,src:t,width:"100%",height:"100%",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",frameBorder:"0",allowFullScreen:!0,style:{display:"block"},onLoad:()=>b(!1)});return(0,a.jsx)(s.default,{title:n,open:d,onOk:h,onCancel:p,afterClose:m,bodyStyle:k,width:null!=j?j:v,zIndex:999,footer:null,centered:!0,destroyOnClose:!0,className:u().modal,children:(0,a.jsx)(i.SV,{fallbackRender:e=>{let{error:n,resetErrorBoundary:t}=e;return(0,a.jsx)(c.A,{componentName:"Modal",message:n.message,retryFunction:t})},children:(0,a.jsxs)("div",{id:"modal-container",style:{height:"100%"},children:[f&&(0,a.jsx)(o.Z,{active:f,style:{padding:"10px"},paragraph:{rows:10}}),w&&(0,a.jsx)("div",{style:{display:f?"none":"inline"},children:w}),y&&(0,a.jsx)("div",{className:u().content,children:y}),f&&(0,a.jsx)(r.Z,{className:u().spinner,spinning:f,size:"large"})]})})})};n.default=h,h.defaultProps={url:void 0,children:void 0,handleOk:void 0,handleCancel:void 0,afterClose:void 0}},37135:function(e,n,t){"use strict";t.d(n,{AB:function(){return c},Qr:function(){return r},t5:function(){return o},wS:function(){return i}});var a=t(42238),s=t.n(a);function o(e){let n=e.split(":");n[n.length-1]="";let t=n.join(":");return"[::1]"===(t=t.slice(0,t.length-1))||"127.0.0.1"===t?"Localhost":t}function r(e){return!e||0===Object.keys(e).length&&e.constructor===Object}function l(e,n,t){return String(n.repeat(t)+e).slice(-t)}function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=Number.isFinite(+e)?Math.abs(e):0,t=Math.floor(n/86400),a=t>0?"".concat(t," day").concat(t>1?"s":""," "):"",s=Math.floor(n/3600%24),o=s||t?l("".concat(s,":"),"0",3):"",r=l("".concat(Math.floor(n/60%60),":"),"0",3),i=l("".concat(Math.floor(n%60)),"0",2);return a+o+r+i}function c(e){let n=s()(e),{device:t,os:a,browser:o}=n,{major:r,name:l}=o,{version:i,name:c}=a,{model:d,type:u}=t;if("libmpv"===e)return"mpv media player";if(!l||!r||!c)return e;let h=d||u?" (".concat(d||u,")"):"";return"".concat(l," ").concat(r," on ").concat(c," ").concat(i,"\n ").concat(h)}},94318:function(e){e.exports={icon:"ChatModerationActionMenu_icon__9j6DF"}},78948:function(e){e.exports={modalContainer:"ChatModerationDetailsModal_modalContainer__czndV",chatHistory:"ChatModerationDetailsModal_chatHistory__PunRk",colorBlock:"ChatModerationDetailsModal_colorBlock___rAlw",displayName:"ChatModerationDetailsModal_displayName__p7pLI"}},70051:function(e){e.exports={spinner:"Modal_spinner__GiSS0",content:"Modal_content__h9my9",modal:"Modal_modal__i0TOf"}}}]);