Files
owncast/static/web/_next/static/chunks/4860.43cdb62aae48289c.js
2023-01-30 17:44:49 +00:00

1 line
7.6 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4860],{94860: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),h=t.n(d),u=t(14761),p=t(54907),x=t(71230),j=t(15746),m=t(71577),y=t(11382),b=t(20550),f=t(54398),g=t(58091),v=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({id:e})};await fetch(a,s)}},w=t(57761),k=t.n(w),C=t(70241);let{Panel:M}=p.Z,_=h()(()=>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{v.removeMessage(e,n)}catch(e){console.error(e)}},S=e=>{let{label:n,value:t}=e;return(0,a.jsxs)(x.Z,{justify:"space-around",align:"middle",children:[(0,a.jsx)(j.Z,{span:12,children:n}),(0,a.jsx)(j.Z,{span:12,children:t})]})},P=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)(S,{label:"Messages Sent",value:"".concat(t)}),"N/A"!==o&&(0,a.jsx)(S,{label:"Geo",value:o}),(0,a.jsx)(S,{label:"Connected At",value:r})]})},A=e=>{let{color:n}=e;return(0,a.jsxs)("div",{className:k().colorBlock,style:{backgroundColor:"var(--theme-color-users-".concat(n,")")},children:["Color ",n]})},N=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:h,messages:u}=s,{displayColor:x,createdAt:j,previousNames:v,scopes:w,isBot:k,authenticated:N}=d,O=h.reduce((e,n)=>e+n.messageCount,0),D=(0,g.Z)(new Date(j),"PP pp");return(0,a.jsxs)(y.Z,{spinning:r,children:[(0,a.jsx)(A,{color:x}),w.map(e=>(0,a.jsx)(b.Z,{children:e},e)),N&&(0,a.jsx)(b.Z,{children:"Authenticated"}),k&&(0,a.jsx)(b.Z,{children:"Bot"}),(0,a.jsx)(S,{label:"Messages Sent Across Clients",value:O.toString()}),(0,a.jsx)(S,{label:"User Created",value:D}),(0,a.jsx)(S,{label:"Known As",value:v.join(",")}),(0,a.jsxs)(p.Z,{accordion:!0,children:[(0,a.jsx)(M,{header:"Currently Connected Clients",children:(0,a.jsx)(p.Z,{accordion:!0,children:h.map(e=>(0,a.jsx)(M,{header:(0,C.AB)(e.userAgent),children:(0,a.jsx)(P,{client:e})},e.id))})},"connected-clients"),(0,a.jsx)(p.Z,{accordion:!0,children:(0,a.jsx)(M,{header:"Recent Chat Messages",children:(0,a.jsx)(f.Z,{size:"small",pagination:null,columns:[{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)(m.Z,{type:"primary",ghost:!0,icon:(0,a.jsx)(_,{}),onClick:()=>Z(n.id,t)})}],dataSource:u,rowKey:"id"})},"chat-messages")})]})]})};var O=t(24110),D=t.n(O);let{confirm:B}=s.Z,T=h()(()=>Promise.all([t.e(2074),t.e(4337)]).then(t.t.bind(t,74337,23)),{loadableGenerated:{webpack:()=>[74337]},ssr:!1}),G=h()(()=>Promise.all([t.e(2074),t.e(7039)]).then(t.t.bind(t,67039,23)),{loadableGenerated:{webpack:()=>[67039]},ssr:!1}),I=h()(()=>Promise.all([t.e(2074),t.e(4645)]).then(t.t.bind(t,84645,23)),{loadableGenerated:{webpack:()=>[84645]},ssr:!1}),U=h()(()=>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,[h,p]=(0,c.useState)(!1),x=async()=>{try{await v.banUser(t,d)}catch(e){console.error(e),o.ZP.error(e)}},j=async()=>{try{await v.removeMessage(n,d)}catch(e){console.error(e),o.ZP.error(e)}},m=async()=>{B({icon:(0,a.jsx)(G,{}),content:"Are you sure you want to remove this message from ".concat(s,"?"),onOk(){j()}})},y=async()=>{B({icon:(0,a.jsx)(G,{}),content:"Are you sure you want to ban ".concat(s," from chat?"),onOk(){x()}})},b=e=>{let{key:n}=e;"hide-message"===n?m():"ban-user"===n?y():"more-info"===n&&p(!0)},f=(0,a.jsx)(r.Z,{onClick:b,items:[{label:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:D().icon,children:(0,a.jsx)(I,{})}),"Hide Message"]}),key:"hide-message"},{label:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:D().icon,children:(0,a.jsx)(T,{})}),"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)(u.Modal,{title:s,open:h,handleCancel:()=>{p(!1)},children:(0,a.jsx)(N,{userId:t,accessToken:d})})]})}},14761:function(e,n,t){"use strict";t.r(n),t.d(n,{Modal:function(){return d}});var a=t(85893),s=t(85402),o=t(26303),r=t(11382),l=t(67294),i=t(77011),c=t.n(i);let d=e=>{let{title:n,url:t,open:i,handleOk:d,handleCancel:h,afterClose:u,height:p,width:x,children:j}=e,[m,y]=(0,l.useState)(!!t),b="100%",f="520px";t&&(b="70vh",f="900px");let g={padding:"0px",minHeight:p,height:null!=p?p:b},v=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:()=>y(!1)});return(0,a.jsx)(s.Z,{title:n,open:i,onOk:d,onCancel:h,afterClose:u,bodyStyle:g,width:null!=x?x:f,zIndex:999,footer:null,centered:!0,destroyOnClose:!0,children:(0,a.jsxs)("div",{id:"modal-container",style:{height:"100%"},children:[m&&(0,a.jsx)(o.Z,{active:m,style:{padding:"10px"},paragraph:{rows:10}}),v&&(0,a.jsx)("div",{style:{display:m?"none":"inline"},children:v}),j&&(0,a.jsx)("div",{className:c().content,children:j}),m&&(0,a.jsx)(r.Z,{className:c().spinner,spinning:m,size:"large"})]})})};n.default=d,d.defaultProps={url:void 0,children:void 0,handleOk:void 0,handleCancel:void 0,afterClose:void 0}},70241: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:h}=t;return"libmpv"===e?"mpv media player":l&&r&&c?"".concat(l," ").concat(r," on ").concat(c," ").concat(i,"\n ").concat(d||h?" (".concat(d||h,")"):""):e}},24110:function(e){e.exports={icon:"ChatModerationActionMenu_icon__9j6DF"}},57761:function(e){e.exports={modalContainer:"ChatModerationDetailsModal_modalContainer__czndV",chatHistory:"ChatModerationDetailsModal_chatHistory__PunRk",colorBlock:"ChatModerationDetailsModal_colorBlock___rAlw",displayName:"ChatModerationDetailsModal_displayName__p7pLI"}},77011:function(e){e.exports={spinner:"Modal_spinner__GiSS0",content:"Modal_content__h9my9"}}}]);