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
chore: fix linter
Johnnyb8a37c7229eb
diff --git a/server/router/api/v1/auth.go b/server/router/api/v1/auth.goindex b07f76361..fca59ee05 100644--- a/server/router/api/v1/auth.go+++ b/server/router/api/v1/auth.go@@ -6,6 +6,7 @@ import ("time""github.com/golang-jwt/jwt/v5"+ "github.com/pkg/errors""github.com/usememos/memos/internal/util")@@ -79,12 +80,12 @@ func BuildSessionCookieValue(userID int32, sessionID string) string {func ParseSessionCookieValue(cookieValue string) (int32, string, error) {parts := strings.SplitN(cookieValue, "-", 2)if len(parts) != 2 {- return 0, "", fmt.Errorf("invalid session cookie format")+ return 0, "", errors.New("invalid session cookie format")}userID, err := util.ConvertStringToInt32(parts[0])if err != nil {- return 0, "", fmt.Errorf("invalid user ID in session cookie: %v", err)+ return 0, "", errors.Errorf("invalid user ID in session cookie: %v", err)}return userID, parts[1], nildiff --git a/server/router/api/v1/auth_service.go b/server/router/api/v1/auth_service.goindex aede7269e..416d02d98 100644--- a/server/router/api/v1/auth_service.go+++ b/server/router/api/v1/auth_service.go@@ -387,7 +387,7 @@ func (s *APIV1Service) trackUserSession(ctx context.Context, userID int32, sessi// - DeviceType: "mobile", "tablet", or "desktop"// - Os: Operating system name and version (e.g., "iOS 17.1", "Windows 10/11")// - Browser: Browser name and version (e.g., "Chrome 120.0.0.0")-// - Country: Geographic location (TODO: implement with GeoIP service)+// - Country: Geographic location (TODO: implement with GeoIP service).func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.SessionsUserSetting_ClientInfo {clientInfo := &storepb.SessionsUserSetting_ClientInfo{}@@ -412,8 +412,8 @@ func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.SessionsUreturn clientInfo}-// parseUserAgent extracts device type, OS, and browser information from user agent string-func (s *APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessionsUserSetting_ClientInfo) {+// parseUserAgent extracts device type, OS, and browser information from user agent string.+func (*APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessionsUserSetting_ClientInfo) {if userAgent == "" {return}@@ -440,7 +440,7 @@ func (s *APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessversionStart := idx + 7versionEnd := strings.Index(userAgent[versionStart:], " ")if versionEnd != -1 {- version := strings.Replace(userAgent[versionStart:versionStart+versionEnd], "_", ".", -1)+ version := strings.ReplaceAll(userAgent[versionStart:versionStart+versionEnd], "_", ".")clientInfo.Os = "iOS " + version} else {clientInfo.Os = "iOS"@@ -449,7 +449,7 @@ func (s *APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessversionStart := idx + 10versionEnd := strings.Index(userAgent[versionStart:], " ")if versionEnd != -1 {- version := strings.Replace(userAgent[versionStart:versionStart+versionEnd], "_", ".", -1)+ version := strings.ReplaceAll(userAgent[versionStart:versionStart+versionEnd], "_", ".")clientInfo.Os = "iOS " + version} else {clientInfo.Os = "iOS"@@ -491,7 +491,7 @@ func (s *APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessversionEnd = strings.Index(userAgent[versionStart:], ")")}if versionEnd != -1 {- version := strings.Replace(userAgent[versionStart:versionStart+versionEnd], "_", ".", -1)+ version := strings.ReplaceAll(userAgent[versionStart:versionStart+versionEnd], "_", ".")clientInfo.Os = "macOS " + version} else {clientInfo.Os = "macOS"diff --git a/server/router/api/v1/auth_service_client_info_test.go b/server/router/api/v1/auth_service_client_info_test.goindex 7f754733f..82429e711 100644--- a/server/router/api/v1/auth_service_client_info_test.go+++ b/server/router/api/v1/auth_service_client_info_test.go@@ -119,7 +119,7 @@ func TestExtractClientInfo(t *testing.T) {}}-// TestClientInfoExamples demonstrates the enhanced client info extraction with various user agents+// TestClientInfoExamples demonstrates the enhanced client info extraction with various user agents.func TestClientInfoExamples(t *testing.T) {service := &APIV1Service{}