Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: return external link directly (#1465)
boojack6ff7cfddda66
diff --git a/server/resource.go b/server/resource.goindex 96795048b..da69e132a 100644--- a/server/resource.go+++ b/server/resource.go@@ -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.Blobif resource.InternalPath != "" {src, err := os.Open(resource.InternalPath)diff --git a/server/system.go b/server/system.goindex 0ec1824c1..a047e90c5 100644--- a/server/system.go+++ b/server/system.go@@ -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 anyerr := 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 {diff --git a/store/db/migration/prod/0.12/04__resource_public_id.sql b/store/db/migration/prod/0.12/04__resource_public_id.sqlindex 3d54e5b76..4a30f2cde 100644--- a/store/db/migration/prod/0.12/04__resource_public_id.sql+++ b/store/db/migration/prod/0.12/04__resource_public_id.sql@@ -3,19 +3,17 @@ ALTER TABLEADDCOLUMN 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);UPDATEresourceSET- public_id = (- SELECT- 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+ 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))));\ No newline at end of filediff --git a/web/src/utils/resource.ts b/web/src/utils/resource.tsindex 831fba4c9..1148b77ab 100644--- a/web/src/utils/resource.ts+++ b/web/src/utils/resource.ts@@ -1,3 +1,7 @@export const getResourceUrl = (resource: Resource, withOrigin = true) => {+ if (resource.externalLink) {+ return resource.externalLink;+ }+return `${withOrigin ? window.location.origin : ""}/o/r/${resource.id}/${resource.publicId}`;};