mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:07:27 +00:00
refactor: unify channel status snapshot base fields
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
applyAccountNameToChannelSection,
|
applyAccountNameToChannelSection,
|
||||||
|
buildComputedAccountStatusSnapshot,
|
||||||
buildChannelConfigSchema,
|
buildChannelConfigSchema,
|
||||||
buildTokenChannelStatusSummary,
|
buildTokenChannelStatusSummary,
|
||||||
collectDiscordAuditChannelIds,
|
collectDiscordAuditChannelIds,
|
||||||
@@ -398,16 +399,17 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount> = {
|
|||||||
resolveConfiguredFromCredentialStatuses(account) ?? Boolean(account.token?.trim());
|
resolveConfiguredFromCredentialStatuses(account) ?? Boolean(account.token?.trim());
|
||||||
const app = runtime?.application ?? (probe as { application?: unknown })?.application;
|
const app = runtime?.application ?? (probe as { application?: unknown })?.application;
|
||||||
const bot = runtime?.bot ?? (probe as { bot?: unknown })?.bot;
|
const bot = runtime?.bot ?? (probe as { bot?: unknown })?.bot;
|
||||||
return {
|
const base = buildComputedAccountStatusSnapshot({
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
name: account.name,
|
name: account.name,
|
||||||
enabled: account.enabled,
|
enabled: account.enabled,
|
||||||
configured,
|
configured,
|
||||||
|
runtime,
|
||||||
|
probe,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
...projectCredentialSnapshotFields(account),
|
...projectCredentialSnapshotFields(account),
|
||||||
running: runtime?.running ?? false,
|
|
||||||
lastStartAt: runtime?.lastStartAt ?? null,
|
|
||||||
lastStopAt: runtime?.lastStopAt ?? null,
|
|
||||||
lastError: runtime?.lastError ?? null,
|
|
||||||
connected: runtime?.connected ?? false,
|
connected: runtime?.connected ?? false,
|
||||||
reconnectAttempts: runtime?.reconnectAttempts,
|
reconnectAttempts: runtime?.reconnectAttempts,
|
||||||
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
||||||
@@ -415,10 +417,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount> = {
|
|||||||
lastEventAt: runtime?.lastEventAt ?? null,
|
lastEventAt: runtime?.lastEventAt ?? null,
|
||||||
application: app ?? undefined,
|
application: app ?? undefined,
|
||||||
bot: bot ?? undefined,
|
bot: bot ?? undefined,
|
||||||
probe,
|
|
||||||
audit,
|
audit,
|
||||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
|
||||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
applyAccountNameToChannelSection,
|
applyAccountNameToChannelSection,
|
||||||
applySetupAccountConfigPatch,
|
applySetupAccountConfigPatch,
|
||||||
|
buildComputedAccountStatusSnapshot,
|
||||||
buildChannelConfigSchema,
|
buildChannelConfigSchema,
|
||||||
DEFAULT_ACCOUNT_ID,
|
DEFAULT_ACCOUNT_ID,
|
||||||
deleteAccountFromConfigSection,
|
deleteAccountFromConfigSection,
|
||||||
@@ -504,25 +505,25 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
|
|||||||
lastProbeAt: snapshot.lastProbeAt ?? null,
|
lastProbeAt: snapshot.lastProbeAt ?? null,
|
||||||
}),
|
}),
|
||||||
probeAccount: async ({ account }) => probeGoogleChat(account),
|
probeAccount: async ({ account }) => probeGoogleChat(account),
|
||||||
buildAccountSnapshot: ({ account, runtime, probe }) => ({
|
buildAccountSnapshot: ({ account, runtime, probe }) => {
|
||||||
accountId: account.accountId,
|
const base = buildComputedAccountStatusSnapshot({
|
||||||
name: account.name,
|
accountId: account.accountId,
|
||||||
enabled: account.enabled,
|
name: account.name,
|
||||||
configured: account.credentialSource !== "none",
|
enabled: account.enabled,
|
||||||
credentialSource: account.credentialSource,
|
configured: account.credentialSource !== "none",
|
||||||
audienceType: account.config.audienceType,
|
runtime,
|
||||||
audience: account.config.audience,
|
probe,
|
||||||
webhookPath: account.config.webhookPath,
|
});
|
||||||
webhookUrl: account.config.webhookUrl,
|
return {
|
||||||
running: runtime?.running ?? false,
|
...base,
|
||||||
lastStartAt: runtime?.lastStartAt ?? null,
|
credentialSource: account.credentialSource,
|
||||||
lastStopAt: runtime?.lastStopAt ?? null,
|
audienceType: account.config.audienceType,
|
||||||
lastError: runtime?.lastError ?? null,
|
audience: account.config.audience,
|
||||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
webhookPath: account.config.webhookPath,
|
||||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
webhookUrl: account.config.webhookUrl,
|
||||||
dmPolicy: account.config.dm?.policy ?? "pairing",
|
dmPolicy: account.config.dm?.policy ?? "pairing",
|
||||||
probe,
|
};
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
gateway: {
|
gateway: {
|
||||||
startAccount: async (ctx) => {
|
startAccount: async (ctx) => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
applyAccountNameToChannelSection,
|
applyAccountNameToChannelSection,
|
||||||
applySetupAccountConfigPatch,
|
applySetupAccountConfigPatch,
|
||||||
|
buildComputedAccountStatusSnapshot,
|
||||||
buildChannelConfigSchema,
|
buildChannelConfigSchema,
|
||||||
DEFAULT_ACCOUNT_ID,
|
DEFAULT_ACCOUNT_ID,
|
||||||
deleteAccountFromConfigSection,
|
deleteAccountFromConfigSection,
|
||||||
@@ -392,24 +393,24 @@ export const mattermostPlugin: ChannelPlugin<ResolvedMattermostAccount> = {
|
|||||||
}
|
}
|
||||||
return await probeMattermost(baseUrl, token, timeoutMs);
|
return await probeMattermost(baseUrl, token, timeoutMs);
|
||||||
},
|
},
|
||||||
buildAccountSnapshot: ({ account, runtime, probe }) => ({
|
buildAccountSnapshot: ({ account, runtime, probe }) => {
|
||||||
accountId: account.accountId,
|
const base = buildComputedAccountStatusSnapshot({
|
||||||
name: account.name,
|
accountId: account.accountId,
|
||||||
enabled: account.enabled,
|
name: account.name,
|
||||||
configured: Boolean(account.botToken && account.baseUrl),
|
enabled: account.enabled,
|
||||||
botTokenSource: account.botTokenSource,
|
configured: Boolean(account.botToken && account.baseUrl),
|
||||||
baseUrl: account.baseUrl,
|
runtime,
|
||||||
running: runtime?.running ?? false,
|
probe,
|
||||||
connected: runtime?.connected ?? false,
|
});
|
||||||
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
return {
|
||||||
lastDisconnect: runtime?.lastDisconnect ?? null,
|
...base,
|
||||||
lastStartAt: runtime?.lastStartAt ?? null,
|
botTokenSource: account.botTokenSource,
|
||||||
lastStopAt: runtime?.lastStopAt ?? null,
|
baseUrl: account.baseUrl,
|
||||||
lastError: runtime?.lastError ?? null,
|
connected: runtime?.connected ?? false,
|
||||||
probe,
|
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
||||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
lastDisconnect: runtime?.lastDisconnect ?? null,
|
||||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
};
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
setup: {
|
setup: {
|
||||||
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
applyAccountNameToChannelSection,
|
applyAccountNameToChannelSection,
|
||||||
|
buildComputedAccountStatusSnapshot,
|
||||||
buildChannelConfigSchema,
|
buildChannelConfigSchema,
|
||||||
DEFAULT_ACCOUNT_ID,
|
DEFAULT_ACCOUNT_ID,
|
||||||
deleteAccountFromConfigSection,
|
deleteAccountFromConfigSection,
|
||||||
@@ -443,19 +444,17 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount> = {
|
|||||||
"botTokenStatus",
|
"botTokenStatus",
|
||||||
"appTokenStatus",
|
"appTokenStatus",
|
||||||
])) ?? isSlackAccountConfigured(account);
|
])) ?? isSlackAccountConfigured(account);
|
||||||
return {
|
const base = buildComputedAccountStatusSnapshot({
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
name: account.name,
|
name: account.name,
|
||||||
enabled: account.enabled,
|
enabled: account.enabled,
|
||||||
configured,
|
configured,
|
||||||
...projectCredentialSnapshotFields(account),
|
runtime,
|
||||||
running: runtime?.running ?? false,
|
|
||||||
lastStartAt: runtime?.lastStartAt ?? null,
|
|
||||||
lastStopAt: runtime?.lastStopAt ?? null,
|
|
||||||
lastError: runtime?.lastError ?? null,
|
|
||||||
probe,
|
probe,
|
||||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
});
|
||||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
return {
|
||||||
|
...base,
|
||||||
|
...projectCredentialSnapshotFields(account),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,4 +43,7 @@ export {
|
|||||||
unbindThreadBindingsBySessionKey,
|
unbindThreadBindingsBySessionKey,
|
||||||
} from "../discord/monitor/thread-bindings.js";
|
} from "../discord/monitor/thread-bindings.js";
|
||||||
|
|
||||||
export { buildTokenChannelStatusSummary } from "./status-helpers.js";
|
export {
|
||||||
|
buildComputedAccountStatusSnapshot,
|
||||||
|
buildTokenChannelStatusSummary,
|
||||||
|
} from "./status-helpers.js";
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export {
|
|||||||
listDirectoryGroupEntriesFromMapKeys,
|
listDirectoryGroupEntriesFromMapKeys,
|
||||||
listDirectoryUserEntriesFromAllowFrom,
|
listDirectoryUserEntriesFromAllowFrom,
|
||||||
} from "../channels/plugins/directory-config-helpers.js";
|
} from "../channels/plugins/directory-config-helpers.js";
|
||||||
|
export { buildComputedAccountStatusSnapshot } from "./status-helpers.js";
|
||||||
export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js";
|
export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js";
|
||||||
export { resolveGoogleChatGroupRequireMention } from "../channels/plugins/group-mentions.js";
|
export { resolveGoogleChatGroupRequireMention } from "../channels/plugins/group-mentions.js";
|
||||||
export { formatPairingApproveHint } from "../channels/plugins/helpers.js";
|
export { formatPairingApproveHint } from "../channels/plugins/helpers.js";
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export {
|
|||||||
applySetupAccountConfigPatch,
|
applySetupAccountConfigPatch,
|
||||||
migrateBaseNameToDefaultAccount,
|
migrateBaseNameToDefaultAccount,
|
||||||
} from "../channels/plugins/setup-helpers.js";
|
} from "../channels/plugins/setup-helpers.js";
|
||||||
|
export { buildComputedAccountStatusSnapshot } from "./status-helpers.js";
|
||||||
export { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
|
export { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
|
||||||
export type {
|
export type {
|
||||||
BaseProbeResult,
|
BaseProbeResult,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export {
|
|||||||
} from "../channels/plugins/normalize/slack.js";
|
} from "../channels/plugins/normalize/slack.js";
|
||||||
export { extractSlackToolSend, listSlackMessageActions } from "../slack/message-actions.js";
|
export { extractSlackToolSend, listSlackMessageActions } from "../slack/message-actions.js";
|
||||||
export { buildSlackThreadingToolContext } from "../slack/threading-tool-context.js";
|
export { buildSlackThreadingToolContext } from "../slack/threading-tool-context.js";
|
||||||
|
export { buildComputedAccountStatusSnapshot } from "./status-helpers.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
resolveDefaultGroupPolicy,
|
resolveDefaultGroupPolicy,
|
||||||
|
|||||||
Reference in New Issue
Block a user