mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-18 20:10:46 +08:00
Sync bot chat language with DSH system locale.
Localize WhatsApp access-grant approvals via t() and push Host language from the UI on load and locale change. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6107692418
commit
45f430fb28
10 changed files with 181 additions and 33 deletions
|
|
@ -22,6 +22,7 @@ import {
|
|||
upsertAccessContact,
|
||||
} from '../shared/access-grant.mjs';
|
||||
import { isSharedLocalCommand } from '../shared/command-permission.mjs';
|
||||
import { t } from '../shared/i18n.mjs';
|
||||
import { isWhatsappLidJid } from './whatsapp-identity.mjs';
|
||||
|
||||
/**
|
||||
|
|
@ -178,17 +179,17 @@ export async function tryHandleWhatsappApprovalReply({
|
|||
}
|
||||
await sendText(
|
||||
{ jid: message.replyTarget?.jid ?? `${phone}@s.whatsapp.net` },
|
||||
intent === 'approve' ? ACCESS_GRANT_COPY.adminApproved : ACCESS_GRANT_COPY.adminDenied,
|
||||
t(intent === 'approve' ? ACCESS_GRANT_COPY.adminApproved : ACCESS_GRANT_COPY.adminDenied),
|
||||
);
|
||||
const requesterJid = resolved.phone
|
||||
? `${resolved.phone}@s.whatsapp.net`
|
||||
: (resolved.lid ?? null);
|
||||
if (requesterJid) {
|
||||
const body = intent === 'approve'
|
||||
const body = t(intent === 'approve'
|
||||
? (resolved.kind === 'group'
|
||||
? ACCESS_GRANT_COPY.approvedGroup
|
||||
: ACCESS_GRANT_COPY.approvedDirect)
|
||||
: ACCESS_GRANT_COPY.denied;
|
||||
: ACCESS_GRANT_COPY.denied);
|
||||
try {
|
||||
await sendText({ jid: requesterJid }, body);
|
||||
} catch {
|
||||
|
|
@ -201,7 +202,7 @@ export async function tryHandleWhatsappApprovalReply({
|
|||
|| error?.code === 'pending-unresolved' || error?.code === 'pending-not-found') {
|
||||
await sendText(
|
||||
{ jid: message.replyTarget?.jid ?? `${phone}@s.whatsapp.net` },
|
||||
error.message || '无法处理该审批。',
|
||||
t(error.message || ACCESS_GRANT_COPY.processFailed),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -322,11 +323,11 @@ export async function gateWhatsappInbound({
|
|||
await workspaces.setAccessGrant(botId, current);
|
||||
}
|
||||
|
||||
const ack = !phone
|
||||
const ack = t(!phone
|
||||
? ACCESS_GRANT_COPY.pendingUnresolved
|
||||
: (scene === 'group'
|
||||
? ACCESS_GRANT_COPY.pendingAckGroup
|
||||
: ACCESS_GRANT_COPY.pendingAckDirect);
|
||||
: ACCESS_GRANT_COPY.pendingAckDirect));
|
||||
try {
|
||||
await sendText(message.replyTarget, ack);
|
||||
} catch {
|
||||
|
|
@ -335,7 +336,7 @@ export async function gateWhatsappInbound({
|
|||
|
||||
if (created) {
|
||||
const admins = approverPhonesForPending(current, pending);
|
||||
const body = formatPendingNotifyBody(pending);
|
||||
const body = formatPendingNotifyBody(pending, t);
|
||||
const refs = [];
|
||||
for (const adminPhone of admins) {
|
||||
// Never DM the linked bot account as if it were a peer when it is the only self-chat path.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue