diff --git a/plugins/team-relay/index.js b/plugins/team-relay/index.js index 5734da1..c9b16dc 100644 --- a/plugins/team-relay/index.js +++ b/plugins/team-relay/index.js @@ -1,13 +1,12 @@ -// Team Relay — presence + coordinator tools over a GENERIC relay. +// Team Relay — team presence over a GENERIC relay. // // The relay (see exbyte-relay/) is a dumb message bus: it routes opaque JSON and // tracks who's online, and knows nothing about Perforce. ALL the logic lives // here and runs through the permission-gated `host.team` bridge: // - every ~4s we announce presence (user, #open files, access level) and drain // our inbox in one /sync round-trip; -// - a coordinator (admin/super) can ask a teammate's client to shelve its open -// work to the server — the teammate's client does the shelve, nothing is -// submitted, and their files stay checked out (shelve is non-destructive). +// - remote shelve is disabled: the sender's access level is self-declared, so +// incoming requests are refused until the receiver can verify it. // // Relay URL/token/room are configured in the Team tab and stored per-plugin — // nothing is hardcoded into the app. @@ -28,7 +27,6 @@ export function activate(host) { const myId = me.client || me.user || "unknown"; let access = ""; team.maxAccess().then((a) => { access = String(a || "").toLowerCase(); updateAll(); }).catch(() => {}); - const isCoordinator = () => access === "super" || access === "admin"; let members = []; let status = "idle"; // idle | ok | error @@ -52,23 +50,8 @@ export function activate(host) { async function handle(msg) { const from = msg.from || "A teammate"; if (msg.type === "shelve-request") { - host.flash(from + " is shelving your open work to the server…"); - host.notify("Team Relay", from + " is shelving your open work to the server…"); - try { - const n = await team.openCount(); - if (!n) { await send(from, "shelve-result", { ok: true, change: "", files: 0 }); return; } - const r = await team.shelveOpen("Remote shelve requested by " + from + " via Team Relay"); - host.notify("Team Relay", "Your open work was shelved as CL " + r.change + " (" + r.files + " file(s)). Your files stay checked out."); - await send(from, "shelve-result", { ok: true, change: r.change, files: r.files }); - } catch (e) { - host.flash("Remote shelve failed: " + e, true); - await send(from, "shelve-result", { ok: false, error: String(e) }); - } - } else if (msg.type === "shelve-result") { - const p = msg.payload || {}; - if (p.ok && p.change) host.flash(from + ": shelved " + p.files + " file(s) as CL " + p.change + " — find it under Pending / Shelved."); - else if (p.ok) host.flash(from + ": nothing open to shelve."); - else host.flash(from + ": shelve failed — " + p.error, true); + host.notify("Team Relay", "Refused a remote shelve request from " + from + "."); + await send(from, "shelve-result", { ok: false, error: "remote shelve is disabled" }).catch(() => {}); } } @@ -141,7 +124,7 @@ export function activate(host) { save.addEventListener("click", () => { host.flash("Relay settings saved."); tick(); }); wrap.append( title, - field("Relay URL", "relayUrl", "http://26.0.0.1:8787"), + field("Relay URL", "relayUrl", "http://192.168.100.1:8787"), field("Token (optional)", "relayToken", "shared secret", true), field("Room", "room", "team"), save, @@ -174,24 +157,6 @@ export function activate(host) { sub.textContent = m.id + " · " + oc + " open" + (meta.access ? " · " + meta.access : ""); infoCol.append(name, sub); row.appendChild(infoCol); - - if (isCoordinator() && m.id !== myId) { - const btn = document.createElement("button"); - const idle = oc > 0 ? "Force shelve" : "Nothing open"; - btn.textContent = idle; - btn.disabled = oc === 0; - styleBtn(btn, oc > 0); - if (oc > 0) { - btn.title = "Ask this teammate's client to shelve their open work to the server (nothing is submitted)."; - btn.addEventListener("click", async () => { - btn.disabled = true; btn.textContent = "Requesting…"; styleBtn(btn, false); - try { await send(m.id, "shelve-request", {}); host.flash("Asked " + (m.name || m.id) + " to shelve their open work…"); } - catch (e) { host.flash("Couldn't reach the relay: " + e, true); } - setTimeout(() => { btn.disabled = false; btn.textContent = idle; styleBtn(btn, true); }, 2500); - }); - } - row.appendChild(btn); - } container.appendChild(row); } } diff --git a/plugins/team-relay/plugin.json b/plugins/team-relay/plugin.json index c17d3b5..e51adcb 100644 --- a/plugins/team-relay/plugin.json +++ b/plugins/team-relay/plugin.json @@ -1,9 +1,9 @@ { "id": "team-relay", "name": "Team Relay", - "version": "1.0.1", + "version": "1.0.2", "author": "Exbyte Studios", - "description": "See who on the team is online and what they have open, over a lightweight relay on your VPN. Coordinators (admin/super) can force-shelve a teammate's open work to the server when they've stepped away — the teammate's client does the shelve; nothing is submitted. Configure the relay URL in the Team tab. Requires the Exbyte relay service.", + "description": "See who on the team is online and what they have open, over a lightweight relay on your VPN. Configure the relay URL in the Team tab. Requires the Exbyte relay service.", "entry": "index.js", "minAppVersion": "0.4.0", "permissions": ["team", "notify"], diff --git a/registry.json b/registry.json index 74e2439..8bff30c 100644 --- a/registry.json +++ b/registry.json @@ -23,9 +23,9 @@ { "id": "team-relay", "name": "Team Relay", - "version": "1.0.1", + "version": "1.0.2", "author": "Exbyte Studios", - "description": "Team presence + coordinator shelve tools over a lightweight relay. See who's online and what they have open; coordinators (admin/super) can force-shelve a teammate's open work to the server when they step away. Nothing is submitted. Configure the relay URL in the Team tab.", + "description": "Team presence over a lightweight relay. See who's online and what they have open. Configure the relay URL in the Team tab.", "permissions": [ "team", "notify"