mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:24:33 +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 type { ChannelAccountSnapshot, ChannelStatusIssue } from "../types.js";
|
||||||
import { appendMatchMetadata, asString, isRecord } from "./shared.js";
|
import {
|
||||||
|
appendMatchMetadata,
|
||||||
|
asString,
|
||||||
|
isRecord,
|
||||||
|
resolveEnabledConfiguredAccountId,
|
||||||
|
} from "./shared.js";
|
||||||
|
|
||||||
type DiscordIntentSummary = {
|
type DiscordIntentSummary = {
|
||||||
messageContent?: "enabled" | "limited" | "disabled";
|
messageContent?: "enabled" | "limited" | "disabled";
|
||||||
@@ -111,10 +116,8 @@ export function collectDiscordStatusIssues(
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const accountId = asString(account.accountId) ?? "default";
|
const accountId = resolveEnabledConfiguredAccountId(account);
|
||||||
const enabled = account.enabled !== false;
|
if (!accountId) {
|
||||||
const configured = account.configured === true;
|
|
||||||
if (!enabled || !configured) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,14 @@ export function appendMatchMetadata(
|
|||||||
const meta = formatMatchMetadata(params);
|
const meta = formatMatchMetadata(params);
|
||||||
return meta ? `${message} (${meta})` : message;
|
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 type { ChannelAccountSnapshot, ChannelStatusIssue } from "../types.js";
|
||||||
import { appendMatchMetadata, asString, isRecord } from "./shared.js";
|
import {
|
||||||
|
appendMatchMetadata,
|
||||||
|
asString,
|
||||||
|
isRecord,
|
||||||
|
resolveEnabledConfiguredAccountId,
|
||||||
|
} from "./shared.js";
|
||||||
|
|
||||||
type TelegramAccountStatus = {
|
type TelegramAccountStatus = {
|
||||||
accountId?: unknown;
|
accountId?: unknown;
|
||||||
@@ -81,10 +86,8 @@ export function collectTelegramStatusIssues(
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const accountId = asString(account.accountId) ?? "default";
|
const accountId = resolveEnabledConfiguredAccountId(account);
|
||||||
const enabled = account.enabled !== false;
|
if (!accountId) {
|
||||||
const configured = account.configured === true;
|
|
||||||
if (!enabled || !configured) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user