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
6ff7cfdd
Unverified
Commit
6ff7cfdd
authored
Apr 04, 2023
by
boojack
Committed by
GitHub
Apr 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: return external link directly (#1465)
* fix: return external link directly * chore: update
parent
5361f76b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
15 deletions
+16
-15
resource.go
server/resource.go
+0
-4
system.go
server/system.go
+4
-1
04__resource_public_id.sql
store/db/migration/prod/0.12/04__resource_public_id.sql
+8
-10
resource.ts
web/src/utils/resource.ts
+4
-0
No files found.
server/resource.go
View file @
6ff7cfdd
...
...
@@ -334,10 +334,6 @@ func (s *Server) registerResourcePublicRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"Failed to find resource by ID: %v"
,
resourceID
))
.
SetInternal
(
err
)
}
if
resource
.
ExternalLink
!=
""
{
return
c
.
Redirect
(
http
.
StatusSeeOther
,
resource
.
ExternalLink
)
}
blob
:=
resource
.
Blob
if
resource
.
InternalPath
!=
""
{
src
,
err
:=
os
.
Open
(
resource
.
InternalPath
)
...
...
server/system.go
View file @
6ff7cfdd
...
...
@@ -9,6 +9,8 @@ import (
"github.com/google/uuid"
"github.com/usememos/memos/api"
"github.com/usememos/memos/common"
"github.com/usememos/memos/common/log"
"go.uber.org/zap"
"github.com/labstack/echo/v4"
)
...
...
@@ -67,7 +69,8 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
var
baseValue
any
err
:=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
baseValue
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal system setting value"
)
.
SetInternal
(
err
)
log
.
Warn
(
"Failed to unmarshal system setting value"
,
zap
.
String
(
"setting name"
,
systemSetting
.
Name
.
String
()))
continue
}
if
systemSetting
.
Name
==
api
.
SystemSettingAllowSignUpName
{
...
...
store/db/migration/prod/0.12/04__resource_public_id.sql
View file @
6ff7cfdd
...
...
@@ -3,19 +3,17 @@ ALTER TABLE
ADD
COLUMN
public_id
TEXT
NOT
NULL
DEFAULT
''
;
-- TODO(steven): remove this in next release.
CREATE
UNIQUE
INDEX
resource_id_public_id_unique_index
ON
resource
(
id
,
public_id
);
UPDATE
resource
SET
public_id
=
(
SELECT
printf
(
public_id
=
printf
(
'%s-%s-%s-%s-%s'
,
lower
(
hex
(
randomblob
(
4
))),
lower
(
hex
(
randomblob
(
2
))),
lower
(
hex
(
randomblob
(
2
))),
lower
(
hex
(
randomblob
(
2
))),
lower
(
hex
(
randomblob
(
6
)))
)
as
uuid
);
\ No newline at end of file
web/src/utils/resource.ts
View file @
6ff7cfdd
export
const
getResourceUrl
=
(
resource
:
Resource
,
withOrigin
=
true
)
=>
{
if
(
resource
.
externalLink
)
{
return
resource
.
externalLink
;
}
return
`
${
withOrigin
?
window
.
location
.
origin
:
""
}
/o/r/
${
resource
.
id
}
/
${
resource
.
publicId
}
`
;
};
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