Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
mattermost-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
sysadmin
mattermost
mattermost-server
Commits
afe70295
Commit
afe70295
authored
Oct 02, 2018
by
Jesse Haka
Committed by
Jesús Espino
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if EnableLinkPreviews not enabled, do not call url (#9461)
parent
6d910548
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
api4/system.go
api4/system.go
+7
-3
api4/system_test.go
api4/system_test.go
+19
-0
No files found.
api4/system.go
View file @
afe70295
...
...
@@ -451,6 +451,13 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
}
func
getRedirectLocation
(
c
*
Context
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
m
:=
make
(
map
[
string
]
string
)
m
[
"location"
]
=
""
cfg
:=
c
.
App
.
GetConfig
()
if
!*
cfg
.
ServiceSettings
.
EnableLinkPreviews
{
w
.
Write
([]
byte
(
model
.
MapToJson
(
m
)))
return
}
url
:=
r
.
URL
.
Query
()
.
Get
(
"url"
)
if
len
(
url
)
==
0
{
c
.
SetInvalidParam
(
"url"
)
...
...
@@ -463,9 +470,6 @@ func getRedirectLocation(c *Context, w http.ResponseWriter, r *http.Request) {
},
}
m
:=
make
(
map
[
string
]
string
)
m
[
"location"
]
=
""
res
,
err
:=
client
.
Head
(
url
)
if
err
!=
nil
{
// Always return a success status and a JSON string to limit the amount of information returned to a
...
...
api4/system_test.go
View file @
afe70295
...
...
@@ -717,6 +717,12 @@ func TestRedirectLocation(t *testing.T) {
th
:=
Setup
()
.
InitBasic
()
.
InitSystemAdmin
()
defer
th
.
TearDown
()
Client
:=
th
.
Client
enableLinkPreviews
:=
*
th
.
App
.
Config
()
.
ServiceSettings
.
EnableLinkPreviews
defer
func
()
{
th
.
App
.
UpdateConfig
(
func
(
cfg
*
model
.
Config
)
{
*
cfg
.
ServiceSettings
.
EnableLinkPreviews
=
enableLinkPreviews
})
}()
*
th
.
App
.
Config
()
.
ServiceSettings
.
EnableLinkPreviews
=
true
_
,
resp
:=
th
.
SystemAdminClient
.
GetRedirectLocation
(
"https://mattermost.com/"
,
""
)
CheckNoError
(
t
,
resp
)
...
...
@@ -730,6 +736,19 @@ func TestRedirectLocation(t *testing.T) {
t
.
Errorf
(
"Expected %v but got %v."
,
expected
,
actual
)
}
*
th
.
App
.
Config
()
.
ServiceSettings
.
EnableLinkPreviews
=
false
actual
,
resp
=
th
.
SystemAdminClient
.
GetRedirectLocation
(
"https://mattermost.com/"
,
""
)
CheckNoError
(
t
,
resp
)
assert
.
Equal
(
t
,
actual
,
""
)
actual
,
resp
=
th
.
SystemAdminClient
.
GetRedirectLocation
(
""
,
""
)
CheckNoError
(
t
,
resp
)
assert
.
Equal
(
t
,
actual
,
""
)
actual
,
resp
=
th
.
SystemAdminClient
.
GetRedirectLocation
(
mockBitlyLink
,
""
)
CheckNoError
(
t
,
resp
)
assert
.
Equal
(
t
,
actual
,
""
)
Client
.
Logout
()
_
,
resp
=
Client
.
GetRedirectLocation
(
""
,
""
)
CheckUnauthorizedStatus
(
t
,
resp
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment