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
71c39ed5
Commit
71c39ed5
authored
Apr 10, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update workspace setting definition
parent
c93b1efb
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
550 additions
and
101 deletions
+550
-101
README.md
proto/gen/store/README.md
+54
-1
workspace_setting.pb.go
proto/gen/store/workspace_setting.pb.go
+357
-76
workspace_setting.proto
proto/store/workspace_setting.proto
+33
-2
workspace_setting.go
store/db/mysql/workspace_setting.go
+35
-6
workspace_setting.go
store/db/postgres/workspace_setting.go
+35
-6
workspace_setting.go
store/db/sqlite/workspace_setting.go
+36
-10
No files found.
proto/gen/store/README.md
View file @
71c39ed5
...
@@ -40,8 +40,11 @@
...
@@ -40,8 +40,11 @@
-
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
-
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
-
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
-
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
-
[
WorkspaceSetting
](
#memos-store-WorkspaceSetting
)
-
[
WorkspaceSetting
](
#memos-store-WorkspaceSetting
)
-
[
WorkspaceStorageSetting
](
#memos-store-WorkspaceStorageSetting
)
-
[
WorkspaceTelegramIntegrationSetting
](
#memos-store-WorkspaceTelegramIntegrationSetting
)
-
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
-
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
-
[
WorkspaceStorageSetting.StorageType
](
#memos-store-WorkspaceStorageSetting-StorageType
)
-
[
Scalar Value Types
](
#scalar-value-types
)
-
[
Scalar Value Types
](
#scalar-value-types
)
...
@@ -484,7 +487,41 @@
...
@@ -484,7 +487,41 @@
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| key |
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
| | |
| key |
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
| | |
| general_setting |
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
| | |
| general_setting |
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
| | |
| storage_setting |
[
WorkspaceStorageSetting
](
#memos-store-WorkspaceStorageSetting
)
| | |
| memo_related_setting |
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
| | |
| memo_related_setting |
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
| | |
| telegram_integration_setting |
[
WorkspaceTelegramIntegrationSetting
](
#memos-store-WorkspaceTelegramIntegrationSetting
)
| | |
<a
name=
"memos-store-WorkspaceStorageSetting"
></a>
### WorkspaceStorageSetting
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| storage_type |
[
WorkspaceStorageSetting.StorageType
](
#memos-store-WorkspaceStorageSetting-StorageType
)
| | storage_type is the storage type. |
| local_storage_path |
[
string
](
#string
)
| | The local storage path for STORAGE_TYPE_LOCAL. e.g. assets/{timestamp}_{filename} |
| upload_size_limit_mb |
[
int64
](
#int64
)
| | The max upload size in megabytes. |
<a
name=
"memos-store-WorkspaceTelegramIntegrationSetting"
></a>
### WorkspaceTelegramIntegrationSetting
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| telegram_bot_token |
[
string
](
#string
)
| | telegram_bot_token is the telegram bot token. |
...
@@ -502,7 +539,23 @@
...
@@ -502,7 +539,23 @@
| ---- | ------ | ----------- |
| ---- | ------ | ----------- |
| WORKSPACE_SETTING_KEY_UNSPECIFIED | 0 | |
| WORKSPACE_SETTING_KEY_UNSPECIFIED | 0 | |
| WORKSPACE_SETTING_GENERAL | 1 | WORKSPACE_SETTING_GENERAL is the key for general settings. |
| WORKSPACE_SETTING_GENERAL | 1 | WORKSPACE_SETTING_GENERAL is the key for general settings. |
| WORKSPACE_SETTING_MEMO_RELATED | 2 | WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. |
| WORKSPACE_SETTING_STORAGE | 2 | WORKSPACE_SETTING_STORAGE is the key for storage settings. |
| WORKSPACE_SETTING_MEMO_RELATED | 3 | WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. |
| WORKSPACE_SETTING_TELEGRAM_INTEGRATION | 4 | WORKSPACE_SETTING_TELEGRAM_INTEGRATION is the key for telegram integration settings. |
<a
name=
"memos-store-WorkspaceStorageSetting-StorageType"
></a>
### WorkspaceStorageSetting.StorageType
| Name | Number | Description |
| ---- | ------ | ----------- |
| STORAGE_TYPE_UNSPECIFIED | 0 | |
| STORAGE_TYPE_DATABASE | 1 | STORAGE_TYPE_DATABASE is the database storage type. |
| STORAGE_TYPE_LOCAL | 2 | STORAGE_TYPE_LOCAL is the local storage type. |
| STORAGE_TYPE_EXTERNAL | 3 | STORAGE_TYPE_EXTERNAL is the external storage type. |
...
...
proto/gen/store/workspace_setting.pb.go
View file @
71c39ed5
This diff is collapsed.
Click to expand it.
proto/store/workspace_setting.proto
View file @
71c39ed5
...
@@ -8,15 +8,21 @@ enum WorkspaceSettingKey {
...
@@ -8,15 +8,21 @@ enum WorkspaceSettingKey {
WORKSPACE_SETTING_KEY_UNSPECIFIED
=
0
;
WORKSPACE_SETTING_KEY_UNSPECIFIED
=
0
;
// WORKSPACE_SETTING_GENERAL is the key for general settings.
// WORKSPACE_SETTING_GENERAL is the key for general settings.
WORKSPACE_SETTING_GENERAL
=
1
;
WORKSPACE_SETTING_GENERAL
=
1
;
// WORKSPACE_SETTING_STORAGE is the key for storage settings.
WORKSPACE_SETTING_STORAGE
=
2
;
// WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings.
// WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings.
WORKSPACE_SETTING_MEMO_RELATED
=
2
;
WORKSPACE_SETTING_MEMO_RELATED
=
3
;
// WORKSPACE_SETTING_TELEGRAM_INTEGRATION is the key for telegram integration settings.
WORKSPACE_SETTING_TELEGRAM_INTEGRATION
=
4
;
}
}
message
WorkspaceSetting
{
message
WorkspaceSetting
{
WorkspaceSettingKey
key
=
1
;
WorkspaceSettingKey
key
=
1
;
oneof
value
{
oneof
value
{
WorkspaceGeneralSetting
general_setting
=
2
;
WorkspaceGeneralSetting
general_setting
=
2
;
WorkspaceMemoRelatedSetting
memo_related_setting
=
3
;
WorkspaceStorageSetting
storage_setting
=
3
;
WorkspaceMemoRelatedSetting
memo_related_setting
=
4
;
WorkspaceTelegramIntegrationSetting
telegram_integration_setting
=
5
;
}
}
}
}
...
@@ -33,9 +39,34 @@ message WorkspaceGeneralSetting {
...
@@ -33,9 +39,34 @@ message WorkspaceGeneralSetting {
string
additional_style
=
6
;
string
additional_style
=
6
;
}
}
message
WorkspaceStorageSetting
{
// storage_type is the storage type.
StorageType
storage_type
=
1
;
// The local storage path for STORAGE_TYPE_LOCAL.
// e.g. assets/{timestamp}_{filename}
string
local_storage_path
=
2
;
// The max upload size in megabytes.
int64
upload_size_limit_mb
=
3
;
enum
StorageType
{
STORAGE_TYPE_UNSPECIFIED
=
0
;
// STORAGE_TYPE_DATABASE is the database storage type.
STORAGE_TYPE_DATABASE
=
1
;
// STORAGE_TYPE_LOCAL is the local storage type.
STORAGE_TYPE_LOCAL
=
2
;
// STORAGE_TYPE_EXTERNAL is the external storage type.
STORAGE_TYPE_EXTERNAL
=
3
;
}
}
message
WorkspaceMemoRelatedSetting
{
message
WorkspaceMemoRelatedSetting
{
// disallow_public_share disallows set memo as public visible.
// disallow_public_share disallows set memo as public visible.
bool
disallow_public_visible
=
1
;
bool
disallow_public_visible
=
1
;
// display_with_update_time orders and displays memo with update time.
// display_with_update_time orders and displays memo with update time.
bool
display_with_update_time
=
2
;
bool
display_with_update_time
=
2
;
}
}
message
WorkspaceTelegramIntegrationSetting
{
// telegram_bot_token is the telegram bot token.
string
telegram_bot_token
=
1
;
}
store/db/mysql/workspace_setting.go
View file @
71c39ed5
...
@@ -2,8 +2,10 @@ package mysql
...
@@ -2,8 +2,10 @@ package mysql
import
(
import
(
"context"
"context"
"fmt"
"strings"
"strings"
"github.com/pkg/errors"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/protojson"
storepb
"github.com/usememos/memos/proto/gen/store"
storepb
"github.com/usememos/memos/proto/gen/store"
...
@@ -72,14 +74,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -72,14 +74,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
INSERT INTO system_setting (name, value, description)
INSERT INTO system_setting (name, value, description)
VALUES (?, ?, '')
VALUES (?, ?, '')
ON DUPLICATE KEY UPDATE value = ?`
ON DUPLICATE KEY UPDATE value = ?`
var
valueString
string
var
valueBytes
[]
byte
var
err
error
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
if
err
!=
nil
{
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
return
nil
,
err
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetStorageSetting
())
}
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
valueString
=
string
(
valueBytes
)
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetMemoRelatedSetting
())
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetTelegramIntegrationSetting
())
}
else
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"unsupported workspace setting key: %s"
,
upsert
.
Key
.
String
()))
}
}
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to marshal workspace setting value"
)
}
valueString
:=
string
(
valueBytes
)
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
,
valueString
);
err
!=
nil
{
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
,
valueString
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -117,6 +128,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -117,6 +128,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
storageSetting
:=
&
storepb
.
WorkspaceStorageSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
storageSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_StorageSetting
{
StorageSetting
:
storageSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
memoRelatedSetting
:=
&
storepb
.
WorkspaceMemoRelatedSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
memoRelatedSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_MemoRelatedSetting
{
MemoRelatedSetting
:
memoRelatedSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
telegramIntegrationSetting
:=
&
storepb
.
WorkspaceTelegramIntegrationSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
telegramIntegrationSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_TelegramIntegrationSetting
{
TelegramIntegrationSetting
:
telegramIntegrationSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
store/db/postgres/workspace_setting.go
View file @
71c39ed5
...
@@ -2,8 +2,10 @@ package postgres
...
@@ -2,8 +2,10 @@ package postgres
import
(
import
(
"context"
"context"
"fmt"
"strings"
"strings"
"github.com/pkg/errors"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/protojson"
storepb
"github.com/usememos/memos/proto/gen/store"
storepb
"github.com/usememos/memos/proto/gen/store"
...
@@ -82,14 +84,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -82,14 +84,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
VALUES ($1, $2, '')
VALUES ($1, $2, '')
ON CONFLICT(name) DO UPDATE
ON CONFLICT(name) DO UPDATE
SET value = EXCLUDED.value`
SET value = EXCLUDED.value`
var
valueString
string
var
valueBytes
[]
byte
var
err
error
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
if
err
!=
nil
{
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
return
nil
,
err
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetStorageSetting
())
}
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
valueString
=
string
(
valueBytes
)
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetMemoRelatedSetting
())
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetTelegramIntegrationSetting
())
}
else
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"unsupported workspace setting key: %s"
,
upsert
.
Key
.
String
()))
}
}
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to marshal workspace setting value"
)
}
valueString
:=
string
(
valueBytes
)
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
);
err
!=
nil
{
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -127,6 +138,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -127,6 +138,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
storageSetting
:=
&
storepb
.
WorkspaceStorageSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
storageSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_StorageSetting
{
StorageSetting
:
storageSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
memoRelatedSetting
:=
&
storepb
.
WorkspaceMemoRelatedSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
memoRelatedSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_MemoRelatedSetting
{
MemoRelatedSetting
:
memoRelatedSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
telegramIntegrationSetting
:=
&
storepb
.
WorkspaceTelegramIntegrationSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
telegramIntegrationSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_TelegramIntegrationSetting
{
TelegramIntegrationSetting
:
telegramIntegrationSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
store/db/sqlite/workspace_setting.go
View file @
71c39ed5
...
@@ -2,8 +2,10 @@ package sqlite
...
@@ -2,8 +2,10 @@ package sqlite
import
(
import
(
"context"
"context"
"fmt"
"strings"
"strings"
"github.com/pkg/errors"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/protojson"
storepb
"github.com/usememos/memos/proto/gen/store"
storepb
"github.com/usememos/memos/proto/gen/store"
...
@@ -82,14 +84,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -82,14 +84,23 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
VALUES (?, ?)
VALUES (?, ?)
ON CONFLICT(name) DO UPDATE
ON CONFLICT(name) DO UPDATE
SET value = EXCLUDED.value`
SET value = EXCLUDED.value`
var
valueString
string
var
valueBytes
[]
byte
var
err
error
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetGeneralSetting
())
if
err
!=
nil
{
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
return
nil
,
err
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetStorageSetting
())
}
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
valueString
=
string
(
valueBytes
)
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetMemoRelatedSetting
())
}
else
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
valueBytes
,
err
=
protojson
.
Marshal
(
upsert
.
GetTelegramIntegrationSetting
())
}
else
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"unsupported workspace setting key: %s"
,
upsert
.
Key
.
String
()))
}
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to marshal workspace setting value"
)
}
}
valueString
:=
string
(
valueBytes
)
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
);
err
!=
nil
{
if
_
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
upsert
.
Key
.
String
(),
valueString
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -113,10 +124,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -113,10 +124,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
for
rows
.
Next
()
{
for
rows
.
Next
()
{
workspaceSetting
:=
&
storepb
.
WorkspaceSetting
{}
workspaceSetting
:=
&
storepb
.
WorkspaceSetting
{}
var
keyString
,
valueString
string
var
keyString
,
valueString
string
if
err
:=
rows
.
Scan
(
if
err
:=
rows
.
Scan
(
&
keyString
,
&
valueString
);
err
!=
nil
{
&
keyString
,
&
valueString
,
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Key
=
storepb
.
WorkspaceSettingKey
(
storepb
.
WorkspaceSettingKey_value
[
keyString
])
workspaceSetting
.
Key
=
storepb
.
WorkspaceSettingKey
(
storepb
.
WorkspaceSettingKey_value
[
keyString
])
...
@@ -126,6 +134,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -126,6 +134,24 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
generalSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE
{
storageSetting
:=
&
storepb
.
WorkspaceStorageSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
storageSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_StorageSetting
{
StorageSetting
:
storageSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED
{
memoRelatedSetting
:=
&
storepb
.
WorkspaceMemoRelatedSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
memoRelatedSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_MemoRelatedSetting
{
MemoRelatedSetting
:
memoRelatedSetting
}
}
else
if
workspaceSetting
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION
{
telegramIntegrationSetting
:=
&
storepb
.
WorkspaceTelegramIntegrationSetting
{}
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
telegramIntegrationSetting
);
err
!=
nil
{
return
nil
,
err
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_TelegramIntegrationSetting
{
TelegramIntegrationSetting
:
telegramIntegrationSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
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