mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: retire legacy setting api
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
package v2
|
||||
|
||||
var authenticationAllowlistMethods = map[string]bool{
|
||||
"/memos.api.v2.WorkspaceService/GetWorkspaceProfile": true,
|
||||
"/memos.api.v2.WorkspaceSettingService/GetWorkspaceSetting": true,
|
||||
"/memos.api.v2.AuthService/GetAuthStatus": true,
|
||||
"/memos.api.v2.AuthService/SignIn": true,
|
||||
"/memos.api.v2.AuthService/SignInWithSSO": true,
|
||||
"/memos.api.v2.AuthService/SignOut": true,
|
||||
"/memos.api.v2.AuthService/SignUp": true,
|
||||
"/memos.api.v2.UserService/GetUser": true,
|
||||
"/memos.api.v2.UserService/SearchUsers": true,
|
||||
"/memos.api.v2.MemoService/ListMemos": true,
|
||||
"/memos.api.v2.MemoService/GetMemo": true,
|
||||
"/memos.api.v2.MemoService/SearchMemos": true,
|
||||
"/memos.api.v2.MemoService/ListMemoResources": true,
|
||||
"/memos.api.v2.MemoService/ListMemoRelations": true,
|
||||
"/memos.api.v2.MemoService/ListMemoComments": true,
|
||||
"/memos.api.v2.LinkService/GetLinkMetadata": true,
|
||||
"/memos.api.v2.WorkspaceService/GetWorkspaceProfile": true,
|
||||
"/memos.api.v2.WorkspaceSettingService/GetWorkspaceSetting": true,
|
||||
"/memos.api.v2.WorkspaceSettingService/ListWorkspaceSettings": true,
|
||||
"/memos.api.v2.AuthService/GetAuthStatus": true,
|
||||
"/memos.api.v2.AuthService/SignIn": true,
|
||||
"/memos.api.v2.AuthService/SignInWithSSO": true,
|
||||
"/memos.api.v2.AuthService/SignOut": true,
|
||||
"/memos.api.v2.AuthService/SignUp": true,
|
||||
"/memos.api.v2.UserService/GetUser": true,
|
||||
"/memos.api.v2.UserService/SearchUsers": true,
|
||||
"/memos.api.v2.MemoService/ListMemos": true,
|
||||
"/memos.api.v2.MemoService/GetMemo": true,
|
||||
"/memos.api.v2.MemoService/SearchMemos": true,
|
||||
"/memos.api.v2.MemoService/ListMemoResources": true,
|
||||
"/memos.api.v2.MemoService/ListMemoRelations": true,
|
||||
"/memos.api.v2.MemoService/ListMemoComments": true,
|
||||
"/memos.api.v2.LinkService/GetLinkMetadata": true,
|
||||
}
|
||||
|
||||
// isUnauthorizeAllowedMethod returns whether the method is exempted from authentication.
|
||||
|
@@ -851,6 +851,21 @@ paths:
|
||||
$ref: '#/definitions/googlerpcStatus'
|
||||
tags:
|
||||
- WorkspaceService
|
||||
/api/v2/workspace/settings:
|
||||
get:
|
||||
summary: ListWorkspaceSetting returns the list of settings.
|
||||
operationId: WorkspaceSettingService_ListWorkspaceSettings
|
||||
responses:
|
||||
"200":
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: '#/definitions/v2ListWorkspaceSettingsResponse'
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
$ref: '#/definitions/googlerpcStatus'
|
||||
tags:
|
||||
- WorkspaceSettingService
|
||||
/api/v2/workspace/{name}:
|
||||
get:
|
||||
summary: GetWorkspaceSetting returns the setting by name.
|
||||
@@ -1985,6 +2000,19 @@ definitions:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
apiv2WorkspaceCustomProfile:
|
||||
type: object
|
||||
properties:
|
||||
title:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
logoUrl:
|
||||
type: string
|
||||
locale:
|
||||
type: string
|
||||
appearance:
|
||||
type: string
|
||||
apiv2WorkspaceGeneralSetting:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2003,6 +2031,9 @@ definitions:
|
||||
additionalStyle:
|
||||
type: string
|
||||
description: additional_style is the additional style.
|
||||
customProfile:
|
||||
$ref: '#/definitions/apiv2WorkspaceCustomProfile'
|
||||
description: custom_profile is the custom profile.
|
||||
apiv2WorkspaceMemoRelatedSetting:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2034,6 +2065,10 @@ definitions:
|
||||
storageType:
|
||||
$ref: '#/definitions/apiv2WorkspaceStorageSettingStorageType'
|
||||
description: storage_type is the storage type.
|
||||
activedExternalStorageId:
|
||||
type: integer
|
||||
format: int32
|
||||
description: The id of actived external storage.
|
||||
localStoragePath:
|
||||
type: string
|
||||
title: |-
|
||||
@@ -2418,6 +2453,14 @@ definitions:
|
||||
items:
|
||||
type: object
|
||||
$ref: '#/definitions/apiv2Webhook'
|
||||
v2ListWorkspaceSettingsResponse:
|
||||
type: object
|
||||
properties:
|
||||
settings:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
$ref: '#/definitions/apiv2WorkspaceSetting'
|
||||
v2Memo:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2714,15 +2757,3 @@ definitions:
|
||||
mode:
|
||||
type: string
|
||||
description: mode is the instance mode (e.g. "prod", "dev" or "demo").
|
||||
disallowSignup:
|
||||
type: boolean
|
||||
description: disallow_signup is whether the signup is disallowed.
|
||||
disablePasswordLogin:
|
||||
type: boolean
|
||||
description: disable_password_login is whether the password login is disabled.
|
||||
additionalScript:
|
||||
type: string
|
||||
description: additional_script is the additional script.
|
||||
additionalStyle:
|
||||
type: string
|
||||
description: additional_style is the additional style.
|
||||
|
@@ -25,14 +25,6 @@ func (s *APIV2Service) GetWorkspaceProfile(ctx context.Context, _ *apiv2pb.GetWo
|
||||
if owner != nil {
|
||||
workspaceProfile.Owner = owner.Name
|
||||
}
|
||||
generalSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get workspace general setting: %v", err)
|
||||
}
|
||||
workspaceProfile.DisallowSignup = generalSetting.DisallowSignup
|
||||
workspaceProfile.DisablePasswordLogin = generalSetting.DisallowPasswordLogin
|
||||
workspaceProfile.AdditionalStyle = generalSetting.AdditionalStyle
|
||||
workspaceProfile.AdditionalScript = generalSetting.AdditionalScript
|
||||
return &apiv2pb.GetWorkspaceProfileResponse{
|
||||
WorkspaceProfile: workspaceProfile,
|
||||
}, nil
|
||||
|
@@ -12,6 +12,24 @@ import (
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (s *APIV2Service) ListWorkspaceSettings(ctx context.Context, request *apiv2pb.ListWorkspaceSettingsRequest) (*apiv2pb.ListWorkspaceSettingsResponse, error) {
|
||||
workspaceSettings, err := s.Store.ListWorkspaceSettingsV1(ctx, &store.FindWorkspaceSetting{})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get workspace setting: %v", err)
|
||||
}
|
||||
|
||||
response := &apiv2pb.ListWorkspaceSettingsResponse{
|
||||
Settings: []*apiv2pb.WorkspaceSetting{},
|
||||
}
|
||||
for _, workspaceSetting := range workspaceSettings {
|
||||
if workspaceSetting.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_BASIC {
|
||||
continue
|
||||
}
|
||||
response.Settings = append(response.Settings, convertWorkspaceSettingFromStore(workspaceSetting))
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *APIV2Service) GetWorkspaceSetting(ctx context.Context, request *apiv2pb.GetWorkspaceSettingRequest) (*apiv2pb.GetWorkspaceSettingResponse, error) {
|
||||
settingKeyString, err := ExtractWorkspaceSettingKeyFromName(request.Name)
|
||||
if err != nil {
|
||||
@@ -111,26 +129,46 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
|
||||
if setting == nil {
|
||||
return nil
|
||||
}
|
||||
return &apiv2pb.WorkspaceGeneralSetting{
|
||||
generalSetting := &apiv2pb.WorkspaceGeneralSetting{
|
||||
InstanceUrl: setting.InstanceUrl,
|
||||
DisallowSignup: setting.DisallowSignup,
|
||||
DisallowPasswordLogin: setting.DisallowPasswordLogin,
|
||||
AdditionalScript: setting.AdditionalScript,
|
||||
AdditionalStyle: setting.AdditionalStyle,
|
||||
}
|
||||
if setting.CustomProfile != nil {
|
||||
generalSetting.CustomProfile = &apiv2pb.WorkspaceCustomProfile{
|
||||
Title: setting.CustomProfile.Title,
|
||||
Description: setting.CustomProfile.Description,
|
||||
LogoUrl: setting.CustomProfile.LogoUrl,
|
||||
Locale: setting.CustomProfile.Locale,
|
||||
Appearance: setting.CustomProfile.Appearance,
|
||||
}
|
||||
}
|
||||
return generalSetting
|
||||
}
|
||||
|
||||
func convertWorkspaceGeneralSettingToStore(setting *apiv2pb.WorkspaceGeneralSetting) *storepb.WorkspaceGeneralSetting {
|
||||
if setting == nil {
|
||||
return nil
|
||||
}
|
||||
return &storepb.WorkspaceGeneralSetting{
|
||||
generalSetting := &storepb.WorkspaceGeneralSetting{
|
||||
InstanceUrl: setting.InstanceUrl,
|
||||
DisallowSignup: setting.DisallowSignup,
|
||||
DisallowPasswordLogin: setting.DisallowPasswordLogin,
|
||||
AdditionalScript: setting.AdditionalScript,
|
||||
AdditionalStyle: setting.AdditionalStyle,
|
||||
}
|
||||
if setting.CustomProfile != nil {
|
||||
generalSetting.CustomProfile = &storepb.WorkspaceCustomProfile{
|
||||
Title: setting.CustomProfile.Title,
|
||||
Description: setting.CustomProfile.Description,
|
||||
LogoUrl: setting.CustomProfile.LogoUrl,
|
||||
Locale: setting.CustomProfile.Locale,
|
||||
Appearance: setting.CustomProfile.Appearance,
|
||||
}
|
||||
}
|
||||
return generalSetting
|
||||
}
|
||||
|
||||
func convertWorkspaceStorageSettingFromStore(setting *storepb.WorkspaceStorageSetting) *apiv2pb.WorkspaceStorageSetting {
|
||||
|
Reference in New Issue
Block a user