diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go index 9dc66d5a..551d6aa4 100644 --- a/bin/server/cmd/root.go +++ b/bin/server/cmd/root.go @@ -37,7 +37,7 @@ func (m *Main) Run() error { m.db = db - s := server.NewServer(m.profile.port) + s := server.NewServer(m.profile.port, m.profile.mode) s.ShortcutService = store.NewShortcutService(db) s.MemoService = store.NewMemoService(db) diff --git a/server/server.go b/server/server.go index 1860bba4..43731b74 100644 --- a/server/server.go +++ b/server/server.go @@ -23,7 +23,7 @@ type Server struct { port int } -func NewServer(port int) *Server { +func NewServer(port int, mode string) *Server { e := echo.New() e.Debug = true e.HideBanner = true @@ -46,7 +46,11 @@ func NewServer(port int) *Server { HTML5: true, })) - e.Use(session.Middleware(sessions.NewCookieStore([]byte(securecookie.GenerateRandomKey(16))))) + secret := []byte("justmemos") + if mode != "dev" { + secret = securecookie.GenerateRandomKey(16) + } + e.Use(session.Middleware(sessions.NewCookieStore(secret))) s := &Server{ e: e, diff --git a/server/user.go b/server/user.go index d57b34f1..9a105090 100644 --- a/server/user.go +++ b/server/user.go @@ -11,8 +11,8 @@ import ( ) func (s *Server) registerUserRoutes(g *echo.Group) { + // GET /api/user/me is used to check if the user is logged in. g.GET("/user/me", func(c echo.Context) error { - // /api/user/me is used to check if the user is logged in, userSessionId := c.Get(getUserIdContextKey()) if userSessionId == nil { return echo.NewHTTPError(http.StatusUnauthorized, "Missing session") diff --git a/server/webhook.go b/server/webhook.go index fb944cb8..ff7cd6a0 100644 --- a/server/webhook.go +++ b/server/webhook.go @@ -103,9 +103,8 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) { } c.Response().Writer.WriteHeader(http.StatusOK) - c.Response().Writer.Header().Set("Content-Type", "application/octet-stream") + c.Response().Writer.Header().Set("Content-Type", resource.Type) c.Response().Writer.Write(resource.Blob) - return nil }) } diff --git a/web/src/components/PreferencesSection.tsx b/web/src/components/PreferencesSection.tsx index 03663fa6..f4f1a6fc 100644 --- a/web/src/components/PreferencesSection.tsx +++ b/web/src/components/PreferencesSection.tsx @@ -1,7 +1,6 @@ import { useContext } from "react"; import appContext from "../stores/appContext"; import { globalStateService, memoService } from "../services"; -import { parseHtmlToRawText } from "../helpers/marked"; import { formatMemoContent } from "./Memo"; import "../less/preferences-section.less"; @@ -49,13 +48,6 @@ const PreferencesSection: React.FC = () => { document.body.removeChild(element); }; - const handleFormatMemosBtnClick = async () => { - const memos = memoService.getState().memos; - for (const m of memos) { - memoService.updateMemo(m.id, parseHtmlToRawText(m.content)); - } - }; - return ( <>
@@ -83,9 +75,6 @@ const PreferencesSection: React.FC = () => { -