Fix issue with newest version of chromium

This commit is contained in:
DianaXWiki 2026-04-23 15:41:18 +02:00
parent 6b9200e2c5
commit 224110c8d1
2 changed files with 35 additions and 5 deletions

View File

@ -167,6 +167,8 @@ const _join: Callback = (ctx, clientId, data) => {
}
const isNew = typeof channels[channelId] === "undefined";
const isReloadNavigation = Boolean(data?.isReloadNavigation);
const isAnonymousSession = !store.loggedIn;
// Create or get existing channel object
const channel = channels[channelId] ||= {
@ -201,7 +203,7 @@ const _join: Callback = (ctx, clientId, data) => {
}
// Existing pad already loaded: send userlist and history
if (!isNew && channel.wc) {
const sendExistingState = () => {
postMessage(clientId, "PAD_CONNECT", { // Initialize
myID: channel.wc.myID,
id: channel.wc.id,
@ -218,7 +220,32 @@ const _join: Callback = (ctx, clientId, data) => {
});
});
postMessage(clientId, "PAD_READY"); // Ready
return;
};
const preflightAnonAccess = (cb) => {
const allow = () => { cb(true); };
const deny = () => {
Cache?.clearChannel?.(channelId);
channel.bcast("PAD_ERROR", { type: "ERESTRICTED" });
ctx.leavePad(null, data, function () {});
cb(false);
};
if (!isAnonymousSession) { return void allow(); }
if (!store.anon_rpc) {
return void (isReloadNavigation ? deny() : allow());
}
_getMetadata(ctx, clientId, { channel: channelId }, md => {
if (md?.rejected) { return void deny(); }
if (isReloadNavigation && md?.error) { return void deny(); }
allow();
});
};
if (!isNew && channel.wc) {
return void preflightAnonAccess((ok) => {
if (!ok) { return; }
sendExistingState();
});
}
// chainpad-netflux config
@ -231,7 +258,7 @@ const _join: Callback = (ctx, clientId, data) => {
}
channel.bcast("PAD_ERROR", err);
if (type === "EDELETED" && Cache?.clearChannel) {
if (["EDELETED", "EEXPIRED", "ERESTRICTED"].includes(type) && Cache?.clearChannel) {
Cache.clearChannel(channelId);
}
@ -343,7 +370,10 @@ const _join: Callback = (ctx, clientId, data) => {
});
}
};
channel.cpNf = CpNetflux.start(conf);
preflightAnonAccess((ok) => {
if (!ok) { return; }
channel.cpNf = CpNetflux.start(conf);
});
};
// Send a message to a pad we already joined

File diff suppressed because one or more lines are too long