mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
feat: proxy feedback-scoped admin attachments (#2059)
Signed-off-by: npub1dccv64krpcpse5cmkzfeh998cftungyatw3djt8jwdw6g43f7fyqzzmrf7 <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1dccv64krpcpse5cmkzfeh998cftungyatw3djt8jwdw6g43f7fyqzzmrf7 <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
@@ -401,6 +401,7 @@ function FeedbackDetailView({ id }: { id: string }) {
|
||||
<StateView resource={resource}>
|
||||
{(feedback) => {
|
||||
const attachments = feedbackAttachments(
|
||||
feedback.id,
|
||||
feedback.tags,
|
||||
feedback.communityHost,
|
||||
);
|
||||
@@ -457,6 +458,7 @@ type FeedbackStatuses = Record<string, boolean>;
|
||||
|
||||
interface FeedbackAttachment {
|
||||
url: string;
|
||||
sourceUrl: string;
|
||||
mimeType: string;
|
||||
hash: string;
|
||||
size?: number;
|
||||
@@ -494,6 +496,7 @@ function timeRangeStart(range: string) {
|
||||
}
|
||||
|
||||
function feedbackAttachments(
|
||||
feedbackId: string,
|
||||
tags: string[][],
|
||||
communityHost: string,
|
||||
): FeedbackAttachment[] {
|
||||
@@ -514,7 +517,8 @@ function feedbackAttachments(
|
||||
const parsedSize = Number(values.get("size"));
|
||||
return [
|
||||
{
|
||||
url: safeUrl,
|
||||
url: `/api/admin/v1/feedback/${encodeURIComponent(feedbackId)}/attachments/${hash}`,
|
||||
sourceUrl: safeUrl,
|
||||
mimeType,
|
||||
hash,
|
||||
size:
|
||||
@@ -546,7 +550,7 @@ function stripAttachmentMarkdown(
|
||||
attachments?: FeedbackAttachment[],
|
||||
) {
|
||||
const knownUrls = attachments
|
||||
? new Set(attachments.map((attachment) => attachment.url))
|
||||
? new Set(attachments.map((attachment) => attachment.sourceUrl))
|
||||
: undefined;
|
||||
return body
|
||||
.replace(/!?\[[^\]]*\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g, (match, url) => {
|
||||
|
||||
@@ -235,10 +235,16 @@ test("feedback attachments render from imeta without raw markdown", async ({
|
||||
await expect(page.getByText("![image]", { exact: false })).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("img", { name: "screenshot.png" }),
|
||||
).toHaveAttribute("src", imageUrl);
|
||||
).toHaveAttribute(
|
||||
"src",
|
||||
`/api/admin/v1/feedback/${id}/attachments/${"a".repeat(64)}`,
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("link", { name: /diagnostics.txt/ }),
|
||||
).toHaveAttribute("href", fileUrl);
|
||||
).toHaveAttribute(
|
||||
"href",
|
||||
`/api/admin/v1/feedback/${id}/attachments/${"b".repeat(64)}`,
|
||||
);
|
||||
const fileHeight = await page
|
||||
.locator(".file-attachment")
|
||||
.evaluate((element) => element.getBoundingClientRect().height);
|
||||
|
||||
Reference in New Issue
Block a user