fix: user avatar mime change from gif to avif

This commit is contained in:
trisua 2025-06-25 23:15:24 -04:00
parent ffdb767518
commit 6e0f2985b9
20 changed files with 219 additions and 104 deletions

View file

@ -52,6 +52,17 @@
if (data.method.Forward === "Key") {
$.STREAMS[stream].id = data.data;
return console.info(`${stream} ${data.data}`);
} else if (data.method.Forward === "Javascript") {
const s = document.createElement("script");
s.setAttribute("type", "module");
s.setAttribute("data-received", Date.now().toString());
s.text = JSON.parse(data.data).js;
document.body.appendChild(s).parentNode.removeChild(s);
return console.info(
`${stream} received Forward(PacketType::Javascript) payload of ${data.data.length} bytes`,
);
}
return $.sock(stream).events.message(data);
@ -72,8 +83,8 @@
socket.socket.close();
});
self.define("event", ({ $ }, stream, event, handler) => {
const socket = $.sock(stream);
self.define("event", async ({ $ }, stream, event, handler) => {
const socket = await $.sock(stream);
if (!socket) {
console.warn("no such stream to add event to");
@ -84,7 +95,7 @@
});
self.define("send_packet", async ({ $ }, stream, method, data) => {
await (
return await (
await fetch(`/api/v1/auth/user/${$.USER}/_connect/${stream}/send`, {
method: "POST",
headers: {
@ -97,4 +108,19 @@
})
).json();
});
self.define("send_packet_to", async (_, user, stream, method, data) => {
return await (
await fetch(`/api/v1/auth/user/${user}/_connect/${stream}/send`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
method,
data: JSON.stringify(data),
}),
})
).json();
});
})();