Skip to content

armgit / memos

Public Imported from GitHub
0

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.

chore: update version to `0.9.1` (#882)

boojack24b21aa9d75d
diff --git a/server/memo.go b/server/memo.go
index d22f398a4..e00b27a37 100644
--- a/server/memo.go
+++ b/server/memo.go
@@ -315,19 +315,14 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)
}
- currentTs := time.Now().Unix()
- memoResourceUpsert := &api.MemoResourceUpsert{
- UpdatedTs: &currentTs,
+ userID, ok := c.Get(getUserIDContextKey()).(int)
+ if !ok {
+ return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")
}
+ memoResourceUpsert := &api.MemoResourceUpsert{}
if err := json.NewDecoder(c.Request().Body).Decode(memoResourceUpsert); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post memo resource request").SetInternal(err)
}
- memoResourceUpsert.MemoID = memoID
-
- if _, err := s.Store.UpsertMemoResource(ctx, memoResourceUpsert); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to upsert memo resource").SetInternal(err)
- }
-
resourceFind := &api.ResourceFind{
ID: &memoResourceUpsert.ResourceID,
}
@@ -335,6 +330,18 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch resource").SetInternal(err)
}
+ if resource == nil {
+ return echo.NewHTTPError(http.StatusBadRequest, "Resource not found").SetInternal(err)
+ } else if resource.CreatorID != userID {
+ return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized to bind this resource").SetInternal(err)
+ }
+
+ memoResourceUpsert.MemoID = memoID
+ currentTs := time.Now().Unix()
+ memoResourceUpsert.UpdatedTs = &currentTs
+ if _, err := s.Store.UpsertMemoResource(ctx, memoResourceUpsert); err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to upsert memo resource").SetInternal(err)
+ }
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(resource)); err != nil {
diff --git a/server/server.go b/server/server.go
index 5e57ea8a2..b66e51982 100644
--- a/server/server.go
+++ b/server/server.go
@@ -42,6 +42,8 @@ func NewServer(profile *profile.Profile) *Server {
e.Use(middleware.CORS())
+ e.Use(middleware.Secure())
+
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
Skipper: middleware.DefaultSkipper,
ErrorMessage: "Request timeout",
diff --git a/server/version/version.go b/server/version/version.go
index ee5a0da2e..6f83fda9e 100644
--- a/server/version/version.go
+++ b/server/version/version.go
@@ -7,10 +7,10 @@ import (
// Version is the service current released version.
// Semantic versioning: https://semver.org/
-var Version = "0.9.0"
+var Version = "0.9.1"
// DevVersion is the service current development version.
-var DevVersion = "0.9.0"
+var DevVersion = "0.9.1"
func GetCurrentVersion(mode string) string {
if mode == "dev" {
diff --git a/web/src/components/AboutSiteDialog.tsx b/web/src/components/AboutSiteDialog.tsx
index 1636351f2..3c171edf3 100644
--- a/web/src/components/AboutSiteDialog.tsx
+++ b/web/src/components/AboutSiteDialog.tsx
@@ -11,6 +11,7 @@ const AboutSiteDialog: React.FC<Props> = ({ destroy }: Props) => {
const { t } = useTranslation();
const globalStore = useGlobalStore();
const profile = globalStore.state.systemStatus.profile;
+ const customizedProfile = globalStore.state.systemStatus.customizedProfile;
const handleCloseBtnClick = () => {
destroy();
@@ -20,36 +21,36 @@ const AboutSiteDialog: React.FC<Props> = ({ destroy }: Props) => {
<>
<div className="dialog-header-container">
<p className="title-text flex items-center">
- <img className="w-7 h-auto mr-1" src="/logo.png" alt="" />
- {t("common.about")} memos
+ {t("common.about")} {customizedProfile.name}
</p>
<button className="btn close-btn" onClick={handleCloseBtnClick}>
<Icon.X />
</button>
</div>
<div className="dialog-content-container">
- <p>{t("slogan")}</p>
- <div className="border-t mt-1 pt-2 flex flex-row justify-start items-center">
- <span className=" text-gray-500 mr-2">Other projects:</span>
+ <p className="text-sm">{customizedProfile.description || "No description"}</p>
+ <div className="mt-4 flex flex-row text-sm justify-start items-center">
+ <div className="flex flex-row justify-start items-center mr-2">
+ Powered by
+ <a href="https://usememos.com" className="flex flex-row justify-start items-center mr-1 hover:underline">
+ <img className="w-6 h-auto" src="/logo.png" alt="" />
+ memos
+ </a>
+ <span>v{profile.version}</span>
+ </div>
+ <GitHubBadge />
+ </div>
+ <div className="border-t mt-3 pt-2 text-sm flex flex-row justify-start items-center">
+ <span className="text-gray-500 mr-2">Other projects:</span>
<a href="https://github.com/boojack/sticky-notes" className="flex items-center underline text-blue-600 hover:opacity-80">
<img
- className="w-5 h-auto mr-1"
+ className="w-4 h-auto mr-1"
src="https://raw.githubusercontent.com/boojack/sticky-notes/main/public/sticky-notes.ico"
alt=""
/>
<span>Sticky notes</span>
</a>
</div>
- <div className="mt-4 flex flex-row text-sm justify-start items-center">
- <GitHubBadge />
- <span className="ml-2">
- {t("common.version")}:
- <span className="font-mono">
- {profile.version}-{profile.mode}
- </span>
- πŸŽ‰
- </span>
- </div>
</div>
</>
);
diff --git a/web/src/components/Sidebar.tsx b/web/src/components/Sidebar.tsx
index 8ffdf58f0..30fb2f94f 100644
--- a/web/src/components/Sidebar.tsx
+++ b/web/src/components/Sidebar.tsx
@@ -35,11 +35,11 @@ const Sidebar = () => {
<button className="btn action-btn" onClick={() => showDailyReviewDialog()}>
<span className="icon">πŸ“…</span> {t("sidebar.daily-review")}
</button>
+ <Link to="/explore" className="btn action-btn">
+ <span className="icon">πŸ‚</span> {t("common.explore")}
+ </Link>
{!userStore.isVisitorMode() && (
<>
- <Link to="/explore" className="btn action-btn">
- <span className="icon">πŸ‚</span> {t("common.explore")}
- </Link>
<button className="btn action-btn" onClick={handleSettingBtnClick}>
<span className="icon">βš™οΈ</span> {t("sidebar.setting")}
</button>