Skip to content

Commit 30ba2c4

Browse files
authored
Merge pull request #9 from Parra-Inc/claude/fix-quote-formatting-pX2eu
Claude/fix quote formatting p x2eu
2 parents 5e7969c + 54ef5fb commit 30ba2c4

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

src/app/api/admin/quotes/[id]/create-post/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NextRequest, NextResponse } from "next/server";
22
import { auth } from "@/lib/auth";
33
import prisma from "@/lib/prisma";
4+
import { cleanQuoteText } from "@/lib/slack";
45

56
async function requireAdmin() {
67
const session = await auth();
@@ -38,7 +39,7 @@ export async function POST(
3839
const post = await prisma.socialPost.create({
3940
data: {
4041
quoteId: id,
41-
content: `\u201c${quote.quoteText}\u201d`,
42+
content: `\u201c${cleanQuoteText(quote.quoteText)}\u201d`,
4243
status: "DRAFT",
4344
channels: {
4445
create: [

src/app/api/queue/image-generation/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async function handler(request: NextRequest) {
214214
channelId: postTargetChannelId,
215215
includesPermalink: !!job.quoteOriginal,
216216
});
217-
let text = `"${quoteText}"`;
217+
let text = `> ${quoteText}`;
218218
if (job.quoteOriginal) {
219219
const permalink = await getMessagePermalink(
220220
slackClient,
@@ -232,7 +232,7 @@ async function handler(request: NextRequest) {
232232
slackClient,
233233
slackChannelId,
234234
messageTs,
235-
`"${quoteText}"`,
235+
`> ${quoteText}`,
236236
storedUrl,
237237
);
238238
}

src/app/api/slack/events/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getParentMessage,
99
isSlackTokenError,
1010
markWorkspaceDisconnected,
11+
cleanQuoteText,
1112
} from "@/lib/slack";
1213
import { detectQuote } from "@/lib/ai/quote-detector";
1314
import { enqueueImageGeneration } from "@/lib/queue/queue";
@@ -425,7 +426,7 @@ async function processMessage(event: SlackEvent, teamId: string) {
425426
slackUserId,
426427
slackUserName: userName,
427428
slackUserAvatarUrl: userAvatarUrl,
428-
quoteText: detection.extractedQuote || text,
429+
quoteText: cleanQuoteText(detection.extractedQuote || text),
429430
attributedTo: detection.attributedTo,
430431
styleId,
431432
aiConfidence: detection.confidence,
@@ -460,7 +461,7 @@ async function processMessage(event: SlackEvent, teamId: string) {
460461
imageGenerationId: imageGeneration.id,
461462
messageTs,
462463
slackChannelId,
463-
quoteText: detection.extractedQuote || text,
464+
quoteText: cleanQuoteText(detection.extractedQuote || text),
464465
styleId,
465466
customStyleDescription,
466467
encryptedBotToken: workspace.slackBotToken,
@@ -610,6 +611,8 @@ async function processMentionInThread(event: SlackEvent, teamId: string) {
610611
return;
611612
}
612613

614+
parentText = cleanQuoteText(parentText);
615+
613616
// Look up existing Quote + ImageGenerations for this parent message
614617
const existingQuote = await prisma.quote.findUnique({
615618
where: {

src/components/admin/admin-workspaces.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ export function AdminWorkspacesManager() {
491491
<SelectContent>
492492
<SelectItem value="FREE">Free — 3/mo, 1 channel</SelectItem>
493493
<SelectItem value="STARTER">
494-
Starter — 25/mo, 1 channel
494+
Starter — 25/mo, 2 channels
495495
</SelectItem>
496496
<SelectItem value="TEAM">
497497
Team — 100/mo, 3 channels

src/components/dashboard/settings-billing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const PLANS = [
7171
`${TIER_QUOTAS.STARTER} images per month`,
7272
`${TIER_IMAGE_QUALITY_LABEL.STARTER} image quality`,
7373
`${TIER_IMAGE_SIZE.STARTER} resolution`,
74-
`${TIER_MAX_CHANNELS.STARTER} channel`,
74+
`${TIER_MAX_CHANNELS.STARTER} channels`,
7575
"No watermark",
7676
"Collections",
7777
"AI style selection",

src/components/marketing/pricing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const tiers = [
4242
"25 generated images/month",
4343
`${TIER_IMAGE_QUALITY_LABEL.STARTER} image quality`,
4444
`${TIER_IMAGE_SIZE.STARTER} resolution`,
45-
"1 connected channel",
45+
"2 connected channels",
4646
`All ${allStyleCount} art styles`,
4747
"No watermark",
4848
"Full image history",

src/lib/slack.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,17 @@ export async function getParentMessage(
211211

212212
return result.messages?.[0]?.text || null;
213213
}
214+
215+
/**
216+
* Strip Slack blockquote prefixes (&gt; / >) and surrounding quotation marks
217+
* from quote text so it can be stored and displayed cleanly.
218+
*/
219+
export function cleanQuoteText(text: string): string {
220+
return text
221+
.split("\n")
222+
.map((line) => line.replace(/^(?:&gt;|>)\s?/, ""))
223+
.join("\n")
224+
.trim()
225+
.replace(/^[\u201c\u201d"]+|[\u201c\u201d"]+$/g, "")
226+
.trim();
227+
}

src/lib/tier-constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const TIER_QUOTAS: Record<string, number> = {
1010

1111
export const TIER_MAX_CHANNELS: Record<string, number> = {
1212
FREE: 1,
13-
STARTER: 1,
13+
STARTER: 2,
1414
TEAM: 3,
1515
BUSINESS: INFINITY,
1616
ENTERPRISE: INFINITY,

0 commit comments

Comments
 (0)