team-relay 1.0.2: remove remote shelve
Presence stays. Incoming shelve requests are now refused until they can be authorized on the receiving side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -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
|
// 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
|
// tracks who's online, and knows nothing about Perforce. ALL the logic lives
|
||||||
// here and runs through the permission-gated `host.team` bridge:
|
// here and runs through the permission-gated `host.team` bridge:
|
||||||
// - every ~4s we announce presence (user, #open files, access level) and drain
|
// - every ~4s we announce presence (user, #open files, access level) and drain
|
||||||
// our inbox in one /sync round-trip;
|
// our inbox in one /sync round-trip;
|
||||||
// - a coordinator (admin/super) can ask a teammate's client to shelve its open
|
// - remote shelve is disabled: the sender's access level is self-declared, so
|
||||||
// work to the server — the teammate's client does the shelve, nothing is
|
// incoming requests are refused until the receiver can verify it.
|
||||||
// submitted, and their files stay checked out (shelve is non-destructive).
|
|
||||||
//
|
//
|
||||||
// Relay URL/token/room are configured in the Team tab and stored per-plugin —
|
// Relay URL/token/room are configured in the Team tab and stored per-plugin —
|
||||||
// nothing is hardcoded into the app.
|
// nothing is hardcoded into the app.
|
||||||
@ -28,7 +27,6 @@ export function activate(host) {
|
|||||||
const myId = me.client || me.user || "unknown";
|
const myId = me.client || me.user || "unknown";
|
||||||
let access = "";
|
let access = "";
|
||||||
team.maxAccess().then((a) => { access = String(a || "").toLowerCase(); updateAll(); }).catch(() => {});
|
team.maxAccess().then((a) => { access = String(a || "").toLowerCase(); updateAll(); }).catch(() => {});
|
||||||
const isCoordinator = () => access === "super" || access === "admin";
|
|
||||||
|
|
||||||
let members = [];
|
let members = [];
|
||||||
let status = "idle"; // idle | ok | error
|
let status = "idle"; // idle | ok | error
|
||||||
@ -52,23 +50,8 @@ export function activate(host) {
|
|||||||
async function handle(msg) {
|
async function handle(msg) {
|
||||||
const from = msg.from || "A teammate";
|
const from = msg.from || "A teammate";
|
||||||
if (msg.type === "shelve-request") {
|
if (msg.type === "shelve-request") {
|
||||||
host.flash(from + " is shelving your open work to the server…");
|
host.notify("Team Relay", "Refused a remote shelve request from " + from + ".");
|
||||||
host.notify("Team Relay", from + " is shelving your open work to the server…");
|
await send(from, "shelve-result", { ok: false, error: "remote shelve is disabled" }).catch(() => {});
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +124,7 @@ export function activate(host) {
|
|||||||
save.addEventListener("click", () => { host.flash("Relay settings saved."); tick(); });
|
save.addEventListener("click", () => { host.flash("Relay settings saved."); tick(); });
|
||||||
wrap.append(
|
wrap.append(
|
||||||
title,
|
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("Token (optional)", "relayToken", "shared secret", true),
|
||||||
field("Room", "room", "team"),
|
field("Room", "room", "team"),
|
||||||
save,
|
save,
|
||||||
@ -174,24 +157,6 @@ export function activate(host) {
|
|||||||
sub.textContent = m.id + " · " + oc + " open" + (meta.access ? " · " + meta.access : "");
|
sub.textContent = m.id + " · " + oc + " open" + (meta.access ? " · " + meta.access : "");
|
||||||
infoCol.append(name, sub);
|
infoCol.append(name, sub);
|
||||||
row.appendChild(infoCol);
|
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);
|
container.appendChild(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"id": "team-relay",
|
"id": "team-relay",
|
||||||
"name": "Team Relay",
|
"name": "Team Relay",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"author": "Exbyte Studios",
|
"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",
|
"entry": "index.js",
|
||||||
"minAppVersion": "0.4.0",
|
"minAppVersion": "0.4.0",
|
||||||
"permissions": ["team", "notify"],
|
"permissions": ["team", "notify"],
|
||||||
|
|||||||
@ -23,9 +23,9 @@
|
|||||||
{
|
{
|
||||||
"id": "team-relay",
|
"id": "team-relay",
|
||||||
"name": "Team Relay",
|
"name": "Team Relay",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"author": "Exbyte Studios",
|
"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": [
|
"permissions": [
|
||||||
"team",
|
"team",
|
||||||
"notify"
|
"notify"
|
||||||
|
|||||||
Reference in New Issue
Block a user