media-server-docker-compose/ghost-fusiondance/content/public/admin-auth/admin-auth.min.js

1 line
1.1 KiB
JavaScript
Raw Normal View History

2024-07-18 11:24:17 -04:00
const adminUrl=window.location.href.replace("auth-frame/","")+"api/admin",siteOrigin="https://libertyfusiondance.com";window.addEventListener("message",(async function(i){if(i.origin!==siteOrigin)return void console.warn("Ignored message to admin auth iframe because of mismatch in origin","expected",siteOrigin,"got",i.origin,"with data",i.data);let t=null;try{t=JSON.parse(i.data)}catch(i){console.error(i)}function n(n,e){i.source.postMessage(JSON.stringify({uid:t.uid,error:n,result:e}),siteOrigin)}if("getUser"===t.action)try{const i=await fetch(adminUrl+"/users/me/");n(null,await i.json())}catch(i){n(i,null)}if("hideComment"===t.action)try{const i=await fetch(adminUrl+"/comments/"+t.id+"/",{method:"PUT",body:JSON.stringify({comments:[{id:t.id,status:"hidden"}]}),headers:{"Content-Type":"application/json"}});n(null,await i.json())}catch(i){n(i,null)}if("showComment"===t.action)try{const i=await fetch(adminUrl+"/comments/"+t.id+"/",{method:"PUT",body:JSON.stringify({comments:[{id:t.id,status:"published"}]}),headers:{"Content-Type":"application/json"}});n(null,await i.json())}catch(i){n(i,null)}}));