Sync WhatsApp group subjects into access UI (4.9.1-ops.10).

Refresh missing/forced group titles via groupMetadata and participating catalog so cards show real names instead of bare JIDs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-05 17:39:25 +08:00
parent a169b164a8
commit f96157da1e
13 changed files with 568 additions and 260 deletions

View file

@ -571,7 +571,7 @@ var React24 = __toESM(require("react"), 1);
// package.json
var package_default = {
name: "dsh-im-ops",
version: "4.9.1-ops.9",
version: "4.9.1-ops.10",
description: "Ops fork of dsh-im (all channels kept). Based on @xmanrui/dsh-im@4.9.1 \u2014 access/session policies owned here.",
keywords: [
"deepseek-harness",
@ -852,6 +852,12 @@ var EN = Object.freeze({
"\u673A\u5668\u4EBA\u8BBE\u7F6E\u9875\u7B7E": "Bot settings tabs",
"\u6295\u9012\u8BBE\u7F6E": "Delivery settings",
"\u8BBF\u95EE\u8BBE\u7F6E": "Access settings",
"\u8BF7\u63D0\u4EA4\u6709\u6548\u7684\u7FA4\u540D\u540C\u6B65\u8BF7\u6C42\u3002": "Submit a valid group-name sync request.",
"\u540C\u6B65\u7FA4\u540D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002": "Could not sync the group name. Try again later.",
"\u672A\u80FD\u4ECE WhatsApp \u8BFB\u53D6\u7FA4\u540D\uFF0C\u8BF7\u786E\u8BA4\u673A\u5668\u4EBA\u5728\u7EBF\u4E14\u4ECD\u5728\u8BE5\u7FA4\u3002": "Could not read the group name from WhatsApp. Confirm the bot is online and still in the group.",
"\u5DF2\u540C\u6B65\u7FA4\u540D\uFF1A": "Synced group name: ",
"\u540C\u6B65\u7FA4\u540D": "Sync group name",
"\u672A\u547D\u540D\u7FA4": "Unnamed group",
"\u6682\u65E0\u6635\u79F0\uFF08\u79C1\u804A/@ \u540E\u4F1A\u81EA\u52A8\u8865\u9F50\uFF09": "No nickname yet (filled after DM or @mention)",
"\u7FA4\u804A \xB7 ": "Group \xB7 ",
"\u3002\u8BB0\u5F97\u70B9\u4FDD\u5B58\u3002": ". Remember to save.",
@ -11309,6 +11315,7 @@ var WHATSAPP_ENDPOINTS = Object.freeze({
setAccessPolicy: "bot.access-policy.set",
setAccessGrant: "bot.access-grant.set",
resolveAccessPending: "bot.access-pending.resolve",
refreshAccessGroupTitles: "bot.access-group-titles.refresh",
setGroupSessionScope: "bot.group-session-scope.set",
setWorkspace: "bot.workspace.set",
setAgentPreset: SET_AGENT_PRESET_ENDPOINT,
@ -12541,6 +12548,7 @@ function AccessPolicySettingsPage({ channel: channel4, account, rpcCall, onSaved
var React21 = __toESM(require("react"), 1);
var ACCESS_GRANT_ENDPOINT = "bot.access-grant.set";
var ACCESS_PENDING_RESOLVE_ENDPOINT = "bot.access-pending.resolve";
var ACCESS_GROUP_TITLES_REFRESH_ENDPOINT = "bot.access-group-titles.refresh";
var GROUP_SESSION_SCOPE_ENDPOINT2 = "bot.group-session-scope.set";
function unwrapRpcResult11(result) {
if (result?.ok === true) return result.value;
@ -12604,10 +12612,7 @@ function NicknameHint({ contacts, phone }) {
function groupDisplayName(groupJid, groups) {
const title = groups?.[groupJid]?.title;
if (typeof title === "string" && title.trim()) return title.trim();
const raw = String(groupJid ?? "");
const id5 = raw.replace(/@g\.us$/i, "");
if (id5.length > 14) return `${id5.slice(0, 10)}\u2026@g.us`;
return raw || "\u672A\u77E5\u7FA4";
return "\u672A\u547D\u540D\u7FA4";
}
function digitsOnly(value) {
return String(value ?? "").replace(/[^\d]/g, "");
@ -12828,7 +12833,7 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
const value = unwrapRpcResult11(await rpcCall("connection.status", {}));
if (cancelled) return;
const bot = Array.isArray(value?.bots) ? value.bots.find((entry) => entry?.botId === account.botId) : null;
const grant = normalizeAccessGrant(bot?.accessGrant);
let grant = normalizeAccessGrant(bot?.accessGrant);
if (grant) {
setDraft(cloneGrant(grant, ownerPhone));
onSaved?.(grant);
@ -12836,6 +12841,24 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
if (bot?.groupSessionScope) {
setGroupSessionScope(normalizeGroupSessionScope(bot.groupSessionScope));
}
const missingTitles = Object.entries(grant?.groups ?? {}).filter(([, group]) => !(typeof group?.title === "string" && group.title.trim())).map(([jid]) => jid);
const pendingGroupJids = (grant?.pending ?? []).map((entry) => entry.groupJid).filter((jid) => typeof jid === "string" && jid.endsWith("@g.us"));
const toSync = [.../* @__PURE__ */ new Set([...missingTitles, ...pendingGroupJids])];
if (toSync.length > 0) {
try {
const refreshed = unwrapRpcResult11(await rpcCall(ACCESS_GROUP_TITLES_REFRESH_ENDPOINT, {
botId: account.botId,
groupJids: toSync
}));
if (cancelled) return;
const next = grantFromSnapshot(refreshed, account.botId);
if (next) {
setDraft(cloneGrant(next, ownerPhone));
onSaved?.(next);
}
} catch {
}
}
} catch (error) {
if (!cancelled) {
setFeedback({
@ -13019,21 +13042,56 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
h2("code", { className: "dim-accessGroupJid" }, groupJid)
),
h2(
"label",
{ className: "dim-accessField" },
h2("span", null, "\u7FA4\u540D\u79F0"),
h2("input", {
value: group.title ?? "",
maxLength: 128,
placeholder: "\u586B\u5199\u4FBF\u4E8E\u8BC6\u522B\u7684\u7FA4\u540D\u79F0",
onChange: (event) => setDraft((current) => ({
...current,
groups: {
...current.groups,
[groupJid]: { ...group, title: event.target.value }
"div",
{ className: "dim-accessGroupTitleRow" },
h2(
"label",
{ className: "dim-accessField" },
h2("span", null, "\u7FA4\u540D\u79F0"),
h2("input", {
value: group.title ?? "",
maxLength: 128,
placeholder: "\u586B\u5199\u4FBF\u4E8E\u8BC6\u522B\u7684\u7FA4\u540D\u79F0",
onChange: (event) => setDraft((current) => ({
...current,
groups: {
...current.groups,
[groupJid]: { ...group, title: event.target.value }
}
}))
})
),
h2("button", {
type: "button",
className: "dim-deliveryButton",
disabled: saving,
onClick: () => void (async () => {
setSaving(true);
setFeedback(null);
try {
const refreshed = unwrapRpcResult11(await rpcCall(
ACCESS_GROUP_TITLES_REFRESH_ENDPOINT,
{ botId: account.botId, groupJids: [groupJid] }
));
const next = grantFromSnapshot(refreshed, account.botId);
if (!next) throw new Error("\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE\u5DF2\u4FDD\u5B58\u7684\u8BBF\u95EE\u6388\u6743\u3002");
setDraft(cloneGrant(next, ownerPhone));
onSaved?.(next);
const title = next.groups?.[groupJid]?.title;
setFeedback({
tone: title ? "success" : "error",
message: title ? ["\u5DF2\u540C\u6B65\u7FA4\u540D\uFF1A", title].join("") : "\u672A\u80FD\u4ECE WhatsApp \u8BFB\u53D6\u7FA4\u540D\uFF0C\u8BF7\u786E\u8BA4\u673A\u5668\u4EBA\u5728\u7EBF\u4E14\u4ECD\u5728\u8BE5\u7FA4\u3002"
});
} catch (error) {
setFeedback({
tone: "error",
message: error?.message || "\u540C\u6B65\u7FA4\u540D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"
});
} finally {
setSaving(false);
}
}))
})
})
}, "\u540C\u6B65\u7FA4\u540D")
),
h2(AdminPhones, {
title: "\u672C\u7FA4\u7BA1\u7406\u5458",
@ -14610,6 +14668,7 @@ var CSS11 = String.raw`
.dim-accessGroupHeading { min-width: 0; display: grid; gap: 2px; }
.dim-accessGroupHeading h3 { margin: 0; color: var(--dsw-alias-label-primary, #1f2329); font-size: 14px; line-height: 21px; font-weight: 650; }
.dim-accessGroupJid { color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 11px; line-height: 16px; overflow-wrap: anywhere; }
.dim-accessGroupTitleRow { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 10px; align-items: end; }
.dim-accessNickname { display: block; margin-top: 4px; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 18px; font-weight: 560; }
.dim-accessNicknameEmpty { color: var(--dsw-alias-label-tertiary, #8f959e); font-weight: 400; }
.dim-accessUserRow { position: relative; z-index: 0; overflow: visible; }

File diff suppressed because one or more lines are too long