Fix Violet PM: echo user message + add session restore on refresh
This commit is contained in:
parent
1d6413cfd6
commit
389415f04d
3
app.py
3
app.py
|
|
@ -620,6 +620,9 @@ def on_pm_message(data):
|
||||||
emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid)
|
emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Echo the user's own message back so it appears in their chat
|
||||||
|
emit("pm_message", payload, to=sid)
|
||||||
|
|
||||||
transit_key = data.get("transit_key", "")
|
transit_key = data.get("transit_key", "")
|
||||||
if not all([ciphertext, nonce_val, transit_key]):
|
if not all([ciphertext, nonce_val, transit_key]):
|
||||||
# Plaintext fallback for admins without crypto keys
|
# Plaintext fallback for admins without crypto keys
|
||||||
|
|
|
||||||
|
|
@ -118,12 +118,25 @@ joinForm.addEventListener("submit", async (e) => {
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
const token = localStorage.getItem("sexychat_token");
|
const token = localStorage.getItem("sexychat_token");
|
||||||
if (token) {
|
if (token) {
|
||||||
// We have a token, notify the join screen but wait for user to click "Enter"
|
// Auto-restore session from stored JWT
|
||||||
// to derive crypto key if they want to. Actually, for UX, if we have a token
|
joinBtn.disabled = true;
|
||||||
// we can try a "restore" join which might skip password entry.
|
joinBtn.innerText = "Restoring session...";
|
||||||
// But for encryption, we NEED that password to derive the key.
|
socket.connect();
|
||||||
// Let's keep it simple: if you have a token, you still need to log in to
|
socket.emit("join", { mode: "restore" });
|
||||||
// re-derive your E2E key.
|
|
||||||
|
// If restore fails, reset the form so user can log in manually
|
||||||
|
const restoreTimeout = setTimeout(() => {
|
||||||
|
joinBtn.disabled = false;
|
||||||
|
joinBtn.innerText = "Enter the Room";
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
const origJoined = socket.listeners("joined");
|
||||||
|
socket.once("joined", () => clearTimeout(restoreTimeout));
|
||||||
|
socket.once("error", () => {
|
||||||
|
clearTimeout(restoreTimeout);
|
||||||
|
joinBtn.disabled = false;
|
||||||
|
joinBtn.innerText = "Enter the Room";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue