mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-18 21:20:44 +08:00
Load WhatsApp accessGrant into bot settings (4.9.1-ops.7).
Settings button only forwarded accessPolicy, so the graded ACL page always opened empty; also refresh grant from connection.status on mount. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
93672dfd91
commit
a4508a7caa
7 changed files with 110 additions and 8 deletions
|
|
@ -571,7 +571,7 @@ var React24 = __toESM(require("react"), 1);
|
||||||
// package.json
|
// package.json
|
||||||
var package_default = {
|
var package_default = {
|
||||||
name: "dsh-im-ops",
|
name: "dsh-im-ops",
|
||||||
version: "4.9.1-ops.6",
|
version: "4.9.1-ops.7",
|
||||||
description: "Ops fork of dsh-im (all channels kept). Based on @xmanrui/dsh-im@4.9.1 \u2014 access/session policies owned here.",
|
description: "Ops fork of dsh-im (all channels kept). Based on @xmanrui/dsh-im@4.9.1 \u2014 access/session policies owned here.",
|
||||||
keywords: [
|
keywords: [
|
||||||
"deepseek-harness",
|
"deepseek-harness",
|
||||||
|
|
@ -852,6 +852,8 @@ var EN = Object.freeze({
|
||||||
"\u673A\u5668\u4EBA\u8BBE\u7F6E\u9875\u7B7E": "Bot settings tabs",
|
"\u673A\u5668\u4EBA\u8BBE\u7F6E\u9875\u7B7E": "Bot settings tabs",
|
||||||
"\u6295\u9012\u8BBE\u7F6E": "Delivery settings",
|
"\u6295\u9012\u8BBE\u7F6E": "Delivery settings",
|
||||||
"\u8BBF\u95EE\u8BBE\u7F6E": "Access settings",
|
"\u8BBF\u95EE\u8BBE\u7F6E": "Access settings",
|
||||||
|
"\u65E0\u6CD5\u8BFB\u53D6\u8BBF\u95EE\u6388\u6743\uFF0C\u8BF7\u8FD4\u56DE\u5237\u65B0\u540E\u91CD\u8BD5\u3002": "Could not load the access grant. Go back, refresh, and try again.",
|
||||||
|
"\u6B63\u5728\u8BFB\u53D6\u5206\u7EA7\u8BBF\u95EE\u8BBE\u7F6E\u2026": "Loading graded access settings\u2026",
|
||||||
"\u52A0\u672C\u7FA4": "Add to group",
|
"\u52A0\u672C\u7FA4": "Add to group",
|
||||||
"\u5DF2\u5728\u672C\u7FA4": "Already in group",
|
"\u5DF2\u5728\u672C\u7FA4": "Already in group",
|
||||||
"\u52A0\u79C1\u804A": "Add to DMs",
|
"\u52A0\u79C1\u804A": "Add to DMs",
|
||||||
|
|
@ -3544,7 +3546,15 @@ function SettingsGlyph() {
|
||||||
h2("path", { d: "M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34 1.7 1.7 0 0 0-1.03 1.55V21h-4v-.08A1.7 1.7 0 0 0 8.97 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.52-1.03H3v-4h.08A1.7 1.7 0 0 0 4.6 8.97a1.7 1.7 0 0 0-.34-1.88l-.06-.06L7.03 4.2l.06.06a1.7 1.7 0 0 0 1.88.34A1.7 1.7 0 0 0 10 3.08V3h4v.08a1.7 1.7 0 0 0 1.03 1.52 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06a1.7 1.7 0 0 0-.34 1.88A1.7 1.7 0 0 0 20.92 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z" })
|
h2("path", { d: "M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34 1.7 1.7 0 0 0-1.03 1.55V21h-4v-.08A1.7 1.7 0 0 0 8.97 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.52-1.03H3v-4h.08A1.7 1.7 0 0 0 4.6 8.97a1.7 1.7 0 0 0-.34-1.88l-.06-.06L7.03 4.2l.06.06a1.7 1.7 0 0 0 1.88.34A1.7 1.7 0 0 0 10 3.08V3h4v.08a1.7 1.7 0 0 0 1.03 1.52 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06a1.7 1.7 0 0 0-.34 1.88A1.7 1.7 0 0 0 20.92 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z" })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function BotSettingsButton({ channel: channel4, botId, botName, connected, accessPolicy }) {
|
function BotSettingsButton({
|
||||||
|
channel: channel4,
|
||||||
|
botId,
|
||||||
|
botName,
|
||||||
|
connected,
|
||||||
|
accessPolicy,
|
||||||
|
accessGrant,
|
||||||
|
groupSessionScope
|
||||||
|
}) {
|
||||||
const { openBotSettings } = React9.useContext(BotSettingsContext);
|
const { openBotSettings } = React9.useContext(BotSettingsContext);
|
||||||
const tooltipId = React9.useId();
|
const tooltipId = React9.useId();
|
||||||
return h2(
|
return h2(
|
||||||
|
|
@ -3561,7 +3571,9 @@ function BotSettingsButton({ channel: channel4, botId, botName, connected, acces
|
||||||
botId,
|
botId,
|
||||||
botName,
|
botName,
|
||||||
connected: Boolean(connected),
|
connected: Boolean(connected),
|
||||||
accessPolicy
|
accessPolicy,
|
||||||
|
accessGrant,
|
||||||
|
groupSessionScope
|
||||||
})
|
})
|
||||||
}, h2(SettingsGlyph)),
|
}, h2(SettingsGlyph)),
|
||||||
h2("span", {
|
h2("span", {
|
||||||
|
|
@ -11698,7 +11710,9 @@ function WhatsappAccountCard({
|
||||||
botId: account.botId,
|
botId: account.botId,
|
||||||
botName: account.bot.name,
|
botName: account.bot.name,
|
||||||
connected: account.connected,
|
connected: account.connected,
|
||||||
accessPolicy: account.accessPolicy
|
accessPolicy: account.accessPolicy,
|
||||||
|
accessGrant: account.accessGrant,
|
||||||
|
groupSessionScope: account.groupSessionScope
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
@ -12737,10 +12751,43 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
|
||||||
const [saving, setSaving] = React21.useState(false);
|
const [saving, setSaving] = React21.useState(false);
|
||||||
const [feedback, setFeedback] = React21.useState(null);
|
const [feedback, setFeedback] = React21.useState(null);
|
||||||
const [newGroupJid, setNewGroupJid] = React21.useState("");
|
const [newGroupJid, setNewGroupJid] = React21.useState("");
|
||||||
|
const [loadingGrant, setLoadingGrant] = React21.useState(!initialGrant);
|
||||||
React21.useEffect(() => {
|
React21.useEffect(() => {
|
||||||
setDraft(cloneGrant(normalizeAccessGrant(account?.accessGrant), ownerPhone));
|
setDraft(cloneGrant(normalizeAccessGrant(account?.accessGrant), ownerPhone));
|
||||||
setGroupSessionScope(normalizeGroupSessionScope(account?.groupSessionScope));
|
setGroupSessionScope(normalizeGroupSessionScope(account?.groupSessionScope));
|
||||||
}, [account?.botId, initialKey, account?.groupSessionScope, ownerPhone]);
|
}, [account?.botId, initialKey, account?.groupSessionScope, ownerPhone]);
|
||||||
|
React21.useEffect(() => {
|
||||||
|
if (typeof rpcCall !== "function" || !account?.botId) return void 0;
|
||||||
|
let cancelled = false;
|
||||||
|
setLoadingGrant(true);
|
||||||
|
void (async () => {
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
if (grant) {
|
||||||
|
setDraft(cloneGrant(grant, ownerPhone));
|
||||||
|
onSaved?.(grant);
|
||||||
|
}
|
||||||
|
if (bot?.groupSessionScope) {
|
||||||
|
setGroupSessionScope(normalizeGroupSessionScope(bot.groupSessionScope));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (!cancelled) {
|
||||||
|
setFeedback({
|
||||||
|
tone: "error",
|
||||||
|
message: error?.message || "\u65E0\u6CD5\u8BFB\u53D6\u8BBF\u95EE\u6388\u6743\uFF0C\u8BF7\u8FD4\u56DE\u5237\u65B0\u540E\u91CD\u8BD5\u3002"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!cancelled) setLoadingGrant(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, [account?.botId, rpcCall, ownerPhone]);
|
||||||
const contacts = draft.contacts ?? [];
|
const contacts = draft.contacts ?? [];
|
||||||
const knownGroupJids = React21.useMemo(() => {
|
const knownGroupJids = React21.useMemo(() => {
|
||||||
const set = new Set(Object.keys(draft.groups ?? {}));
|
const set = new Set(Object.keys(draft.groups ?? {}));
|
||||||
|
|
@ -12826,6 +12873,7 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
|
||||||
className: "dim-accessPage",
|
className: "dim-accessPage",
|
||||||
onSubmit: (event) => void save(event)
|
onSubmit: (event) => void save(event)
|
||||||
},
|
},
|
||||||
|
loadingGrant ? h2("div", { className: "dim-accessState", "aria-busy": "true" }, "\u6B63\u5728\u8BFB\u53D6\u5206\u7EA7\u8BBF\u95EE\u8BBE\u7F6E\u2026") : null,
|
||||||
h2(
|
h2(
|
||||||
"p",
|
"p",
|
||||||
{ className: "dim-accessUsersEmpty" },
|
{ className: "dim-accessUsersEmpty" },
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dsh-im-ops",
|
"name": "dsh-im-ops",
|
||||||
"version": "4.9.1-ops.6",
|
"version": "4.9.1-ops.7",
|
||||||
"description": "Ops fork of dsh-im (all channels kept). Based on @xmanrui/dsh-im@4.9.1 — access/session policies owned here.",
|
"description": "Ops fork of dsh-im (all channels kept). Based on @xmanrui/dsh-im@4.9.1 — access/session policies owned here.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"deepseek-harness",
|
"deepseek-harness",
|
||||||
|
|
|
||||||
|
|
@ -221,12 +221,47 @@ export function AccessGrantSettingsPage({ channel, account, rpcCall, onSaved })
|
||||||
const [saving, setSaving] = React.useState(false);
|
const [saving, setSaving] = React.useState(false);
|
||||||
const [feedback, setFeedback] = React.useState(null);
|
const [feedback, setFeedback] = React.useState(null);
|
||||||
const [newGroupJid, setNewGroupJid] = React.useState('');
|
const [newGroupJid, setNewGroupJid] = React.useState('');
|
||||||
|
const [loadingGrant, setLoadingGrant] = React.useState(!initialGrant);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setDraft(cloneGrant(normalizeAccessGrant(account?.accessGrant), ownerPhone));
|
setDraft(cloneGrant(normalizeAccessGrant(account?.accessGrant), ownerPhone));
|
||||||
setGroupSessionScope(normalizeGroupSessionScope(account?.groupSessionScope));
|
setGroupSessionScope(normalizeGroupSessionScope(account?.groupSessionScope));
|
||||||
}, [account?.botId, initialKey, account?.groupSessionScope, ownerPhone]);
|
}, [account?.botId, initialKey, account?.groupSessionScope, ownerPhone]);
|
||||||
|
|
||||||
|
// Settings open payload historically omitted accessGrant; always refresh from status.
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (typeof rpcCall !== 'function' || !account?.botId) return undefined;
|
||||||
|
let cancelled = false;
|
||||||
|
setLoadingGrant(true);
|
||||||
|
void (async () => {
|
||||||
|
try {
|
||||||
|
const value = unwrapRpcResult(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);
|
||||||
|
if (grant) {
|
||||||
|
setDraft(cloneGrant(grant, ownerPhone));
|
||||||
|
onSaved?.(grant);
|
||||||
|
}
|
||||||
|
if (bot?.groupSessionScope) {
|
||||||
|
setGroupSessionScope(normalizeGroupSessionScope(bot.groupSessionScope));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (!cancelled) {
|
||||||
|
setFeedback({
|
||||||
|
tone: 'error',
|
||||||
|
message: error?.message || '无法读取访问授权,请返回刷新后重试。',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!cancelled) setLoadingGrant(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [account?.botId, rpcCall, ownerPhone]);
|
||||||
|
|
||||||
const contacts = draft.contacts ?? [];
|
const contacts = draft.contacts ?? [];
|
||||||
const knownGroupJids = React.useMemo(() => {
|
const knownGroupJids = React.useMemo(() => {
|
||||||
const set = new Set(Object.keys(draft.groups ?? {}));
|
const set = new Set(Object.keys(draft.groups ?? {}));
|
||||||
|
|
@ -319,6 +354,9 @@ export function AccessGrantSettingsPage({ channel, account, rpcCall, onSaved })
|
||||||
className: 'dim-accessPage',
|
className: 'dim-accessPage',
|
||||||
onSubmit: (event) => void save(event),
|
onSubmit: (event) => void save(event),
|
||||||
},
|
},
|
||||||
|
loadingGrant
|
||||||
|
? h('div', { className: 'dim-accessState', 'aria-busy': 'true' }, '正在读取分级访问设置…')
|
||||||
|
: null,
|
||||||
h('p', { className: 'dim-accessUsersEmpty' },
|
h('p', { className: 'dim-accessUsersEmpty' },
|
||||||
'WhatsApp 按电话号码授权:全局管理员管私聊;群管理员只批本群。成员不可跨群、有群权也不自动获得私聊权。'),
|
'WhatsApp 按电话号码授权:全局管理员管私聊;群管理员只批本群。成员不可跨群、有群权也不自动获得私聊权。'),
|
||||||
h(AdminPhones, {
|
h(AdminPhones, {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,15 @@ function SettingsGlyph() {
|
||||||
h('path', { d: 'M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34 1.7 1.7 0 0 0-1.03 1.55V21h-4v-.08A1.7 1.7 0 0 0 8.97 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.52-1.03H3v-4h.08A1.7 1.7 0 0 0 4.6 8.97a1.7 1.7 0 0 0-.34-1.88l-.06-.06L7.03 4.2l.06.06a1.7 1.7 0 0 0 1.88.34A1.7 1.7 0 0 0 10 3.08V3h4v.08a1.7 1.7 0 0 0 1.03 1.52 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06a1.7 1.7 0 0 0-.34 1.88A1.7 1.7 0 0 0 20.92 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z' }));
|
h('path', { d: 'M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34 1.7 1.7 0 0 0-1.03 1.55V21h-4v-.08A1.7 1.7 0 0 0 8.97 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.52-1.03H3v-4h.08A1.7 1.7 0 0 0 4.6 8.97a1.7 1.7 0 0 0-.34-1.88l-.06-.06L7.03 4.2l.06.06a1.7 1.7 0 0 0 1.88.34A1.7 1.7 0 0 0 10 3.08V3h4v.08a1.7 1.7 0 0 0 1.03 1.52 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06a1.7 1.7 0 0 0-.34 1.88A1.7 1.7 0 0 0 20.92 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BotSettingsButton({ channel, botId, botName, connected, accessPolicy }) {
|
export function BotSettingsButton({
|
||||||
|
channel,
|
||||||
|
botId,
|
||||||
|
botName,
|
||||||
|
connected,
|
||||||
|
accessPolicy,
|
||||||
|
accessGrant,
|
||||||
|
groupSessionScope,
|
||||||
|
}) {
|
||||||
const { openBotSettings } = React.useContext(BotSettingsContext);
|
const { openBotSettings } = React.useContext(BotSettingsContext);
|
||||||
const tooltipId = React.useId();
|
const tooltipId = React.useId();
|
||||||
return h('span', { className: 'dim-botSettingsAction' },
|
return h('span', { className: 'dim-botSettingsAction' },
|
||||||
|
|
@ -38,6 +46,8 @@ export function BotSettingsButton({ channel, botId, botName, connected, accessPo
|
||||||
botName,
|
botName,
|
||||||
connected: Boolean(connected),
|
connected: Boolean(connected),
|
||||||
accessPolicy,
|
accessPolicy,
|
||||||
|
accessGrant,
|
||||||
|
groupSessionScope,
|
||||||
}),
|
}),
|
||||||
}, h(SettingsGlyph)),
|
}, h(SettingsGlyph)),
|
||||||
h('span', {
|
h('span', {
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,8 @@ export function WhatsappAccountCard({
|
||||||
botName: account.bot.name,
|
botName: account.bot.name,
|
||||||
connected: account.connected,
|
connected: account.connected,
|
||||||
accessPolicy: account.accessPolicy,
|
accessPolicy: account.accessPolicy,
|
||||||
|
accessGrant: account.accessGrant,
|
||||||
|
groupSessionScope: account.groupSessionScope,
|
||||||
}))),
|
}))),
|
||||||
h(WorkspaceEditor, {
|
h(WorkspaceEditor, {
|
||||||
workspace: account.workspace,
|
workspace: account.workspace,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ const EN = Object.freeze({
|
||||||
'机器人设置页签': 'Bot settings tabs',
|
'机器人设置页签': 'Bot settings tabs',
|
||||||
'投递设置': 'Delivery settings',
|
'投递设置': 'Delivery settings',
|
||||||
'访问设置': 'Access settings',
|
'访问设置': 'Access settings',
|
||||||
|
"无法读取访问授权,请返回刷新后重试。": "Could not load the access grant. Go back, refresh, and try again.",
|
||||||
|
|
||||||
|
"正在读取分级访问设置…": "Loading graded access settings…",
|
||||||
|
|
||||||
"加本群": "Add to group",
|
"加本群": "Add to group",
|
||||||
|
|
||||||
"已在本群": "Already in group",
|
"已在本群": "Already in group",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue