mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 12:41:12 +00:00
refactor: dedupe matrix trimmed readers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { GatewayRequestHandlerOptions } from "openclaw/plugin-sdk/core";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { formatMatrixErrorMessage } from "./matrix/errors.js";
|
||||
|
||||
function sendError(respond: (ok: boolean, payload?: unknown) => void, err: unknown) {
|
||||
@@ -18,13 +19,12 @@ export async function handleVerifyRecoveryKey({
|
||||
}: GatewayRequestHandlerOptions): Promise<void> {
|
||||
try {
|
||||
const { verifyMatrixRecoveryKey } = await import("./matrix/actions/verification.js");
|
||||
const key = typeof params?.key === "string" ? params.key : "";
|
||||
if (!key.trim()) {
|
||||
const key = normalizeOptionalString(params?.key);
|
||||
if (!key) {
|
||||
respond(false, { error: "key required" });
|
||||
return;
|
||||
}
|
||||
const accountId =
|
||||
typeof params?.accountId === "string" ? params.accountId.trim() || undefined : undefined;
|
||||
const accountId = normalizeOptionalString(params?.accountId);
|
||||
const result = await verifyMatrixRecoveryKey(key, { accountId });
|
||||
respond(result.success, result);
|
||||
} catch (err) {
|
||||
@@ -38,8 +38,7 @@ export async function handleVerificationBootstrap({
|
||||
}: GatewayRequestHandlerOptions): Promise<void> {
|
||||
try {
|
||||
const { bootstrapMatrixVerification } = await import("./matrix/actions/verification.js");
|
||||
const accountId =
|
||||
typeof params?.accountId === "string" ? params.accountId.trim() || undefined : undefined;
|
||||
const accountId = normalizeOptionalString(params?.accountId);
|
||||
const recoveryKey = typeof params?.recoveryKey === "string" ? params.recoveryKey : undefined;
|
||||
const forceResetCrossSigning = params?.forceResetCrossSigning === true;
|
||||
const result = await bootstrapMatrixVerification({
|
||||
@@ -59,8 +58,7 @@ export async function handleVerificationStatus({
|
||||
}: GatewayRequestHandlerOptions): Promise<void> {
|
||||
try {
|
||||
const { getMatrixVerificationStatus } = await import("./matrix/actions/verification.js");
|
||||
const accountId =
|
||||
typeof params?.accountId === "string" ? params.accountId.trim() || undefined : undefined;
|
||||
const accountId = normalizeOptionalString(params?.accountId);
|
||||
const includeRecoveryKey = params?.includeRecoveryKey === true;
|
||||
const status = await getMatrixVerificationStatus({ accountId, includeRecoveryKey });
|
||||
respond(true, status);
|
||||
|
||||
Reference in New Issue
Block a user