mirror of
https://github.com/dyzulk/trustlab.git
synced 2026-01-26 13:32:06 +07:00
fix: handle secure attachment downloads and fix invalid storage URLs
This commit is contained in:
@@ -216,7 +216,7 @@ export default function AdminTicketDetailsClient() {
|
|||||||
{reply.attachments.map((att: any) => (
|
{reply.attachments.map((att: any) => (
|
||||||
<a
|
<a
|
||||||
key={att.id}
|
key={att.id}
|
||||||
href={getAttachmentUrl(att.file_path)}
|
href={att.download_url || getAttachmentUrl(att.file_path)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className={`flex items-center gap-2 p-2 rounded-lg text-xs transition-colors ${
|
className={`flex items-center gap-2 p-2 rounded-lg text-xs transition-colors ${
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ export default function TicketDetailsClient() {
|
|||||||
{reply.attachments.map((att: any) => (
|
{reply.attachments.map((att: any) => (
|
||||||
<a
|
<a
|
||||||
key={att.id}
|
key={att.id}
|
||||||
href={getAttachmentUrl(att.file_path)}
|
href={att.download_url || getAttachmentUrl(att.file_path)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className={`flex items-center gap-2 p-2 rounded-lg text-xs transition-colors ${
|
className={`flex items-center gap-2 p-2 rounded-lg text-xs transition-colors ${
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const parseApiError = (error: any, defaultMessage: string = "An error occ
|
|||||||
* Handles both old relative paths and new absolute R2 URLs.
|
* Handles both old relative paths and new absolute R2 URLs.
|
||||||
*/
|
*/
|
||||||
export const getAttachmentUrl = (filePath: string) => {
|
export const getAttachmentUrl = (filePath: string) => {
|
||||||
if (!filePath) return "#";
|
if (!filePath || filePath === "0" || filePath === "null") return "#";
|
||||||
|
|
||||||
// If it's already a full URL (R2), return it as is
|
// If it's already a full URL (R2), return it as is
|
||||||
if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
|
if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user