mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:11:25 +00:00
refactor(status-issues): share enabled/configured account gate
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import type { ChannelAccountSnapshot, ChannelStatusIssue } from "../types.js";
|
||||
import { appendMatchMetadata, asString, isRecord } from "./shared.js";
|
||||
import {
|
||||
appendMatchMetadata,
|
||||
asString,
|
||||
isRecord,
|
||||
resolveEnabledConfiguredAccountId,
|
||||
} from "./shared.js";
|
||||
|
||||
type DiscordIntentSummary = {
|
||||
messageContent?: "enabled" | "limited" | "disabled";
|
||||
@@ -111,10 +116,8 @@ export function collectDiscordStatusIssues(
|
||||
if (!account) {
|
||||
continue;
|
||||
}
|
||||
const accountId = asString(account.accountId) ?? "default";
|
||||
const enabled = account.enabled !== false;
|
||||
const configured = account.configured === true;
|
||||
if (!enabled || !configured) {
|
||||
const accountId = resolveEnabledConfiguredAccountId(account);
|
||||
if (!accountId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,3 +30,14 @@ export function appendMatchMetadata(
|
||||
const meta = formatMatchMetadata(params);
|
||||
return meta ? `${message} (${meta})` : message;
|
||||
}
|
||||
|
||||
export function resolveEnabledConfiguredAccountId(account: {
|
||||
accountId?: unknown;
|
||||
enabled?: unknown;
|
||||
configured?: unknown;
|
||||
}): string | null {
|
||||
const accountId = asString(account.accountId) ?? "default";
|
||||
const enabled = account.enabled !== false;
|
||||
const configured = account.configured === true;
|
||||
return enabled && configured ? accountId : null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import type { ChannelAccountSnapshot, ChannelStatusIssue } from "../types.js";
|
||||
import { appendMatchMetadata, asString, isRecord } from "./shared.js";
|
||||
import {
|
||||
appendMatchMetadata,
|
||||
asString,
|
||||
isRecord,
|
||||
resolveEnabledConfiguredAccountId,
|
||||
} from "./shared.js";
|
||||
|
||||
type TelegramAccountStatus = {
|
||||
accountId?: unknown;
|
||||
@@ -81,10 +86,8 @@ export function collectTelegramStatusIssues(
|
||||
if (!account) {
|
||||
continue;
|
||||
}
|
||||
const accountId = asString(account.accountId) ?? "default";
|
||||
const enabled = account.enabled !== false;
|
||||
const configured = account.configured === true;
|
||||
if (!enabled || !configured) {
|
||||
const accountId = resolveEnabledConfiguredAccountId(account);
|
||||
if (!accountId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user