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 { ...@@ -147,9 +147,8 @@ type Data struct {
ImageUrl string `json:"image_url"` ImageUrl string `json:"image_url"`
Type string `json:"type"` Type string `json:"type"`
Player string `json:"player"` Player string `json:"player"`
ThumbUrl string `json:"thumb_url"` Service string `json:"service"`
Footer string `json:"footer"` ServiceIcon string `json:"service_icon"`
FooterIcon string `json:"footer_icon"`
Ts int `json:"ts"` Ts int `json:"ts"`
} }
...@@ -209,31 +208,23 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna ...@@ -209,31 +208,23 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna
for _, fallback := range providerFallbacks { for _, fallback := range providerFallbacks {
out.Color = coalesce([]string{in.metaThemeColor, in.urlProviderMetaThemeColor}) out.Color = coalesce([]string{in.metaThemeColor, in.urlProviderMetaThemeColor})
out.Footer = coalesce([]string{oEmbed.ProviderName, in.ogSiteName, in.urlProviderOgSiteName, in.urlProviderMetaTitle, in.urlProviderTitle}) out.Service = 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})) out.ServiceIcon = resolve(in.url, coalesce([]string{in.linkFavicon, in.urlProviderLinkFavicon, in.urlProviderIconPng, in.urlProviderIconIco}))
if out.Footer != "" && out.FooterIcon != "" { if out.Service != "" && out.ServiceIcon != "" {
break break
} }
fallback(&in) fallback(&in)
} }
var largeImages []string var images []string
var smallImages []string images = append(images, in.twitterImage)
if in.twitterCard == "summary" || in.twitterCard == "summary_large_image" { images = append(images, in.ogImage)
largeImages = append(largeImages, in.twitterImage)
} else {
smallImages = append(smallImages, in.twitterImage)
}
largeImages = append(largeImages, in.ogImage)
smallImages = append(smallImages, in.ogImage)
if in.rawType == "image" { if in.rawType == "image" {
largeImages = append(largeImages, in.url.String()) images = append(images, 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)
} }
out.ImageUrl = resolve(in.url, coalesce(images))
hasType := func(formats []string, types []string) bool { hasType := func(formats []string, types []string) bool {
for _, format := range formats { for _, format := range formats {
for _, t := range types { for _, t := range types {
...@@ -265,9 +256,6 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna ...@@ -265,9 +256,6 @@ func buildData(in InternalData, oEmbed OEmbed, providerFallbacks []func(*Interna
out.Type = "article" out.Type = "article"
} }
out.ThumbUrl = resolve(in.url, coalesce(smallImages))
out.ImageUrl = resolve(in.url, coalesce(largeImages))
buildField := func(title string, value string) { buildField := func(title string, value string) {
const MaxShortFieldLength = 32 const MaxShortFieldLength = 32
value = strings.TrimSpace(value) 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