chore: add memo content length limit setting

This commit is contained in:
Steven
2024-05-06 08:02:39 +08:00
parent 56ceba2dec
commit af1ad2f2db
9 changed files with 171 additions and 96 deletions

View File

@@ -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
}