mirror of https://github.com/usememos/memos
refactor: rename workspace to instance throughout codebase
Remove work-related terminology by renaming "workspace" to "instance" across the entire application. This change better reflects that Memos is a self-hosted tool suitable for personal and non-work use cases. Breaking Changes: - API endpoints: /api/v1/workspace/* → /api/v1/instance/* - gRPC service: WorkspaceService → InstanceService - Proto types: WorkspaceSetting → InstanceSetting - Frontend translation keys: workspace-section → instance-section Backend Changes: - Renamed proto definitions and regenerated code - Updated all store layer methods and database drivers - Renamed service implementations and API handlers - Updated cache from workspaceSettingCache to instanceSettingCache Frontend Changes: - Renamed service client: workspaceServiceClient → instanceServiceClient - Updated all React components and state management - Refactored stores: workspace.ts → instance.ts - Updated all 32 locale translation files All tests pass and both backend and frontend build successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>pull/5229/head
parent
d98ee36178
commit
4c1d1c70d1
@ -1,617 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc (unknown)
|
||||
// source: api/v1/inbox_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Status enumeration for inbox notifications.
|
||||
type Inbox_Status int32
|
||||
|
||||
const (
|
||||
// Unspecified status.
|
||||
Inbox_STATUS_UNSPECIFIED Inbox_Status = 0
|
||||
// The notification is unread.
|
||||
Inbox_UNREAD Inbox_Status = 1
|
||||
// The notification is archived.
|
||||
Inbox_ARCHIVED Inbox_Status = 2
|
||||
)
|
||||
|
||||
// Enum value maps for Inbox_Status.
|
||||
var (
|
||||
Inbox_Status_name = map[int32]string{
|
||||
0: "STATUS_UNSPECIFIED",
|
||||
1: "UNREAD",
|
||||
2: "ARCHIVED",
|
||||
}
|
||||
Inbox_Status_value = map[string]int32{
|
||||
"STATUS_UNSPECIFIED": 0,
|
||||
"UNREAD": 1,
|
||||
"ARCHIVED": 2,
|
||||
}
|
||||
)
|
||||
|
||||
func (x Inbox_Status) Enum() *Inbox_Status {
|
||||
p := new(Inbox_Status)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x Inbox_Status) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (Inbox_Status) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_v1_inbox_service_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (Inbox_Status) Type() protoreflect.EnumType {
|
||||
return &file_api_v1_inbox_service_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x Inbox_Status) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Inbox_Status.Descriptor instead.
|
||||
func (Inbox_Status) EnumDescriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
// Type enumeration for inbox notifications.
|
||||
type Inbox_Type int32
|
||||
|
||||
const (
|
||||
// Unspecified type.
|
||||
Inbox_TYPE_UNSPECIFIED Inbox_Type = 0
|
||||
// Memo comment notification.
|
||||
Inbox_MEMO_COMMENT Inbox_Type = 1
|
||||
)
|
||||
|
||||
// Enum value maps for Inbox_Type.
|
||||
var (
|
||||
Inbox_Type_name = map[int32]string{
|
||||
0: "TYPE_UNSPECIFIED",
|
||||
1: "MEMO_COMMENT",
|
||||
}
|
||||
Inbox_Type_value = map[string]int32{
|
||||
"TYPE_UNSPECIFIED": 0,
|
||||
"MEMO_COMMENT": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x Inbox_Type) Enum() *Inbox_Type {
|
||||
p := new(Inbox_Type)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x Inbox_Type) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (Inbox_Type) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_v1_inbox_service_proto_enumTypes[1].Descriptor()
|
||||
}
|
||||
|
||||
func (Inbox_Type) Type() protoreflect.EnumType {
|
||||
return &file_api_v1_inbox_service_proto_enumTypes[1]
|
||||
}
|
||||
|
||||
func (x Inbox_Type) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Inbox_Type.Descriptor instead.
|
||||
func (Inbox_Type) EnumDescriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{0, 1}
|
||||
}
|
||||
|
||||
type Inbox struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The resource name of the inbox.
|
||||
// Format: inboxes/{inbox}
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// The sender of the inbox notification.
|
||||
// Format: users/{user}
|
||||
Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
|
||||
// The receiver of the inbox notification.
|
||||
// Format: users/{user}
|
||||
Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"`
|
||||
// The status of the inbox notification.
|
||||
Status Inbox_Status `protobuf:"varint,4,opt,name=status,proto3,enum=memos.api.v1.Inbox_Status" json:"status,omitempty"`
|
||||
// Output only. The creation timestamp.
|
||||
CreateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
|
||||
// The type of the inbox notification.
|
||||
Type Inbox_Type `protobuf:"varint,6,opt,name=type,proto3,enum=memos.api.v1.Inbox_Type" json:"type,omitempty"`
|
||||
// Optional. The activity ID associated with this inbox notification.
|
||||
ActivityId *int32 `protobuf:"varint,7,opt,name=activity_id,json=activityId,proto3,oneof" json:"activity_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Inbox) Reset() {
|
||||
*x = Inbox{}
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Inbox) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Inbox) ProtoMessage() {}
|
||||
|
||||
func (x *Inbox) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Inbox.ProtoReflect.Descriptor instead.
|
||||
func (*Inbox) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Inbox) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Inbox) GetSender() string {
|
||||
if x != nil {
|
||||
return x.Sender
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Inbox) GetReceiver() string {
|
||||
if x != nil {
|
||||
return x.Receiver
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Inbox) GetStatus() Inbox_Status {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return Inbox_STATUS_UNSPECIFIED
|
||||
}
|
||||
|
||||
func (x *Inbox) GetCreateTime() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.CreateTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Inbox) GetType() Inbox_Type {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return Inbox_TYPE_UNSPECIFIED
|
||||
}
|
||||
|
||||
func (x *Inbox) GetActivityId() int32 {
|
||||
if x != nil && x.ActivityId != nil {
|
||||
return *x.ActivityId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ListInboxesRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The parent resource whose inboxes will be listed.
|
||||
// Format: users/{user}
|
||||
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
|
||||
// Optional. The maximum number of inboxes to return.
|
||||
// The service may return fewer than this value.
|
||||
// If unspecified, at most 50 inboxes will be returned.
|
||||
// The maximum value is 1000; values above 1000 will be coerced to 1000.
|
||||
PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
|
||||
// Optional. A page token, received from a previous `ListInboxes` call.
|
||||
// Provide this to retrieve the subsequent page.
|
||||
PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`
|
||||
// Optional. Filter to apply to the list results.
|
||||
// Example: "status=UNREAD" or "type=MEMO_COMMENT"
|
||||
// Supported operators: =, !=
|
||||
// Supported fields: status, type, sender, create_time
|
||||
Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
// Optional. The order to sort results by.
|
||||
// Example: "create_time desc" or "status asc"
|
||||
OrderBy string `protobuf:"bytes,5,opt,name=order_by,json=orderBy,proto3" json:"order_by,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) Reset() {
|
||||
*x = ListInboxesRequest{}
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListInboxesRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListInboxesRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListInboxesRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListInboxesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) GetParent() string {
|
||||
if x != nil {
|
||||
return x.Parent
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) GetPageSize() int32 {
|
||||
if x != nil {
|
||||
return x.PageSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) GetPageToken() string {
|
||||
if x != nil {
|
||||
return x.PageToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) GetFilter() string {
|
||||
if x != nil {
|
||||
return x.Filter
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListInboxesRequest) GetOrderBy() string {
|
||||
if x != nil {
|
||||
return x.OrderBy
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListInboxesResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The list of inboxes.
|
||||
Inboxes []*Inbox `protobuf:"bytes,1,rep,name=inboxes,proto3" json:"inboxes,omitempty"`
|
||||
// A token that can be sent as `page_token` to retrieve the next page.
|
||||
// If this field is omitted, there are no subsequent pages.
|
||||
NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"`
|
||||
// The total count of inboxes (may be approximate).
|
||||
TotalSize int32 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListInboxesResponse) Reset() {
|
||||
*x = ListInboxesResponse{}
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListInboxesResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListInboxesResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListInboxesResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListInboxesResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListInboxesResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListInboxesResponse) GetInboxes() []*Inbox {
|
||||
if x != nil {
|
||||
return x.Inboxes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ListInboxesResponse) GetNextPageToken() string {
|
||||
if x != nil {
|
||||
return x.NextPageToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListInboxesResponse) GetTotalSize() int32 {
|
||||
if x != nil {
|
||||
return x.TotalSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type UpdateInboxRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The inbox to update.
|
||||
Inbox *Inbox `protobuf:"bytes,1,opt,name=inbox,proto3" json:"inbox,omitempty"`
|
||||
// Required. The list of fields to update.
|
||||
UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
|
||||
// Optional. If set to true, allows updating missing fields.
|
||||
AllowMissing bool `protobuf:"varint,3,opt,name=allow_missing,json=allowMissing,proto3" json:"allow_missing,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateInboxRequest) Reset() {
|
||||
*x = UpdateInboxRequest{}
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateInboxRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateInboxRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateInboxRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateInboxRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateInboxRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *UpdateInboxRequest) GetInbox() *Inbox {
|
||||
if x != nil {
|
||||
return x.Inbox
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UpdateInboxRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
|
||||
if x != nil {
|
||||
return x.UpdateMask
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UpdateInboxRequest) GetAllowMissing() bool {
|
||||
if x != nil {
|
||||
return x.AllowMissing
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type DeleteInboxRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The resource name of the inbox to delete.
|
||||
// Format: inboxes/{inbox}
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteInboxRequest) Reset() {
|
||||
*x = DeleteInboxRequest{}
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteInboxRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteInboxRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteInboxRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_inbox_service_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteInboxRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteInboxRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_inbox_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *DeleteInboxRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_api_v1_inbox_service_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_inbox_service_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1aapi/v1/inbox_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xf3\x03\n" +
|
||||
"\x05Inbox\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12\x1b\n" +
|
||||
"\x06sender\x18\x02 \x01(\tB\x03\xe0A\x03R\x06sender\x12\x1f\n" +
|
||||
"\breceiver\x18\x03 \x01(\tB\x03\xe0A\x03R\breceiver\x127\n" +
|
||||
"\x06status\x18\x04 \x01(\x0e2\x1a.memos.api.v1.Inbox.StatusB\x03\xe0A\x01R\x06status\x12@\n" +
|
||||
"\vcreate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x03R\n" +
|
||||
"createTime\x121\n" +
|
||||
"\x04type\x18\x06 \x01(\x0e2\x18.memos.api.v1.Inbox.TypeB\x03\xe0A\x03R\x04type\x12)\n" +
|
||||
"\vactivity_id\x18\a \x01(\x05B\x03\xe0A\x01H\x00R\n" +
|
||||
"activityId\x88\x01\x01\":\n" +
|
||||
"\x06Status\x12\x16\n" +
|
||||
"\x12STATUS_UNSPECIFIED\x10\x00\x12\n" +
|
||||
"\n" +
|
||||
"\x06UNREAD\x10\x01\x12\f\n" +
|
||||
"\bARCHIVED\x10\x02\".\n" +
|
||||
"\x04Type\x12\x14\n" +
|
||||
"\x10TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +
|
||||
"\fMEMO_COMMENT\x10\x01:>\xeaA;\n" +
|
||||
"\x12memos.api.v1/Inbox\x12\x0finboxes/{inbox}\x1a\x04name*\ainboxes2\x05inboxB\x0e\n" +
|
||||
"\f_activity_id\"\xca\x01\n" +
|
||||
"\x12ListInboxesRequest\x121\n" +
|
||||
"\x06parent\x18\x01 \x01(\tB\x19\xe0A\x02\xfaA\x13\n" +
|
||||
"\x11memos.api.v1/UserR\x06parent\x12 \n" +
|
||||
"\tpage_size\x18\x02 \x01(\x05B\x03\xe0A\x01R\bpageSize\x12\"\n" +
|
||||
"\n" +
|
||||
"page_token\x18\x03 \x01(\tB\x03\xe0A\x01R\tpageToken\x12\x1b\n" +
|
||||
"\x06filter\x18\x04 \x01(\tB\x03\xe0A\x01R\x06filter\x12\x1e\n" +
|
||||
"\border_by\x18\x05 \x01(\tB\x03\xe0A\x01R\aorderBy\"\x8b\x01\n" +
|
||||
"\x13ListInboxesResponse\x12-\n" +
|
||||
"\ainboxes\x18\x01 \x03(\v2\x13.memos.api.v1.InboxR\ainboxes\x12&\n" +
|
||||
"\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\x12\x1d\n" +
|
||||
"\n" +
|
||||
"total_size\x18\x03 \x01(\x05R\ttotalSize\"\xb0\x01\n" +
|
||||
"\x12UpdateInboxRequest\x12.\n" +
|
||||
"\x05inbox\x18\x01 \x01(\v2\x13.memos.api.v1.InboxB\x03\xe0A\x02R\x05inbox\x12@\n" +
|
||||
"\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskB\x03\xe0A\x02R\n" +
|
||||
"updateMask\x12(\n" +
|
||||
"\rallow_missing\x18\x03 \x01(\bB\x03\xe0A\x01R\fallowMissing\"D\n" +
|
||||
"\x12DeleteInboxRequest\x12.\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x1a\xe0A\x02\xfaA\x14\n" +
|
||||
"\x12memos.api.v1/InboxR\x04name2\x92\x03\n" +
|
||||
"\fInboxService\x12\x85\x01\n" +
|
||||
"\vListInboxes\x12 .memos.api.v1.ListInboxesRequest\x1a!.memos.api.v1.ListInboxesResponse\"1\xdaA\x06parent\x82\xd3\xe4\x93\x02\"\x12 /api/v1/{parent=users/*}/inboxes\x12\x87\x01\n" +
|
||||
"\vUpdateInbox\x12 .memos.api.v1.UpdateInboxRequest\x1a\x13.memos.api.v1.Inbox\"A\xdaA\x11inbox,update_mask\x82\xd3\xe4\x93\x02':\x05inbox2\x1e/api/v1/{inbox.name=inboxes/*}\x12p\n" +
|
||||
"\vDeleteInbox\x12 .memos.api.v1.DeleteInboxRequest\x1a\x16.google.protobuf.Empty\"'\xdaA\x04name\x82\xd3\xe4\x93\x02\x1a*\x18/api/v1/{name=inboxes/*}B\xa9\x01\n" +
|
||||
"\x10com.memos.api.v1B\x11InboxServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_v1_inbox_service_proto_rawDescOnce sync.Once
|
||||
file_api_v1_inbox_service_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_v1_inbox_service_proto_rawDescGZIP() []byte {
|
||||
file_api_v1_inbox_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_v1_inbox_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_v1_inbox_service_proto_rawDesc), len(file_api_v1_inbox_service_proto_rawDesc)))
|
||||
})
|
||||
return file_api_v1_inbox_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v1_inbox_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_api_v1_inbox_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_api_v1_inbox_service_proto_goTypes = []any{
|
||||
(Inbox_Status)(0), // 0: memos.api.v1.Inbox.Status
|
||||
(Inbox_Type)(0), // 1: memos.api.v1.Inbox.Type
|
||||
(*Inbox)(nil), // 2: memos.api.v1.Inbox
|
||||
(*ListInboxesRequest)(nil), // 3: memos.api.v1.ListInboxesRequest
|
||||
(*ListInboxesResponse)(nil), // 4: memos.api.v1.ListInboxesResponse
|
||||
(*UpdateInboxRequest)(nil), // 5: memos.api.v1.UpdateInboxRequest
|
||||
(*DeleteInboxRequest)(nil), // 6: memos.api.v1.DeleteInboxRequest
|
||||
(*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
|
||||
(*fieldmaskpb.FieldMask)(nil), // 8: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 9: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_inbox_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v1.Inbox.status:type_name -> memos.api.v1.Inbox.Status
|
||||
7, // 1: memos.api.v1.Inbox.create_time:type_name -> google.protobuf.Timestamp
|
||||
1, // 2: memos.api.v1.Inbox.type:type_name -> memos.api.v1.Inbox.Type
|
||||
2, // 3: memos.api.v1.ListInboxesResponse.inboxes:type_name -> memos.api.v1.Inbox
|
||||
2, // 4: memos.api.v1.UpdateInboxRequest.inbox:type_name -> memos.api.v1.Inbox
|
||||
8, // 5: memos.api.v1.UpdateInboxRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
3, // 6: memos.api.v1.InboxService.ListInboxes:input_type -> memos.api.v1.ListInboxesRequest
|
||||
5, // 7: memos.api.v1.InboxService.UpdateInbox:input_type -> memos.api.v1.UpdateInboxRequest
|
||||
6, // 8: memos.api.v1.InboxService.DeleteInbox:input_type -> memos.api.v1.DeleteInboxRequest
|
||||
4, // 9: memos.api.v1.InboxService.ListInboxes:output_type -> memos.api.v1.ListInboxesResponse
|
||||
2, // 10: memos.api.v1.InboxService.UpdateInbox:output_type -> memos.api.v1.Inbox
|
||||
9, // 11: memos.api.v1.InboxService.DeleteInbox:output_type -> google.protobuf.Empty
|
||||
9, // [9:12] is the sub-list for method output_type
|
||||
6, // [6:9] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_inbox_service_proto_init() }
|
||||
func file_api_v1_inbox_service_proto_init() {
|
||||
if File_api_v1_inbox_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_v1_inbox_service_proto_msgTypes[0].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_inbox_service_proto_rawDesc), len(file_api_v1_inbox_service_proto_rawDesc)),
|
||||
NumEnums: 2,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_v1_inbox_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_v1_inbox_service_proto_depIdxs,
|
||||
EnumInfos: file_api_v1_inbox_service_proto_enumTypes,
|
||||
MessageInfos: file_api_v1_inbox_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_v1_inbox_service_proto = out.File
|
||||
file_api_v1_inbox_service_proto_goTypes = nil
|
||||
file_api_v1_inbox_service_proto_depIdxs = nil
|
||||
}
|
||||
@ -1,381 +0,0 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/inbox_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var (
|
||||
_ codes.Code
|
||||
_ io.Reader
|
||||
_ status.Status
|
||||
_ = errors.New
|
||||
_ = runtime.String
|
||||
_ = utilities.NewDoubleArray
|
||||
_ = metadata.Join
|
||||
)
|
||||
|
||||
var filter_InboxService_ListInboxes_0 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
|
||||
func request_InboxService_ListInboxes_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListInboxesRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInboxes_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := client.ListInboxes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_InboxService_ListInboxes_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListInboxesRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInboxes_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.ListInboxes(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_InboxService_UpdateInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{"inbox": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
|
||||
func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateInboxRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Inbox); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Inbox); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["inbox.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "inbox.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := client.UpdateInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateInboxRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Inbox); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Inbox); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["inbox.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "inbox.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UpdateInbox(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_InboxService_DeleteInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteInboxRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := client.DeleteInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_InboxService_DeleteInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteInboxRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := server.DeleteInbox(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
// RegisterInboxServiceHandlerServer registers the http handlers for service InboxService to "mux".
|
||||
// UnaryRPC :call InboxServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterInboxServiceHandlerFromEndpoint instead.
|
||||
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
||||
func RegisterInboxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InboxServiceServer) error {
|
||||
mux.Handle(http.MethodGet, pattern_InboxService_ListInboxes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/ListInboxes", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/inboxes"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_InboxService_ListInboxes_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_ListInboxes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v1/{inbox.name=inboxes/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_InboxService_DeleteInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v1/{name=inboxes/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_InboxService_DeleteInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_DeleteInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterInboxServiceHandlerFromEndpoint is same as RegisterInboxServiceHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterInboxServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.NewClient(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
return RegisterInboxServiceHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterInboxServiceHandler registers the http handlers for service InboxService to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterInboxServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterInboxServiceHandlerClient(ctx, mux, NewInboxServiceClient(conn))
|
||||
}
|
||||
|
||||
// RegisterInboxServiceHandlerClient registers the http handlers for service InboxService
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InboxServiceClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InboxServiceClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "InboxServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
||||
func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InboxServiceClient) error {
|
||||
mux.Handle(http.MethodGet, pattern_InboxService_ListInboxes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/ListInboxes", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/inboxes"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_InboxService_ListInboxes_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_ListInboxes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v1/{inbox.name=inboxes/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_InboxService_DeleteInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v1/{name=inboxes/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_InboxService_DeleteInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_InboxService_DeleteInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_InboxService_ListInboxes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "inboxes"}, ""))
|
||||
pattern_InboxService_UpdateInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "inboxes", "inbox.name"}, ""))
|
||||
pattern_InboxService_DeleteInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "inboxes", "name"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_InboxService_ListInboxes_0 = runtime.ForwardResponseMessage
|
||||
forward_InboxService_UpdateInbox_0 = runtime.ForwardResponseMessage
|
||||
forward_InboxService_DeleteInbox_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
@ -1,204 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/inbox_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
InboxService_ListInboxes_FullMethodName = "/memos.api.v1.InboxService/ListInboxes"
|
||||
InboxService_UpdateInbox_FullMethodName = "/memos.api.v1.InboxService/UpdateInbox"
|
||||
InboxService_DeleteInbox_FullMethodName = "/memos.api.v1.InboxService/DeleteInbox"
|
||||
)
|
||||
|
||||
// InboxServiceClient is the client API for InboxService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type InboxServiceClient interface {
|
||||
// ListInboxes lists inboxes for a user.
|
||||
ListInboxes(ctx context.Context, in *ListInboxesRequest, opts ...grpc.CallOption) (*ListInboxesResponse, error)
|
||||
// UpdateInbox updates an inbox.
|
||||
UpdateInbox(ctx context.Context, in *UpdateInboxRequest, opts ...grpc.CallOption) (*Inbox, error)
|
||||
// DeleteInbox deletes an inbox.
|
||||
DeleteInbox(ctx context.Context, in *DeleteInboxRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type inboxServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewInboxServiceClient(cc grpc.ClientConnInterface) InboxServiceClient {
|
||||
return &inboxServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *inboxServiceClient) ListInboxes(ctx context.Context, in *ListInboxesRequest, opts ...grpc.CallOption) (*ListInboxesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListInboxesResponse)
|
||||
err := c.cc.Invoke(ctx, InboxService_ListInboxes_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *inboxServiceClient) UpdateInbox(ctx context.Context, in *UpdateInboxRequest, opts ...grpc.CallOption) (*Inbox, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Inbox)
|
||||
err := c.cc.Invoke(ctx, InboxService_UpdateInbox_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *inboxServiceClient) DeleteInbox(ctx context.Context, in *DeleteInboxRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, InboxService_DeleteInbox_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// InboxServiceServer is the server API for InboxService service.
|
||||
// All implementations must embed UnimplementedInboxServiceServer
|
||||
// for forward compatibility.
|
||||
type InboxServiceServer interface {
|
||||
// ListInboxes lists inboxes for a user.
|
||||
ListInboxes(context.Context, *ListInboxesRequest) (*ListInboxesResponse, error)
|
||||
// UpdateInbox updates an inbox.
|
||||
UpdateInbox(context.Context, *UpdateInboxRequest) (*Inbox, error)
|
||||
// DeleteInbox deletes an inbox.
|
||||
DeleteInbox(context.Context, *DeleteInboxRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedInboxServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedInboxServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedInboxServiceServer struct{}
|
||||
|
||||
func (UnimplementedInboxServiceServer) ListInboxes(context.Context, *ListInboxesRequest) (*ListInboxesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListInboxes not implemented")
|
||||
}
|
||||
func (UnimplementedInboxServiceServer) UpdateInbox(context.Context, *UpdateInboxRequest) (*Inbox, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateInbox not implemented")
|
||||
}
|
||||
func (UnimplementedInboxServiceServer) DeleteInbox(context.Context, *DeleteInboxRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteInbox not implemented")
|
||||
}
|
||||
func (UnimplementedInboxServiceServer) mustEmbedUnimplementedInboxServiceServer() {}
|
||||
func (UnimplementedInboxServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeInboxServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to InboxServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeInboxServiceServer interface {
|
||||
mustEmbedUnimplementedInboxServiceServer()
|
||||
}
|
||||
|
||||
func RegisterInboxServiceServer(s grpc.ServiceRegistrar, srv InboxServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedInboxServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&InboxService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _InboxService_ListInboxes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListInboxesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InboxServiceServer).ListInboxes(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InboxService_ListInboxes_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InboxServiceServer).ListInboxes(ctx, req.(*ListInboxesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InboxService_UpdateInbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateInboxRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InboxServiceServer).UpdateInbox(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InboxService_UpdateInbox_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InboxServiceServer).UpdateInbox(ctx, req.(*UpdateInboxRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InboxService_DeleteInbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteInboxRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InboxServiceServer).DeleteInbox(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InboxService_DeleteInbox_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InboxServiceServer).DeleteInbox(ctx, req.(*DeleteInboxRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// InboxService_ServiceDesc is the grpc.ServiceDesc for InboxService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var InboxService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.InboxService",
|
||||
HandlerType: (*InboxServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListInboxes",
|
||||
Handler: _InboxService_ListInboxes_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateInbox",
|
||||
Handler: _InboxService_UpdateInbox_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteInbox",
|
||||
Handler: _InboxService_DeleteInbox_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/inbox_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,203 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/instance_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
InstanceService_GetInstanceProfile_FullMethodName = "/memos.api.v1.InstanceService/GetInstanceProfile"
|
||||
InstanceService_GetInstanceSetting_FullMethodName = "/memos.api.v1.InstanceService/GetInstanceSetting"
|
||||
InstanceService_UpdateInstanceSetting_FullMethodName = "/memos.api.v1.InstanceService/UpdateInstanceSetting"
|
||||
)
|
||||
|
||||
// InstanceServiceClient is the client API for InstanceService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type InstanceServiceClient interface {
|
||||
// Gets the instance profile.
|
||||
GetInstanceProfile(ctx context.Context, in *GetInstanceProfileRequest, opts ...grpc.CallOption) (*InstanceProfile, error)
|
||||
// Gets an instance setting.
|
||||
GetInstanceSetting(ctx context.Context, in *GetInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error)
|
||||
// Updates an instance setting.
|
||||
UpdateInstanceSetting(ctx context.Context, in *UpdateInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error)
|
||||
}
|
||||
|
||||
type instanceServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewInstanceServiceClient(cc grpc.ClientConnInterface) InstanceServiceClient {
|
||||
return &instanceServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *instanceServiceClient) GetInstanceProfile(ctx context.Context, in *GetInstanceProfileRequest, opts ...grpc.CallOption) (*InstanceProfile, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(InstanceProfile)
|
||||
err := c.cc.Invoke(ctx, InstanceService_GetInstanceProfile_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instanceServiceClient) GetInstanceSetting(ctx context.Context, in *GetInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(InstanceSetting)
|
||||
err := c.cc.Invoke(ctx, InstanceService_GetInstanceSetting_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instanceServiceClient) UpdateInstanceSetting(ctx context.Context, in *UpdateInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(InstanceSetting)
|
||||
err := c.cc.Invoke(ctx, InstanceService_UpdateInstanceSetting_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// InstanceServiceServer is the server API for InstanceService service.
|
||||
// All implementations must embed UnimplementedInstanceServiceServer
|
||||
// for forward compatibility.
|
||||
type InstanceServiceServer interface {
|
||||
// Gets the instance profile.
|
||||
GetInstanceProfile(context.Context, *GetInstanceProfileRequest) (*InstanceProfile, error)
|
||||
// Gets an instance setting.
|
||||
GetInstanceSetting(context.Context, *GetInstanceSettingRequest) (*InstanceSetting, error)
|
||||
// Updates an instance setting.
|
||||
UpdateInstanceSetting(context.Context, *UpdateInstanceSettingRequest) (*InstanceSetting, error)
|
||||
mustEmbedUnimplementedInstanceServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedInstanceServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedInstanceServiceServer struct{}
|
||||
|
||||
func (UnimplementedInstanceServiceServer) GetInstanceProfile(context.Context, *GetInstanceProfileRequest) (*InstanceProfile, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetInstanceProfile not implemented")
|
||||
}
|
||||
func (UnimplementedInstanceServiceServer) GetInstanceSetting(context.Context, *GetInstanceSettingRequest) (*InstanceSetting, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetInstanceSetting not implemented")
|
||||
}
|
||||
func (UnimplementedInstanceServiceServer) UpdateInstanceSetting(context.Context, *UpdateInstanceSettingRequest) (*InstanceSetting, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateInstanceSetting not implemented")
|
||||
}
|
||||
func (UnimplementedInstanceServiceServer) mustEmbedUnimplementedInstanceServiceServer() {}
|
||||
func (UnimplementedInstanceServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeInstanceServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to InstanceServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeInstanceServiceServer interface {
|
||||
mustEmbedUnimplementedInstanceServiceServer()
|
||||
}
|
||||
|
||||
func RegisterInstanceServiceServer(s grpc.ServiceRegistrar, srv InstanceServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedInstanceServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&InstanceService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _InstanceService_GetInstanceProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetInstanceProfileRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstanceServiceServer).GetInstanceProfile(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InstanceService_GetInstanceProfile_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstanceServiceServer).GetInstanceProfile(ctx, req.(*GetInstanceProfileRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstanceService_GetInstanceSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetInstanceSettingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstanceServiceServer).GetInstanceSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InstanceService_GetInstanceSetting_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstanceServiceServer).GetInstanceSetting(ctx, req.(*GetInstanceSettingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstanceService_UpdateInstanceSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateInstanceSettingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstanceServiceServer).UpdateInstanceSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: InstanceService_UpdateInstanceSetting_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstanceServiceServer).UpdateInstanceSetting(ctx, req.(*UpdateInstanceSettingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// InstanceService_ServiceDesc is the grpc.ServiceDesc for InstanceService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var InstanceService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.InstanceService",
|
||||
HandlerType: (*InstanceServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetInstanceProfile",
|
||||
Handler: _InstanceService_GetInstanceProfile_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetInstanceSetting",
|
||||
Handler: _InstanceService_GetInstanceSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateInstanceSetting",
|
||||
Handler: _InstanceService_UpdateInstanceSetting_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/instance_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,203 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/workspace_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
WorkspaceService_GetWorkspaceProfile_FullMethodName = "/memos.api.v1.WorkspaceService/GetWorkspaceProfile"
|
||||
WorkspaceService_GetWorkspaceSetting_FullMethodName = "/memos.api.v1.WorkspaceService/GetWorkspaceSetting"
|
||||
WorkspaceService_UpdateWorkspaceSetting_FullMethodName = "/memos.api.v1.WorkspaceService/UpdateWorkspaceSetting"
|
||||
)
|
||||
|
||||
// WorkspaceServiceClient is the client API for WorkspaceService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type WorkspaceServiceClient interface {
|
||||
// Gets the workspace profile.
|
||||
GetWorkspaceProfile(ctx context.Context, in *GetWorkspaceProfileRequest, opts ...grpc.CallOption) (*WorkspaceProfile, error)
|
||||
// Gets a workspace setting.
|
||||
GetWorkspaceSetting(ctx context.Context, in *GetWorkspaceSettingRequest, opts ...grpc.CallOption) (*WorkspaceSetting, error)
|
||||
// Updates a workspace setting.
|
||||
UpdateWorkspaceSetting(ctx context.Context, in *UpdateWorkspaceSettingRequest, opts ...grpc.CallOption) (*WorkspaceSetting, error)
|
||||
}
|
||||
|
||||
type workspaceServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewWorkspaceServiceClient(cc grpc.ClientConnInterface) WorkspaceServiceClient {
|
||||
return &workspaceServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *workspaceServiceClient) GetWorkspaceProfile(ctx context.Context, in *GetWorkspaceProfileRequest, opts ...grpc.CallOption) (*WorkspaceProfile, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(WorkspaceProfile)
|
||||
err := c.cc.Invoke(ctx, WorkspaceService_GetWorkspaceProfile_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *workspaceServiceClient) GetWorkspaceSetting(ctx context.Context, in *GetWorkspaceSettingRequest, opts ...grpc.CallOption) (*WorkspaceSetting, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(WorkspaceSetting)
|
||||
err := c.cc.Invoke(ctx, WorkspaceService_GetWorkspaceSetting_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *workspaceServiceClient) UpdateWorkspaceSetting(ctx context.Context, in *UpdateWorkspaceSettingRequest, opts ...grpc.CallOption) (*WorkspaceSetting, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(WorkspaceSetting)
|
||||
err := c.cc.Invoke(ctx, WorkspaceService_UpdateWorkspaceSetting_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// WorkspaceServiceServer is the server API for WorkspaceService service.
|
||||
// All implementations must embed UnimplementedWorkspaceServiceServer
|
||||
// for forward compatibility.
|
||||
type WorkspaceServiceServer interface {
|
||||
// Gets the workspace profile.
|
||||
GetWorkspaceProfile(context.Context, *GetWorkspaceProfileRequest) (*WorkspaceProfile, error)
|
||||
// Gets a workspace setting.
|
||||
GetWorkspaceSetting(context.Context, *GetWorkspaceSettingRequest) (*WorkspaceSetting, error)
|
||||
// Updates a workspace setting.
|
||||
UpdateWorkspaceSetting(context.Context, *UpdateWorkspaceSettingRequest) (*WorkspaceSetting, error)
|
||||
mustEmbedUnimplementedWorkspaceServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedWorkspaceServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedWorkspaceServiceServer struct{}
|
||||
|
||||
func (UnimplementedWorkspaceServiceServer) GetWorkspaceProfile(context.Context, *GetWorkspaceProfileRequest) (*WorkspaceProfile, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetWorkspaceProfile not implemented")
|
||||
}
|
||||
func (UnimplementedWorkspaceServiceServer) GetWorkspaceSetting(context.Context, *GetWorkspaceSettingRequest) (*WorkspaceSetting, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetWorkspaceSetting not implemented")
|
||||
}
|
||||
func (UnimplementedWorkspaceServiceServer) UpdateWorkspaceSetting(context.Context, *UpdateWorkspaceSettingRequest) (*WorkspaceSetting, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateWorkspaceSetting not implemented")
|
||||
}
|
||||
func (UnimplementedWorkspaceServiceServer) mustEmbedUnimplementedWorkspaceServiceServer() {}
|
||||
func (UnimplementedWorkspaceServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeWorkspaceServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to WorkspaceServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeWorkspaceServiceServer interface {
|
||||
mustEmbedUnimplementedWorkspaceServiceServer()
|
||||
}
|
||||
|
||||
func RegisterWorkspaceServiceServer(s grpc.ServiceRegistrar, srv WorkspaceServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedWorkspaceServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&WorkspaceService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _WorkspaceService_GetWorkspaceProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetWorkspaceProfileRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(WorkspaceServiceServer).GetWorkspaceProfile(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: WorkspaceService_GetWorkspaceProfile_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WorkspaceServiceServer).GetWorkspaceProfile(ctx, req.(*GetWorkspaceProfileRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _WorkspaceService_GetWorkspaceSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetWorkspaceSettingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(WorkspaceServiceServer).GetWorkspaceSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: WorkspaceService_GetWorkspaceSetting_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WorkspaceServiceServer).GetWorkspaceSetting(ctx, req.(*GetWorkspaceSettingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _WorkspaceService_UpdateWorkspaceSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateWorkspaceSettingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(WorkspaceServiceServer).UpdateWorkspaceSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: WorkspaceService_UpdateWorkspaceSetting_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WorkspaceServiceServer).UpdateWorkspaceSetting(ctx, req.(*UpdateWorkspaceSettingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// WorkspaceService_ServiceDesc is the grpc.ServiceDesc for WorkspaceService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var WorkspaceService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.WorkspaceService",
|
||||
HandlerType: (*WorkspaceServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetWorkspaceProfile",
|
||||
Handler: _WorkspaceService_GetWorkspaceProfile_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetWorkspaceSetting",
|
||||
Handler: _WorkspaceService_GetWorkspaceSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateWorkspaceSetting",
|
||||
Handler: _WorkspaceService_UpdateWorkspaceSetting_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/workspace_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,245 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
type InstanceSetting struct {
|
||||
Name string
|
||||
Value string
|
||||
Description string
|
||||
}
|
||||
|
||||
type FindInstanceSetting struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type DeleteInstanceSetting struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error) {
|
||||
instanceSettingRaw := &InstanceSetting{
|
||||
Name: upsert.Key.String(),
|
||||
}
|
||||
var valueBytes []byte
|
||||
var err error
|
||||
if upsert.Key == storepb.InstanceSettingKey_BASIC {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetBasicSetting())
|
||||
} else if upsert.Key == storepb.InstanceSettingKey_GENERAL {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetGeneralSetting())
|
||||
} else if upsert.Key == storepb.InstanceSettingKey_STORAGE {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetStorageSetting())
|
||||
} else if upsert.Key == storepb.InstanceSettingKey_MEMO_RELATED {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetMemoRelatedSetting())
|
||||
} else {
|
||||
return nil, errors.Errorf("unsupported instance setting key: %v", upsert.Key)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal instance setting value")
|
||||
}
|
||||
valueString := string(valueBytes)
|
||||
instanceSettingRaw.Value = valueString
|
||||
instanceSettingRaw, err = s.driver.UpsertInstanceSetting(ctx, instanceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to upsert instance setting")
|
||||
}
|
||||
instanceSetting, err := convertInstanceSettingFromRaw(instanceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to convert instance setting")
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, instanceSetting.Key.String(), instanceSetting)
|
||||
return instanceSetting, nil
|
||||
}
|
||||
|
||||
func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error) {
|
||||
list, err := s.driver.ListInstanceSettings(ctx, find)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
instanceSettings := []*storepb.InstanceSetting{}
|
||||
for _, instanceSettingRaw := range list {
|
||||
instanceSetting, err := convertInstanceSettingFromRaw(instanceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to convert instance setting")
|
||||
}
|
||||
if instanceSetting == nil {
|
||||
continue
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, instanceSetting.Key.String(), instanceSetting)
|
||||
instanceSettings = append(instanceSettings, instanceSetting)
|
||||
}
|
||||
return instanceSettings, nil
|
||||
}
|
||||
|
||||
func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error) {
|
||||
if cache, ok := s.instanceSettingCache.Get(ctx, find.Name); ok {
|
||||
instanceSetting, ok := cache.(*storepb.InstanceSetting)
|
||||
if ok {
|
||||
return instanceSetting, nil
|
||||
}
|
||||
}
|
||||
|
||||
list, err := s.ListInstanceSettings(ctx, find)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(list) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if len(list) > 1 {
|
||||
return nil, errors.Errorf("found multiple instance settings with key %s", find.Name)
|
||||
}
|
||||
return list[0], nil
|
||||
}
|
||||
|
||||
func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error) {
|
||||
instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{
|
||||
Name: storepb.InstanceSettingKey_BASIC.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get instance basic setting")
|
||||
}
|
||||
|
||||
instanceBasicSetting := &storepb.InstanceBasicSetting{}
|
||||
if instanceSetting != nil {
|
||||
instanceBasicSetting = instanceSetting.GetBasicSetting()
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_BASIC.String(), &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_BASIC,
|
||||
Value: &storepb.InstanceSetting_BasicSetting{BasicSetting: instanceBasicSetting},
|
||||
})
|
||||
return instanceBasicSetting, nil
|
||||
}
|
||||
|
||||
func (s *Store) GetInstanceGeneralSetting(ctx context.Context) (*storepb.InstanceGeneralSetting, error) {
|
||||
instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{
|
||||
Name: storepb.InstanceSettingKey_GENERAL.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get instance general setting")
|
||||
}
|
||||
|
||||
instanceGeneralSetting := &storepb.InstanceGeneralSetting{}
|
||||
if instanceSetting != nil {
|
||||
instanceGeneralSetting = instanceSetting.GetGeneralSetting()
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_GENERAL.String(), &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_GENERAL,
|
||||
Value: &storepb.InstanceSetting_GeneralSetting{GeneralSetting: instanceGeneralSetting},
|
||||
})
|
||||
return instanceGeneralSetting, nil
|
||||
}
|
||||
|
||||
// DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.
|
||||
const DefaultContentLengthLimit = 8 * 1024
|
||||
|
||||
// DefaultReactions is the default reactions for memo related setting.
|
||||
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}
|
||||
|
||||
// DefaultNsfwTags is the default tags that mark content as NSFW for blurring.
|
||||
var DefaultNsfwTags = []string{"nsfw"}
|
||||
|
||||
func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error) {
|
||||
instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{
|
||||
Name: storepb.InstanceSettingKey_MEMO_RELATED.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get instance general setting")
|
||||
}
|
||||
|
||||
instanceMemoRelatedSetting := &storepb.InstanceMemoRelatedSetting{}
|
||||
if instanceSetting != nil {
|
||||
instanceMemoRelatedSetting = instanceSetting.GetMemoRelatedSetting()
|
||||
}
|
||||
if instanceMemoRelatedSetting.ContentLengthLimit < DefaultContentLengthLimit {
|
||||
instanceMemoRelatedSetting.ContentLengthLimit = DefaultContentLengthLimit
|
||||
}
|
||||
if len(instanceMemoRelatedSetting.Reactions) == 0 {
|
||||
instanceMemoRelatedSetting.Reactions = append(instanceMemoRelatedSetting.Reactions, DefaultReactions...)
|
||||
}
|
||||
if len(instanceMemoRelatedSetting.NsfwTags) == 0 {
|
||||
instanceMemoRelatedSetting.NsfwTags = append(instanceMemoRelatedSetting.NsfwTags, DefaultNsfwTags...)
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_MEMO_RELATED.String(), &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_MEMO_RELATED,
|
||||
Value: &storepb.InstanceSetting_MemoRelatedSetting{MemoRelatedSetting: instanceMemoRelatedSetting},
|
||||
})
|
||||
return instanceMemoRelatedSetting, nil
|
||||
}
|
||||
|
||||
const (
|
||||
defaultInstanceStorageType = storepb.InstanceStorageSetting_DATABASE
|
||||
defaultInstanceUploadSizeLimitMb = 30
|
||||
defaultInstanceFilepathTemplate = "assets/{timestamp}_{filename}"
|
||||
)
|
||||
|
||||
func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error) {
|
||||
instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{
|
||||
Name: storepb.InstanceSettingKey_STORAGE.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get instance storage setting")
|
||||
}
|
||||
|
||||
instanceStorageSetting := &storepb.InstanceStorageSetting{}
|
||||
if instanceSetting != nil {
|
||||
instanceStorageSetting = instanceSetting.GetStorageSetting()
|
||||
}
|
||||
if instanceStorageSetting.StorageType == storepb.InstanceStorageSetting_STORAGE_TYPE_UNSPECIFIED {
|
||||
instanceStorageSetting.StorageType = defaultInstanceStorageType
|
||||
}
|
||||
if instanceStorageSetting.UploadSizeLimitMb == 0 {
|
||||
instanceStorageSetting.UploadSizeLimitMb = defaultInstanceUploadSizeLimitMb
|
||||
}
|
||||
if instanceStorageSetting.FilepathTemplate == "" {
|
||||
instanceStorageSetting.FilepathTemplate = defaultInstanceFilepathTemplate
|
||||
}
|
||||
s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_STORAGE.String(), &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: instanceStorageSetting},
|
||||
})
|
||||
return instanceStorageSetting, nil
|
||||
}
|
||||
|
||||
func convertInstanceSettingFromRaw(instanceSettingRaw *InstanceSetting) (*storepb.InstanceSetting, error) {
|
||||
instanceSetting := &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey(storepb.InstanceSettingKey_value[instanceSettingRaw.Name]),
|
||||
}
|
||||
switch instanceSettingRaw.Name {
|
||||
case storepb.InstanceSettingKey_BASIC.String():
|
||||
basicSetting := &storepb.InstanceBasicSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(instanceSettingRaw.Value), basicSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceSetting.Value = &storepb.InstanceSetting_BasicSetting{BasicSetting: basicSetting}
|
||||
case storepb.InstanceSettingKey_GENERAL.String():
|
||||
generalSetting := &storepb.InstanceGeneralSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(instanceSettingRaw.Value), generalSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceSetting.Value = &storepb.InstanceSetting_GeneralSetting{GeneralSetting: generalSetting}
|
||||
case storepb.InstanceSettingKey_STORAGE.String():
|
||||
storageSetting := &storepb.InstanceStorageSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(instanceSettingRaw.Value), storageSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceSetting.Value = &storepb.InstanceSetting_StorageSetting{StorageSetting: storageSetting}
|
||||
case storepb.InstanceSettingKey_MEMO_RELATED.String():
|
||||
memoRelatedSetting := &storepb.InstanceMemoRelatedSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(instanceSettingRaw.Value), memoRelatedSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceSetting.Value = &storepb.InstanceSetting_MemoRelatedSetting{MemoRelatedSetting: memoRelatedSetting}
|
||||
default:
|
||||
// Skip unsupported instance setting key.
|
||||
return nil, nil
|
||||
}
|
||||
return instanceSetting, nil
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestInstanceSettingV1Store(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
instanceSetting, err := ts.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_GENERAL,
|
||||
Value: &storepb.InstanceSetting_GeneralSetting{
|
||||
GeneralSetting: &storepb.InstanceGeneralSetting{
|
||||
AdditionalScript: "",
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
setting, err := ts.GetInstanceSetting(ctx, &store.FindInstanceSetting{
|
||||
Name: storepb.InstanceSettingKey_GENERAL.String(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, instanceSetting, setting)
|
||||
ts.Close()
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestWorkspaceSettingV1Store(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
workspaceSetting, err := ts.UpsertWorkspaceSetting(ctx, &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_GENERAL,
|
||||
Value: &storepb.WorkspaceSetting_GeneralSetting{
|
||||
GeneralSetting: &storepb.WorkspaceGeneralSetting{
|
||||
AdditionalScript: "",
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
setting, err := ts.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
||||
Name: storepb.WorkspaceSettingKey_GENERAL.String(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, workspaceSetting, setting)
|
||||
ts.Close()
|
||||
}
|
||||
@ -1,245 +0,0 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
type WorkspaceSetting struct {
|
||||
Name string
|
||||
Value string
|
||||
Description string
|
||||
}
|
||||
|
||||
type FindWorkspaceSetting struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type DeleteWorkspaceSetting struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (s *Store) UpsertWorkspaceSetting(ctx context.Context, upsert *storepb.WorkspaceSetting) (*storepb.WorkspaceSetting, error) {
|
||||
workspaceSettingRaw := &WorkspaceSetting{
|
||||
Name: upsert.Key.String(),
|
||||
}
|
||||
var valueBytes []byte
|
||||
var err error
|
||||
if upsert.Key == storepb.WorkspaceSettingKey_BASIC {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetBasicSetting())
|
||||
} else if upsert.Key == storepb.WorkspaceSettingKey_GENERAL {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetGeneralSetting())
|
||||
} else if upsert.Key == storepb.WorkspaceSettingKey_STORAGE {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetStorageSetting())
|
||||
} else if upsert.Key == storepb.WorkspaceSettingKey_MEMO_RELATED {
|
||||
valueBytes, err = protojson.Marshal(upsert.GetMemoRelatedSetting())
|
||||
} else {
|
||||
return nil, errors.Errorf("unsupported workspace setting key: %v", upsert.Key)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal workspace setting value")
|
||||
}
|
||||
valueString := string(valueBytes)
|
||||
workspaceSettingRaw.Value = valueString
|
||||
workspaceSettingRaw, err = s.driver.UpsertWorkspaceSetting(ctx, workspaceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to upsert workspace setting")
|
||||
}
|
||||
workspaceSetting, err := convertWorkspaceSettingFromRaw(workspaceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to convert workspace setting")
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, workspaceSetting.Key.String(), workspaceSetting)
|
||||
return workspaceSetting, nil
|
||||
}
|
||||
|
||||
func (s *Store) ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSetting) ([]*storepb.WorkspaceSetting, error) {
|
||||
list, err := s.driver.ListWorkspaceSettings(ctx, find)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
workspaceSettings := []*storepb.WorkspaceSetting{}
|
||||
for _, workspaceSettingRaw := range list {
|
||||
workspaceSetting, err := convertWorkspaceSettingFromRaw(workspaceSettingRaw)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to convert workspace setting")
|
||||
}
|
||||
if workspaceSetting == nil {
|
||||
continue
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, workspaceSetting.Key.String(), workspaceSetting)
|
||||
workspaceSettings = append(workspaceSettings, workspaceSetting)
|
||||
}
|
||||
return workspaceSettings, nil
|
||||
}
|
||||
|
||||
func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error) {
|
||||
if cache, ok := s.workspaceSettingCache.Get(ctx, find.Name); ok {
|
||||
workspaceSetting, ok := cache.(*storepb.WorkspaceSetting)
|
||||
if ok {
|
||||
return workspaceSetting, nil
|
||||
}
|
||||
}
|
||||
|
||||
list, err := s.ListWorkspaceSettings(ctx, find)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(list) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
if len(list) > 1 {
|
||||
return nil, errors.Errorf("found multiple workspace settings with key %s", find.Name)
|
||||
}
|
||||
return list[0], nil
|
||||
}
|
||||
|
||||
func (s *Store) GetWorkspaceBasicSetting(ctx context.Context) (*storepb.WorkspaceBasicSetting, error) {
|
||||
workspaceSetting, err := s.GetWorkspaceSetting(ctx, &FindWorkspaceSetting{
|
||||
Name: storepb.WorkspaceSettingKey_BASIC.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace basic setting")
|
||||
}
|
||||
|
||||
workspaceBasicSetting := &storepb.WorkspaceBasicSetting{}
|
||||
if workspaceSetting != nil {
|
||||
workspaceBasicSetting = workspaceSetting.GetBasicSetting()
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, storepb.WorkspaceSettingKey_BASIC.String(), &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_BASIC,
|
||||
Value: &storepb.WorkspaceSetting_BasicSetting{BasicSetting: workspaceBasicSetting},
|
||||
})
|
||||
return workspaceBasicSetting, nil
|
||||
}
|
||||
|
||||
func (s *Store) GetWorkspaceGeneralSetting(ctx context.Context) (*storepb.WorkspaceGeneralSetting, error) {
|
||||
workspaceSetting, err := s.GetWorkspaceSetting(ctx, &FindWorkspaceSetting{
|
||||
Name: storepb.WorkspaceSettingKey_GENERAL.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace general setting")
|
||||
}
|
||||
|
||||
workspaceGeneralSetting := &storepb.WorkspaceGeneralSetting{}
|
||||
if workspaceSetting != nil {
|
||||
workspaceGeneralSetting = workspaceSetting.GetGeneralSetting()
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, storepb.WorkspaceSettingKey_GENERAL.String(), &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_GENERAL,
|
||||
Value: &storepb.WorkspaceSetting_GeneralSetting{GeneralSetting: workspaceGeneralSetting},
|
||||
})
|
||||
return workspaceGeneralSetting, nil
|
||||
}
|
||||
|
||||
// DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.
|
||||
const DefaultContentLengthLimit = 8 * 1024
|
||||
|
||||
// DefaultReactions is the default reactions for memo related setting.
|
||||
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}
|
||||
|
||||
// DefaultNsfwTags is the default tags that mark content as NSFW for blurring.
|
||||
var DefaultNsfwTags = []string{"nsfw"}
|
||||
|
||||
func (s *Store) GetWorkspaceMemoRelatedSetting(ctx context.Context) (*storepb.WorkspaceMemoRelatedSetting, error) {
|
||||
workspaceSetting, err := s.GetWorkspaceSetting(ctx, &FindWorkspaceSetting{
|
||||
Name: storepb.WorkspaceSettingKey_MEMO_RELATED.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace general setting")
|
||||
}
|
||||
|
||||
workspaceMemoRelatedSetting := &storepb.WorkspaceMemoRelatedSetting{}
|
||||
if workspaceSetting != nil {
|
||||
workspaceMemoRelatedSetting = workspaceSetting.GetMemoRelatedSetting()
|
||||
}
|
||||
if workspaceMemoRelatedSetting.ContentLengthLimit < DefaultContentLengthLimit {
|
||||
workspaceMemoRelatedSetting.ContentLengthLimit = DefaultContentLengthLimit
|
||||
}
|
||||
if len(workspaceMemoRelatedSetting.Reactions) == 0 {
|
||||
workspaceMemoRelatedSetting.Reactions = append(workspaceMemoRelatedSetting.Reactions, DefaultReactions...)
|
||||
}
|
||||
if len(workspaceMemoRelatedSetting.NsfwTags) == 0 {
|
||||
workspaceMemoRelatedSetting.NsfwTags = append(workspaceMemoRelatedSetting.NsfwTags, DefaultNsfwTags...)
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, storepb.WorkspaceSettingKey_MEMO_RELATED.String(), &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_MEMO_RELATED,
|
||||
Value: &storepb.WorkspaceSetting_MemoRelatedSetting{MemoRelatedSetting: workspaceMemoRelatedSetting},
|
||||
})
|
||||
return workspaceMemoRelatedSetting, nil
|
||||
}
|
||||
|
||||
const (
|
||||
defaultWorkspaceStorageType = storepb.WorkspaceStorageSetting_DATABASE
|
||||
defaultWorkspaceUploadSizeLimitMb = 30
|
||||
defaultWorkspaceFilepathTemplate = "assets/{timestamp}_{filename}"
|
||||
)
|
||||
|
||||
func (s *Store) GetWorkspaceStorageSetting(ctx context.Context) (*storepb.WorkspaceStorageSetting, error) {
|
||||
workspaceSetting, err := s.GetWorkspaceSetting(ctx, &FindWorkspaceSetting{
|
||||
Name: storepb.WorkspaceSettingKey_STORAGE.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace storage setting")
|
||||
}
|
||||
|
||||
workspaceStorageSetting := &storepb.WorkspaceStorageSetting{}
|
||||
if workspaceSetting != nil {
|
||||
workspaceStorageSetting = workspaceSetting.GetStorageSetting()
|
||||
}
|
||||
if workspaceStorageSetting.StorageType == storepb.WorkspaceStorageSetting_STORAGE_TYPE_UNSPECIFIED {
|
||||
workspaceStorageSetting.StorageType = defaultWorkspaceStorageType
|
||||
}
|
||||
if workspaceStorageSetting.UploadSizeLimitMb == 0 {
|
||||
workspaceStorageSetting.UploadSizeLimitMb = defaultWorkspaceUploadSizeLimitMb
|
||||
}
|
||||
if workspaceStorageSetting.FilepathTemplate == "" {
|
||||
workspaceStorageSetting.FilepathTemplate = defaultWorkspaceFilepathTemplate
|
||||
}
|
||||
s.workspaceSettingCache.Set(ctx, storepb.WorkspaceSettingKey_STORAGE.String(), &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_STORAGE,
|
||||
Value: &storepb.WorkspaceSetting_StorageSetting{StorageSetting: workspaceStorageSetting},
|
||||
})
|
||||
return workspaceStorageSetting, nil
|
||||
}
|
||||
|
||||
func convertWorkspaceSettingFromRaw(workspaceSettingRaw *WorkspaceSetting) (*storepb.WorkspaceSetting, error) {
|
||||
workspaceSetting := &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey(storepb.WorkspaceSettingKey_value[workspaceSettingRaw.Name]),
|
||||
}
|
||||
switch workspaceSettingRaw.Name {
|
||||
case storepb.WorkspaceSettingKey_BASIC.String():
|
||||
basicSetting := &storepb.WorkspaceBasicSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), basicSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
workspaceSetting.Value = &storepb.WorkspaceSetting_BasicSetting{BasicSetting: basicSetting}
|
||||
case storepb.WorkspaceSettingKey_GENERAL.String():
|
||||
generalSetting := &storepb.WorkspaceGeneralSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), generalSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
workspaceSetting.Value = &storepb.WorkspaceSetting_GeneralSetting{GeneralSetting: generalSetting}
|
||||
case storepb.WorkspaceSettingKey_STORAGE.String():
|
||||
storageSetting := &storepb.WorkspaceStorageSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), storageSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
workspaceSetting.Value = &storepb.WorkspaceSetting_StorageSetting{StorageSetting: storageSetting}
|
||||
case storepb.WorkspaceSettingKey_MEMO_RELATED.String():
|
||||
memoRelatedSetting := &storepb.WorkspaceMemoRelatedSetting{}
|
||||
if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), memoRelatedSetting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{MemoRelatedSetting: memoRelatedSetting}
|
||||
default:
|
||||
// Skip unsupported workspace setting key.
|
||||
return nil, nil
|
||||
}
|
||||
return workspaceSetting, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue