Skip to content

Commit

Permalink
fix: Adding large image only for video on discord, no animated webp
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed May 23, 2022
1 parent fe4e022 commit ca71a71
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/webhook/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/request"
)

const amqpThumbnailDiscordDelay = 10 * time.Second

// EventConsumer handle event pushed to the event bus
func (a *App) EventConsumer(ctx context.Context, event provider.Event) {
a.RLock()
Expand Down Expand Up @@ -112,11 +114,17 @@ func (a *App) discordHandle(ctx context.Context, webhook provider.Webhook, event

if a.amqpClient != nil {
// Waiting a couple of seconds before checking for thumbnail
time.Sleep(time.Second * 15)
time.Sleep(amqpThumbnailDiscordDelay)
}

if a.thumbnailApp.HasThumbnail(ctx, event.Item, thumbnail.SmallSize) {
embed.Thumbnail = discord.NewImage(event.GetURL() + "?thumbnail&scale=large")
thumbnailURL := event.GetURL() + "?thumbnail"

if _, ok := provider.VideoExtensions[event.Item.Extension]; ok {
thumbnailURL += "&scale=large"
}

embed.Thumbnail = discord.NewImage(thumbnailURL)
}

return send(ctx, webhook.ID, request.Post(webhook.URL), discord.NewDataResponse("").AddEmbed(embed))
Expand Down

0 comments on commit ca71a71

Please sign in to comment.