Skip to content

Commit dc35e25

Browse files
committed
Fix strip images/ignore new lines not applying in template preview
1 parent 4b9cf74 commit dc35e25

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

services/backend-api/client/src/features/feedConnections/api/createTemplatePreview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export interface CreateTemplatePreviewInput {
1414
dateFormat?: string | null;
1515
dateTimezone?: string | null;
1616
} | null;
17+
connectionFormatOptions?: {
18+
formatTables?: boolean;
19+
stripImages?: boolean;
20+
ignoreNewLines?: boolean;
21+
} | null;
1722
placeholderLimits?: Array<{
1823
placeholder: string;
1924
characterCount: number;

services/backend-api/client/src/features/templates/components/TemplateGalleryModal/templatePreviewUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ const convertV2RootToTemplatePreviewInput = (
162162
content: null,
163163
embeds: undefined,
164164
componentsV2: componentsV2.length > 0 ? componentsV2 : null,
165+
connectionFormatOptions: {
166+
formatTables: messageComponent.formatTables,
167+
stripImages: messageComponent.stripImages,
168+
ignoreNewLines: messageComponent.ignoreNewLines,
169+
},
165170
enablePlaceholderFallback: messageComponent.enablePlaceholderFallback,
166171
placeholderLimits: messageComponent.placeholderLimits,
167172
};
@@ -251,6 +256,11 @@ export const convertTemplateMessageComponentToPreviewInput = (
251256
content: content || null,
252257
embeds: embeds.length > 0 ? embeds : undefined,
253258
componentsV2: null,
259+
connectionFormatOptions: {
260+
formatTables: messageComponent.formatTables,
261+
stripImages: messageComponent.stripImages,
262+
ignoreNewLines: messageComponent.ignoreNewLines,
263+
},
254264
enablePlaceholderFallback: messageComponent.enablePlaceholderFallback,
255265
placeholderLimits: messageComponent.placeholderLimits,
256266
};

services/backend-api/src/features/feed-connections/dto/create-template-preview-input.dto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import {
1313
UserFeedFormatOptions,
1414
DiscordPlaceholderLimitOptions,
15+
DiscordConnectionFormatterOptions,
1516
} from "../../../common";
1617
import { DiscordPreviewEmbed } from "../../../common/types/discord-preview-embed.type";
1718

@@ -50,6 +51,13 @@ export class CreateTemplatePreviewInputDto {
5051
@ValidateIf((v) => v !== null)
5152
userFeedFormatOptions?: UserFeedFormatOptions | null;
5253

54+
@IsOptional()
55+
@Type(() => DiscordConnectionFormatterOptions)
56+
@ValidateNested()
57+
@IsObject()
58+
@ValidateIf((v) => v !== null)
59+
connectionFormatOptions?: DiscordConnectionFormatterOptions | null;
60+
5361
@IsOptional()
5462
@Type(() => Boolean)
5563
@IsBoolean()

services/backend-api/src/features/feed-connections/feed-connections-discord-channels.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export class FeedConnectionsDiscordChannelsController {
305305
content,
306306
embeds,
307307
userFeedFormatOptions,
308+
connectionFormatOptions,
308309
placeholderLimits,
309310
enablePlaceholderFallback,
310311
componentsV2,
@@ -313,6 +314,7 @@ export class FeedConnectionsDiscordChannelsController {
313314
const result = await this.service.createTemplatePreview({
314315
userFeed: feed,
315316
feedFormatOptions: { ...feed.formatOptions, ...userFeedFormatOptions },
317+
connectionFormatOptions,
316318
articleId: article?.id,
317319
content,
318320
embeds,

services/backend-api/src/features/feed-connections/feed-connections-discord-channels.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ interface CreateTemplatePreviewInput {
159159
content?: string;
160160
embeds?: DiscordPreviewEmbed[];
161161
feedFormatOptions: UserFeed["formatOptions"] | null;
162+
connectionFormatOptions?:
163+
| DiscordChannelConnection["details"]["formatter"]
164+
| null;
162165
articleId?: string;
163166
placeholderLimits?:
164167
| DiscordChannelConnection["details"]["placeholderLimits"]
@@ -1281,6 +1284,7 @@ export class FeedConnectionsDiscordChannelsService {
12811284
content,
12821285
embeds,
12831286
feedFormatOptions,
1287+
connectionFormatOptions,
12841288
articleId,
12851289
placeholderLimits,
12861290
enablePlaceholderFallback,
@@ -1340,7 +1344,7 @@ export class FeedConnectionsDiscordChannelsService {
13401344
) || [],
13411345
}))
13421346
),
1343-
formatter: undefined,
1347+
formatter: connectionFormatOptions || undefined,
13441348
splitOptions: undefined,
13451349
mentions: undefined,
13461350
customPlaceholders: undefined,
@@ -1350,7 +1354,7 @@ export class FeedConnectionsDiscordChannelsService {
13501354
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13511355
componentsV2: (componentsV2 as any) ?? undefined,
13521356
},
1353-
} as const;
1357+
};
13541358

13551359
return this.feedHandlerService.createPreview({
13561360
details: payload,

0 commit comments

Comments
 (0)