mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 01:53:21 +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
|
||||
var package_default = {
|
||||
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.",
|
||||
keywords: [
|
||||
"deepseek-harness",
|
||||
|
|
@ -852,6 +852,8 @@ 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",
|
||||
"\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",
|
||||
"\u5DF2\u5728\u672C\u7FA4": "Already in group",
|
||||
"\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" })
|
||||
);
|
||||
}
|
||||
function BotSettingsButton({ channel: channel4, botId, botName, connected, accessPolicy }) {
|
||||
function BotSettingsButton({
|
||||
channel: channel4,
|
||||
botId,
|
||||
botName,
|
||||
connected,
|
||||
accessPolicy,
|
||||
accessGrant,
|
||||
groupSessionScope
|
||||
}) {
|
||||
const { openBotSettings } = React9.useContext(BotSettingsContext);
|
||||
const tooltipId = React9.useId();
|
||||
return h2(
|
||||
|
|
@ -3561,7 +3571,9 @@ function BotSettingsButton({ channel: channel4, botId, botName, connected, acces
|
|||
botId,
|
||||
botName,
|
||||
connected: Boolean(connected),
|
||||
accessPolicy
|
||||
accessPolicy,
|
||||
accessGrant,
|
||||
groupSessionScope
|
||||
})
|
||||
}, h2(SettingsGlyph)),
|
||||
h2("span", {
|
||||
|
|
@ -11698,7 +11710,9 @@ function WhatsappAccountCard({
|
|||
botId: account.botId,
|
||||
botName: account.bot.name,
|
||||
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 [feedback, setFeedback] = React21.useState(null);
|
||||
const [newGroupJid, setNewGroupJid] = React21.useState("");
|
||||
const [loadingGrant, setLoadingGrant] = React21.useState(!initialGrant);
|
||||
React21.useEffect(() => {
|
||||
setDraft(cloneGrant(normalizeAccessGrant(account?.accessGrant), ownerPhone));
|
||||
setGroupSessionScope(normalizeGroupSessionScope(account?.groupSessionScope));
|
||||
}, [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 knownGroupJids = React21.useMemo(() => {
|
||||
const set = new Set(Object.keys(draft.groups ?? {}));
|
||||
|
|
@ -12826,6 +12873,7 @@ function AccessGrantSettingsPage({ channel: channel4, account, rpcCall, onSaved
|
|||
className: "dim-accessPage",
|
||||
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(
|
||||
"p",
|
||||
{ className: "dim-accessUsersEmpty" },
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue