TheSpaghettiDetective / obico-server

Obico is a community-built, open-source smart 3D printing platform used by makers, enthusiasts, and tinkerers around the world.
https://obico.io
GNU Affero General Public License v3.0
1.47k stars 297 forks source link

[BUG] Image attachment in Discord stopped working #711

Open kennethjiang opened 1 year ago

kennethjiang commented 1 year ago

It looks like some subtle change in Discord API that has broke the image attachment function.

Steps to reproduce:

from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your discord webhook url')
embed = DiscordEmbed(title='Your Title', description='Lorem ipsum dolor sit', color='03b2f8')
embed.set_image(url='https://app-stg.obico.io/ent/object_store/?t=0/tsd-pics/snapshots/244/1667691350.71139_rotated.jpg&d=48dd0bffee71c77327a9d36374c1332e&ts=1667691350.7235715')
response = webhook.execute()

The message sent won't have the image.

If

embed.set_image(url='https://app-stg.obico.io/ent/object_store/?t=0/tsd-pics/snapshots/244/1667691350.71139_rotated.jpg&d=48dd0bffee71c77327a9d36374c1332e&ts=1667691350.7235715')

is changed to a simpler image url, such as

embed.set_image(url='https://obico.io/img/favicon.png')

the message will have the image correctly attached.

My best guess is some recent change in Discord API has broken its previous behavior. This looks more like a bug in Discord API, so we could just wait it out until Discord fixes it. But it's also possible that it's a "feature" by their design.

Help wanted as we don't have time to dig much deeper atm.

mcstoufer commented 1 year ago

If the resolution of the content is client side, then this should be an easy fix. If that URL is being passed up the Discord endpoint and processed there, there may be some XSS checks that squelch the execution of the parameterized URL. Or it could be something as silly as not finding the URL ending with a valid image file extension. I'll see what I can dig into on the client lib.

pilonull commented 1 year ago

Would love to have image snippets in my obico discord notifications, that would be awesome.