Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
embed-helper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
embed-helper
Commits
215137df
Verified
Commit
215137df
authored
6 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Improve compatibility with the IRCCloud Slack gateway
parent
0b15e731
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.go
+23
-35
23 additions, 35 deletions
main.go
with
23 additions
and
35 deletions
main.go
+
23
−
35
View file @
215137df
...
@@ -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
.
Footer
Icon
=
resolve
(
in
.
url
,
coalesce
([]
string
{
in
.
linkFavicon
,
in
.
urlProviderLinkFavicon
,
in
.
urlProviderIconPng
,
in
.
urlProviderIconIco
}))
out
.
Service
Icon
=
resolve
(
in
.
url
,
coalesce
([]
string
{
in
.
linkFavicon
,
in
.
urlProviderLinkFavicon
,
in
.
urlProviderIconPng
,
in
.
urlProviderIconIco
}))
if
out
.
Footer
!=
""
&&
out
.
Footer
Icon
!=
""
{
if
out
.
Service
!=
""
&&
out
.
Service
Icon
!=
""
{
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment