Skip to content
GitLab
Explore
Sign in
derf
travelynx
Compare revisions
8d7e66cdc8150b5390f7cc1de90609a461cc6cc9 to 6d07d0a18027d7647a375849f85201bbd532161c
Commits on Source (2)
/status: respond to .json as well as "Accept: application/json"
· 0a859715
Birte Kristina Friesel
authored
Apr 26, 2024
0a859715
/status: return JSON for 404 errors as well
· 6d07d0a1
Birte Kristina Friesel
authored
Apr 26, 2024
6d07d0a1
Hide whitespace changes
Inline
Side-by-side
lib/Travelynx.pm
View file @
6d07d0a1
...
...
@@ -2358,8 +2358,10 @@ sub startup {
$r
->
get
('
/recover
')
->
to
('
account#request_password_reset
');
$r
->
get
('
/recover/:id/:token
')
->
to
('
account#recover_password
');
$r
->
get
('
/reg/:id/:token
')
->
to
('
account#verify
');
$r
->
get
('
/status/:name
')
->
to
('
profile#user_status
');
$r
->
get
('
/status/:name/:ts
')
->
to
('
profile#user_status
');
$r
->
get
(
'
/status/:name
'
=>
[
format
=>
[
'
html
',
'
json
'
]
]
)
->
to
(
'
profile#user_status
',
format
=>
undef
);
$r
->
get
(
'
/status/:name/:ts
'
=>
[
format
=>
[
'
html
',
'
json
'
]
]
)
->
to
(
'
profile#user_status
',
format
=>
undef
);
$r
->
get
('
/ajax/status/#name
')
->
to
('
profile#status_card
');
$r
->
get
('
/ajax/status/:name/:ts
')
->
to
('
profile#status_card
');
$r
->
get
('
/p/:name
')
->
to
('
profile#profile
');
...
...
lib/Travelynx/Controller/Profile.pm
View file @
6d07d0a1
...
...
@@ -334,7 +334,16 @@ sub user_status {
my
$user
=
$self
->
users
->
get_privacy_by
(
name
=>
$name
);
if
(
not
$user
)
{
$self
->
render
(
'
not_found
',
status
=>
404
);
$self
->
respond_to
(
json
=>
{
json
=>
{
error
=>
'
not found
'
},
status
=>
404
,
},
any
=>
{
template
=>
'
not_found
',
status
=>
404
}
);
return
;
}
...
...
@@ -389,11 +398,29 @@ sub user_status {
"
/p/
${name}
/j/
$journey
->{id}?token=
${token}
-
${ts}
");
}
else
{
$self
->
render
(
'
not_found
',
status
=>
404
);
$self
->
respond_to
(
json
=>
{
json
=>
{
error
=>
'
not found
'
},
status
=>
404
,
},
any
=>
{
template
=>
'
not_found
',
status
=>
404
}
);
}
return
;
}
$self
->
render
(
'
not_found
',
status
=>
404
);
$self
->
respond_to
(
json
=>
{
json
=>
{
error
=>
'
not found
'
},
status
=>
404
,
},
any
=>
{
template
=>
'
not_found
',
status
=>
404
}
);
return
;
}
...
...