Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
9138ab80
Unverified
Commit
9138ab80
authored
Jul 22, 2023
by
boojack
Committed by
GitHub
Jul 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: rss route (#2008)
* fix: rss route * chore: update
parent
4231ec5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
jwt.go
api/v1/jwt.go
+1
-1
rss.go
api/v1/rss.go
+36
-0
user.go
api/v1/user.go
+0
-1
vite.config.ts
web/vite.config.ts
+1
-1
No files found.
api/v1/jwt.go
View file @
9138ab80
...
@@ -82,7 +82,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
...
@@ -82,7 +82,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
}
}
// Skip validation for server status endpoints.
// Skip validation for server status endpoints.
if
util
.
HasPrefixes
(
path
,
"/api/v1/ping"
,
"/api/v1/idp"
,
"/api/v1/status"
,
"/api/v1/user
/:id"
)
&&
method
==
http
.
MethodGet
{
if
util
.
HasPrefixes
(
path
,
"/api/v1/ping"
,
"/api/v1/idp"
,
"/api/v1/status"
,
"/api/v1/user
"
)
&&
path
!=
"/api/v1/user/me"
&&
method
==
http
.
MethodGet
{
return
next
(
c
)
return
next
(
c
)
}
}
...
...
api/v1/rss.go
View file @
9138ab80
...
@@ -78,6 +78,42 @@ func (s *APIV1Service) registerRSSRoutes(g *echo.Group) {
...
@@ -78,6 +78,42 @@ func (s *APIV1Service) registerRSSRoutes(g *echo.Group) {
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationXMLCharsetUTF8
)
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationXMLCharsetUTF8
)
return
c
.
String
(
http
.
StatusOK
,
rss
)
return
c
.
String
(
http
.
StatusOK
,
rss
)
})
})
g
.
GET
(
"/u/:username/rss.xml"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
username
:=
c
.
Param
(
"username"
)
user
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
Username
:
&
username
})
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find user"
)
.
SetInternal
(
err
)
}
if
user
==
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusNotFound
,
"User not found"
)
}
systemCustomizedProfile
,
err
:=
s
.
getSystemCustomizedProfile
(
ctx
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to get system customized profile"
)
.
SetInternal
(
err
)
}
normalStatus
:=
store
.
Normal
memoFind
:=
store
.
FindMemo
{
CreatorID
:
&
user
.
ID
,
RowStatus
:
&
normalStatus
,
VisibilityList
:
[]
store
.
Visibility
{
store
.
Public
},
}
memoList
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
&
memoFind
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find memo list"
)
.
SetInternal
(
err
)
}
baseURL
:=
c
.
Scheme
()
+
"://"
+
c
.
Request
()
.
Host
rss
,
err
:=
s
.
generateRSSFromMemoList
(
ctx
,
memoList
,
baseURL
,
systemCustomizedProfile
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to generate rss"
)
.
SetInternal
(
err
)
}
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderContentType
,
echo
.
MIMEApplicationXMLCharsetUTF8
)
return
c
.
String
(
http
.
StatusOK
,
rss
)
})
}
}
func
(
s
*
APIV1Service
)
generateRSSFromMemoList
(
ctx
context
.
Context
,
memoList
[]
*
store
.
Memo
,
baseURL
string
,
profile
*
CustomizedProfile
)
(
string
,
error
)
{
func
(
s
*
APIV1Service
)
generateRSSFromMemoList
(
ctx
context
.
Context
,
memoList
[]
*
store
.
Memo
,
baseURL
string
,
profile
*
CustomizedProfile
)
(
string
,
error
)
{
...
...
api/v1/user.go
View file @
9138ab80
...
@@ -262,7 +262,6 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {
...
@@ -262,7 +262,6 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {
g
.
GET
(
"/user/:username"
,
func
(
c
echo
.
Context
)
error
{
g
.
GET
(
"/user/:username"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
username
:=
c
.
Param
(
"username"
)
username
:=
c
.
Param
(
"username"
)
user
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
Username
:
&
username
})
user
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
Username
:
&
username
})
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find user"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find user"
)
.
SetInternal
(
err
)
...
...
web/vite.config.ts
View file @
9138ab80
...
@@ -23,7 +23,7 @@ export default defineConfig({
...
@@ -23,7 +23,7 @@ export default defineConfig({
target
:
devProxyServer
,
target
:
devProxyServer
,
changeOrigin
:
true
,
changeOrigin
:
true
,
},
},
"^/u/
\\
d*
/rss.xml"
:
{
"^/u/
.+
/rss.xml"
:
{
target
:
devProxyServer
,
target
:
devProxyServer
,
changeOrigin
:
true
,
changeOrigin
:
true
,
},
},
...
...
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