diff --git a/backend/src/plugins/Logs/types.ts b/backend/src/plugins/Logs/types.ts index 41af232d..1efbbc62 100644 --- a/backend/src/plugins/Logs/types.ts +++ b/backend/src/plugins/Logs/types.ts @@ -27,19 +27,11 @@ const DEFAULT_BATCH_TIME = 1000; const MIN_BATCH_TIME = 250; const MAX_BATCH_TIME = 5000; -const zStrictLogMessageContent = zStrictMessageContent.extend({ - embed: zEmbedInput.optional(), -}); -const zLogMessageContent = z.union([ - zBoundedCharacters(0, 2000), - zStrictLogMessageContent, -]); - // A bit of a workaround so we can pass LogType keys to z.enum() -const zMessageContentWithDefault = zLogMessageContent.default(""); +const zMessageContentWithDefault = zMessageContent.default(""); const logTypes = keys(LogType); const logTypeProps = logTypes.reduce((map, type) => { - map[type] = zLogMessageContent.default(DefaultLogMessages[type] || ""); + map[type] = zMessageContent.default(DefaultLogMessages[type] || ""); return map; }, {} as Record); const zLogFormats = z.strictObject(logTypeProps); diff --git a/backend/src/plugins/Logs/util/getLogMessage.ts b/backend/src/plugins/Logs/util/getLogMessage.ts index 7214a08f..30c92087 100644 --- a/backend/src/plugins/Logs/util/getLogMessage.ts +++ b/backend/src/plugins/Logs/util/getLogMessage.ts @@ -37,11 +37,6 @@ export async function getLogMessage( const format = opts?.format?.[LogType[type]] || config.format[LogType[type]] || ""; if (format === "" || format == null) return null; - if (typeof format === "object" && format.embed) { - format.embeds = [format.embed]; - delete format.embed; - } - // See comment on FORMAT_NO_TIMESTAMP in types.ts const timestampFormat = opts?.timestamp_format ?? config.timestamp_format; diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 3bb3e0eb..796326e6 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -270,6 +270,13 @@ export const zStrictMessageContent = z.strictObject({ content: z.string().optional(), tts: z.boolean().optional(), embeds: z.array(zEmbedInput).optional(), + embed: zEmbedInput.optional(), +}).transform((data) => { + if (data.embed) { + data.embeds = [data.embed]; + delete data.embed; + } + return data as StrictMessageContent; }); export type ZStrictMessageContent = z.infer;