Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
af1ad2f2
Commit
af1ad2f2
authored
May 06, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add memo content length limit setting
parent
56ceba2d
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
171 additions
and
96 deletions
+171
-96
apidocs.swagger.yaml
docs/apidocs.swagger.yaml
+4
-0
workspace_setting_service.proto
proto/api/v1/workspace_setting_service.proto
+2
-0
workspace_setting_service.pb.go
proto/gen/api/v1/workspace_setting_service.pb.go
+72
-60
workspace_setting.pb.go
proto/gen/store/workspace_setting.pb.go
+36
-24
workspace_setting.proto
proto/store/workspace_setting.proto
+2
-0
memo_service.go
server/router/api/v1/memo_service.go
+22
-8
workspace_setting_service.go
server/router/api/v1/workspace_setting_service.go
+2
-0
workspace_setting.go
store/workspace_setting.go
+8
-0
WorkspaceSection.tsx
web/src/components/Settings/WorkspaceSection.tsx
+23
-4
No files found.
docs/apidocs.swagger.yaml
View file @
af1ad2f2
...
...
@@ -2096,6 +2096,10 @@ definitions:
displayWithUpdateTime
:
type
:
boolean
description
:
display_with_update_time orders and displays memo with update time.
contentLengthLimit
:
type
:
string
format
:
int64
description
:
content_length_limit is the limit of content length.
apiv1WorkspaceSetting
:
type
:
object
properties
:
...
...
proto/api/v1/workspace_setting_service.proto
View file @
af1ad2f2
...
...
@@ -96,6 +96,8 @@ message WorkspaceMemoRelatedSetting {
bool
disallow_public_visible
=
1
;
// display_with_update_time orders and displays memo with update time.
bool
display_with_update_time
=
2
;
// content_length_limit is the limit of content length.
int64
content_length_limit
=
3
;
}
message
ListWorkspaceSettingsRequest
{}
...
...
proto/gen/api/v1/workspace_setting_service.pb.go
View file @
af1ad2f2
This diff is collapsed.
Click to expand it.
proto/gen/store/workspace_setting.pb.go
View file @
af1ad2f2
...
...
@@ -555,6 +555,8 @@ type WorkspaceMemoRelatedSetting struct {
DisallowPublicVisible
bool
`protobuf:"varint,1,opt,name=disallow_public_visible,json=disallowPublicVisible,proto3" json:"disallow_public_visible,omitempty"`
// display_with_update_time orders and displays memo with update time.
DisplayWithUpdateTime
bool
`protobuf:"varint,2,opt,name=display_with_update_time,json=displayWithUpdateTime,proto3" json:"display_with_update_time,omitempty"`
// content_length_limit is the limit of content length.
ContentLengthLimit
int64
`protobuf:"varint,3,opt,name=content_length_limit,json=contentLengthLimit,proto3" json:"content_length_limit,omitempty"`
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
Reset
()
{
...
...
@@ -603,6 +605,13 @@ func (x *WorkspaceMemoRelatedSetting) GetDisplayWithUpdateTime() bool {
return
false
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
GetContentLengthLimit
()
int64
{
if
x
!=
nil
{
return
x
.
ContentLengthLimit
}
return
0
}
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
type
WorkspaceStorageSetting_S3Config
struct
{
state
protoimpl
.
MessageState
...
...
@@ -784,7 +793,7 @@ var file_store_workspace_setting_proto_rawDesc = []byte{
0x41
,
0x42
,
0x41
,
0x53
,
0x45
,
0x10
,
0x01
,
0x12
,
0x16
,
0x0a
,
0x12
,
0x53
,
0x54
,
0x4f
,
0x52
,
0x41
,
0x47
,
0x45
,
0x5f
,
0x54
,
0x59
,
0x50
,
0x45
,
0x5f
,
0x4c
,
0x4f
,
0x43
,
0x41
,
0x4c
,
0x10
,
0x02
,
0x12
,
0x13
,
0x0a
,
0x0f
,
0x53
,
0x54
,
0x4f
,
0x52
,
0x41
,
0x47
,
0x45
,
0x5f
,
0x54
,
0x59
,
0x50
,
0x45
,
0x5f
,
0x53
,
0x33
,
0x10
,
0x03
,
0x22
,
0x
8e
,
0x01
,
0x0a
,
0x1b
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x53
,
0x33
,
0x10
,
0x03
,
0x22
,
0x
c0
,
0x01
,
0x0a
,
0x1b
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x52
,
0x65
,
0x6c
,
0x61
,
0x74
,
0x65
,
0x64
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x12
,
0x36
,
0x0a
,
0x17
,
0x64
,
0x69
,
0x73
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x77
,
0x5f
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x5f
,
0x76
,
0x69
,
0x73
,
0x69
,
0x62
,
0x6c
,
0x65
,
0x18
,
...
...
@@ -793,29 +802,32 @@ var file_store_workspace_setting_proto_rawDesc = []byte{
0x64
,
0x69
,
0x73
,
0x70
,
0x6c
,
0x61
,
0x79
,
0x5f
,
0x77
,
0x69
,
0x74
,
0x68
,
0x5f
,
0x75
,
0x70
,
0x64
,
0x61
,
0x74
,
0x65
,
0x5f
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x15
,
0x64
,
0x69
,
0x73
,
0x70
,
0x6c
,
0x61
,
0x79
,
0x57
,
0x69
,
0x74
,
0x68
,
0x55
,
0x70
,
0x64
,
0x61
,
0x74
,
0x65
,
0x54
,
0x69
,
0x6d
,
0x65
,
0x2a
,
0xbb
,
0x01
,
0x0a
,
0x13
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x4b
,
0x65
,
0x79
,
0x12
,
0x25
,
0x0a
,
0x21
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x4b
,
0x45
,
0x59
,
0x5f
,
0x55
,
0x4e
,
0x53
,
0x50
,
0x45
,
0x43
,
0x49
,
0x46
,
0x49
,
0x45
,
0x44
,
0x10
,
0x00
,
0x12
,
0x1b
,
0x0a
,
0x17
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x42
,
0x41
,
0x53
,
0x49
,
0x43
,
0x10
,
0x01
,
0x12
,
0x1d
,
0x0a
,
0x19
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x47
,
0x45
,
0x4e
,
0x45
,
0x52
,
0x41
,
0x4c
,
0x10
,
0x02
,
0x12
,
0x1d
,
0x0a
,
0x19
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x53
,
0x54
,
0x4f
,
0x52
,
0x41
,
0x47
,
0x45
,
0x10
,
0x03
,
0x12
,
0x22
,
0x0a
,
0x1e
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x4d
,
0x45
,
0x4d
,
0x4f
,
0x5f
,
0x52
,
0x45
,
0x4c
,
0x41
,
0x54
,
0x45
,
0x44
,
0x10
,
0x04
,
0x42
,
0xa0
,
0x01
,
0x0a
,
0x0f
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x42
,
0x15
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x29
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x53
,
0x58
,
0xaa
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xca
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xe2
,
0x02
,
0x17
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
0x65
,
0x54
,
0x69
,
0x6d
,
0x65
,
0x12
,
0x30
,
0x0a
,
0x14
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x5f
,
0x6c
,
0x65
,
0x6e
,
0x67
,
0x74
,
0x68
,
0x5f
,
0x6c
,
0x69
,
0x6d
,
0x69
,
0x74
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x03
,
0x52
,
0x12
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x4c
,
0x65
,
0x6e
,
0x67
,
0x74
,
0x68
,
0x4c
,
0x69
,
0x6d
,
0x69
,
0x74
,
0x2a
,
0xbb
,
0x01
,
0x0a
,
0x13
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x4b
,
0x65
,
0x79
,
0x12
,
0x25
,
0x0a
,
0x21
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x4b
,
0x45
,
0x59
,
0x5f
,
0x55
,
0x4e
,
0x53
,
0x50
,
0x45
,
0x43
,
0x49
,
0x46
,
0x49
,
0x45
,
0x44
,
0x10
,
0x00
,
0x12
,
0x1b
,
0x0a
,
0x17
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x42
,
0x41
,
0x53
,
0x49
,
0x43
,
0x10
,
0x01
,
0x12
,
0x1d
,
0x0a
,
0x19
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x47
,
0x45
,
0x4e
,
0x45
,
0x52
,
0x41
,
0x4c
,
0x10
,
0x02
,
0x12
,
0x1d
,
0x0a
,
0x19
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x53
,
0x54
,
0x4f
,
0x52
,
0x41
,
0x47
,
0x45
,
0x10
,
0x03
,
0x12
,
0x22
,
0x0a
,
0x1e
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x4d
,
0x45
,
0x4d
,
0x4f
,
0x5f
,
0x52
,
0x45
,
0x4c
,
0x41
,
0x54
,
0x45
,
0x44
,
0x10
,
0x04
,
0x42
,
0xa0
,
0x01
,
0x0a
,
0x0f
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x42
,
0x15
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x29
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x53
,
0x58
,
0xaa
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xca
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xe2
,
0x02
,
0x17
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
(
...
...
proto/store/workspace_setting.proto
View file @
af1ad2f2
...
...
@@ -87,4 +87,6 @@ message WorkspaceMemoRelatedSetting {
bool
disallow_public_visible
=
1
;
// display_with_update_time orders and displays memo with update time.
bool
display_with_update_time
=
2
;
// content_length_limit is the limit of content length.
int64
content_length_limit
=
3
;
}
server/router/api/v1/memo_service.go
View file @
af1ad2f2
...
...
@@ -28,8 +28,6 @@ import (
const
(
DefaultPageSize
=
10
MaxContentLength
=
8
*
1024
ChunkSize
=
64
*
1024
// 64 KiB
)
func
(
s
*
APIV1Service
)
CreateMemo
(
ctx
context
.
Context
,
request
*
v1pb
.
CreateMemoRequest
)
(
*
v1pb
.
Memo
,
error
)
{
...
...
@@ -40,9 +38,6 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
if
user
==
nil
{
return
nil
,
status
.
Errorf
(
codes
.
PermissionDenied
,
"permission denied"
)
}
if
len
(
request
.
Content
)
>
MaxContentLength
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"content too long"
)
}
create
:=
&
store
.
Memo
{
UID
:
shortuuid
.
New
(),
...
...
@@ -57,6 +52,13 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
if
workspaceMemoRelatedSetting
.
DisallowPublicVisible
&&
create
.
Visibility
==
store
.
Public
{
return
nil
,
status
.
Errorf
(
codes
.
PermissionDenied
,
"disable public memos system setting is enabled"
)
}
contentLengthLimit
,
err
:=
s
.
getContentLengthLimit
(
ctx
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to get content length limit"
)
}
if
len
(
create
.
Content
)
>
contentLengthLimit
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"content too long (max %d characters)"
,
contentLengthLimit
)
}
memo
,
err
:=
s
.
Store
.
CreateMemo
(
ctx
,
create
)
if
err
!=
nil
{
...
...
@@ -257,8 +259,12 @@ func (s *APIV1Service) UpdateMemo(ctx context.Context, request *v1pb.UpdateMemoR
}
}
}
if
update
.
Content
!=
nil
&&
len
(
*
update
.
Content
)
>
MaxContentLength
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"content too long"
)
contentLengthLimit
,
err
:=
s
.
getContentLengthLimit
(
ctx
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to get content length limit"
)
}
if
update
.
Content
!=
nil
&&
len
(
*
update
.
Content
)
>
contentLengthLimit
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"content too long (max %d characters)"
,
contentLengthLimit
)
}
if
err
=
s
.
Store
.
UpdateMemo
(
ctx
,
update
);
err
!=
nil
{
...
...
@@ -702,6 +708,14 @@ func (s *APIV1Service) buildMemoFindWithFilter(ctx context.Context, find *store.
return
nil
}
func
(
s
*
APIV1Service
)
getContentLengthLimit
(
ctx
context
.
Context
)
(
int
,
error
)
{
workspaceMemoRelatedSetting
,
err
:=
s
.
Store
.
GetWorkspaceMemoRelatedSetting
(
ctx
)
if
err
!=
nil
{
return
0
,
status
.
Errorf
(
codes
.
Internal
,
"failed to get workspace memo related setting"
)
}
return
int
(
workspaceMemoRelatedSetting
.
ContentLengthLimit
),
nil
}
// SearchMemosFilterCELAttributes are the CEL attributes.
var
SearchMemosFilterCELAttributes
=
[]
cel
.
EnvOption
{
cel
.
Variable
(
"content_search"
,
cel
.
ListType
(
cel
.
StringType
)),
...
...
server/router/api/v1/workspace_setting_service.go
View file @
af1ad2f2
...
...
@@ -211,6 +211,7 @@ func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoR
return
&
v1pb
.
WorkspaceMemoRelatedSetting
{
DisallowPublicVisible
:
setting
.
DisallowPublicVisible
,
DisplayWithUpdateTime
:
setting
.
DisplayWithUpdateTime
,
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
}
}
...
...
@@ -221,5 +222,6 @@ func convertWorkspaceMemoRelatedSettingToStore(setting *v1pb.WorkspaceMemoRelate
return
&
storepb
.
WorkspaceMemoRelatedSetting
{
DisallowPublicVisible
:
setting
.
DisallowPublicVisible
,
DisplayWithUpdateTime
:
setting
.
DisplayWithUpdateTime
,
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
}
}
store/workspace_setting.go
View file @
af1ad2f2
...
...
@@ -123,6 +123,11 @@ func (s *Store) GetWorkspaceGeneralSetting(ctx context.Context) (*storepb.Worksp
return
workspaceGeneralSetting
,
nil
}
const
(
// DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.
DefaultContentLengthLimit
=
8
*
1024
)
func
(
s
*
Store
)
GetWorkspaceMemoRelatedSetting
(
ctx
context
.
Context
)
(
*
storepb
.
WorkspaceMemoRelatedSetting
,
error
)
{
workspaceSetting
,
err
:=
s
.
GetWorkspaceSetting
(
ctx
,
&
FindWorkspaceSetting
{
Name
:
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
.
String
(),
...
...
@@ -135,6 +140,9 @@ func (s *Store) GetWorkspaceMemoRelatedSetting(ctx context.Context) (*storepb.Wo
if
workspaceSetting
!=
nil
{
workspaceMemoRelatedSetting
=
workspaceSetting
.
GetMemoRelatedSetting
()
}
if
workspaceMemoRelatedSetting
.
ContentLengthLimit
<
DefaultContentLengthLimit
{
workspaceMemoRelatedSetting
.
ContentLengthLimit
=
DefaultContentLengthLimit
}
return
workspaceMemoRelatedSetting
,
nil
}
...
...
web/src/components/Settings/WorkspaceSection.tsx
View file @
af1ad2f2
...
...
@@ -144,6 +144,20 @@ const WorkspaceSection = () => {
});
};
const
handleMemoContentLengthLimitChanges
=
async
(
value
:
number
)
=>
{
if
(
value
<
8
*
1024
)
{
toast
.
error
(
"Content length limit should be greater than 8KB"
);
return
;
}
const
update
:
WorkspaceMemoRelatedSetting
=
{
...
workspaceMemoRelatedSetting
,
contentLengthLimit
:
value
};
setWorkspaceMemoRelatedSetting
(
update
);
await
workspaceSettingStore
.
setWorkspaceSetting
({
name
:
`
${
WorkspaceSettingPrefix
}${
WorkspaceSettingKey
.
WORKSPACE_SETTING_MEMO_RELATED
}
`
,
memoRelatedSetting
:
update
,
});
};
return
(
<
div
className=
"w-full flex flex-col gap-2 pt-2 pb-4"
>
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
{
t
(
"common.basic"
)
}
</
p
>
...
...
@@ -179,10 +193,6 @@ const WorkspaceSection = () => {
</
div
>
<
Input
className=
"w-full"
sx=
{
{
fontFamily
:
"monospace"
,
fontSize
:
"14px"
,
}
}
placeholder=
{
"Should be started with http:// or https://"
}
value=
{
workspaceGeneralSetting
.
instanceUrl
}
onChange=
{
(
event
)
=>
handleInstanceUrlChanged
(
event
.
target
.
value
)
}
...
...
@@ -263,6 +273,15 @@ const WorkspaceSection = () => {
onChange=
{
(
event
)
=>
handleMemoDisplayWithUpdatedTs
(
event
.
target
.
checked
)
}
/>
</
div
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
>
Content length limit(Byte)
</
span
>
<
Input
className=
"w-32"
type=
"number"
defaultValue=
{
workspaceMemoRelatedSetting
.
contentLengthLimit
}
onBlur=
{
(
event
)
=>
handleMemoContentLengthLimitChanges
(
Number
(
event
.
target
.
value
))
}
/>
</
div
>
</
div
>
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment