diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!
https://zipline.diced.sh/
MIT License
1.6k stars 143 forks source link

Skipping Replace of placeholder values in Discord Webhooks for File Uploads #178

Closed MrMysterius closed 2 years ago

MrMysterius commented 2 years ago

https://github.com/diced/zipline/blob/4589c6ee0aacd982478d7e4e107d4aa47fa0873f/src/lib/discord.ts#L18-L24

This bit is getting skipped for some reason, only on Files, URLs work.

image

MrMysterius commented 2 years ago

Side note .replace(/{file.id}/gi, args[1].id.toString()) the . in the regex is not escaped (\.), so it counts as any character and not explicitly the dot so:

are all valid placeholders.

diced commented 2 years ago

Could you send your variables for the discord notifs, so I can test them with your config.

MrMysterius commented 2 years ago

This should be mine:

DISCORD_UPLOAD_EMBED_TITLE: ":page_facing_up: FILE/IMAGE/TEXT Upload from {user.name}"
DISCORD_UPLOAD_EMBED_DESCRIPTION: "**URL/LINK:** `{link}`\n**ID:** `{file.id}`\n**TYPE:** `{file.mime}`\n**NAME:** `{file.file}`"
DISCORD_UPLOAD_EMBED_COLOR: 0xffe051
DISCORD_UPLOAD_EMBED_IMAGE: true
DISCORD_UPLOAD_EMBED_THUMBNAIL: false
DISCORD_UPLOAD_EMBED_TIMESTAMP: true
DISCORD_SHORTEN_EMBED_TITLE: ":link: URL Shortened by {user.name}"
DISCORD_SHORTEN_EMBED_DESCRIPTION: "**URL/LINK:** `{link}`\n**ID:** `{url.id}`\n**VANITY:** `{url.vanity}`\n**DESTINATION:** `{url.destination}`"
DISCORD_SHORTEN_EMBED_COLOR: 0x5170ff
DISCORD_SHORTEN_EMBED_IMAGE: false
DISCORD_SHORTEN_EMBED_THUMBNAIL: false
DISCORD_SHORTEN_EMBED_TIMESTAMP: true

From the Link Shorten the placeholder work. On the File Uploads they don't.

diced commented 2 years ago

Weird.. Unable to reproduce this. I'll push a fix that fixes the . thing in the regex and you can change to the trunk tag in docker once it updates.

MrMysterius commented 2 years ago

I don't know what exactly change or if the fix/change fixed it 78a6f3122d3218689d7f6dfa702915e8b4f11985, but it seems to replace it now.

image