Skip to content
Snippets Groups Projects
Verified Commit 215137df authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improve compatibility with the IRCCloud Slack gateway

parent 0b15e731
No related branches found
No related tags found
No related merge requests found
......@@ -147,9 +147,8 @@ type Data struct {
ImageUrl string `json:"image_url"`
Type string `json:"type"`
Player string `json:"player"`
ThumbUrl string `json:"thumb_url"`
Footer string `json:"footer"`
FooterIcon string `json:"footer_icon"`
Service string `json:"service"`
ServiceIcon string `json:"service_icon"`
Ts int `json:"ts"`
}
......@@ -209,31 +208,23 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna
for _, fallback := range providerFallbacks {
out.Color = coalesce([]string{in.metaThemeColor, in.urlProviderMetaThemeColor})
out.Footer = coalesce([]string{oEmbed.ProviderName, in.ogSiteName, in.urlProviderOgSiteName, in.urlProviderMetaTitle, in.urlProviderTitle})
out.FooterIcon = resolve(in.url, coalesce([]string{in.linkFavicon, in.urlProviderLinkFavicon, in.urlProviderIconPng, in.urlProviderIconIco}))
if out.Footer != "" && out.FooterIcon != "" {
out.Service = coalesce([]string{oEmbed.ProviderName, in.ogSiteName, in.urlProviderOgSiteName, in.urlProviderMetaTitle, in.urlProviderTitle})
out.ServiceIcon = resolve(in.url, coalesce([]string{in.linkFavicon, in.urlProviderLinkFavicon, in.urlProviderIconPng, in.urlProviderIconIco}))
if out.Service != "" && out.ServiceIcon != "" {
break
}
fallback(&in)
}
var largeImages []string
var smallImages []string
if in.twitterCard == "summary" || in.twitterCard == "summary_large_image" {
largeImages = append(largeImages, in.twitterImage)
} else {
smallImages = append(smallImages, in.twitterImage)
}
largeImages = append(largeImages, in.ogImage)
smallImages = append(smallImages, in.ogImage)
var images []string
images = append(images, in.twitterImage)
images = append(images, in.ogImage)
if in.rawType == "image" {
largeImages = append(largeImages, in.url.String())
}
// Only use favicon as thumbnail icon if we don’t already use it for the footer
if out.Footer == "" {
smallImages = append(smallImages, in.linkFavicon)
images = append(images, in.url.String())
}
out.ImageUrl = resolve(in.url, coalesce(images))
hasType := func(formats []string, types []string) bool {
for _, format := range formats {
for _, t := range types {
......@@ -265,9 +256,6 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna
out.Type = "article"
}
out.ThumbUrl = resolve(in.url, coalesce(smallImages))
out.ImageUrl = resolve(in.url, coalesce(largeImages))
buildField := func(title string, value string) {
const MaxShortFieldLength = 32
value = strings.TrimSpace(value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment