diff --git a/pkg/proto/v0/accounts.pb.go b/pkg/proto/v0/accounts.pb.go index a31a0e539c..6e4503750a 100644 --- a/pkg/proto/v0/accounts.pb.go +++ b/pkg/proto/v0/accounts.pb.go @@ -21,11 +21,11 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type Record struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Theme string `protobuf:"bytes,2,opt,name=theme,proto3" json:"theme,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Payload *Settings `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Record) Reset() { *m = Record{} } @@ -53,18 +53,18 @@ func (m *Record) XXX_DiscardUnknown() { var xxx_messageInfo_Record proto.InternalMessageInfo -func (m *Record) GetId() string { +func (m *Record) GetKey() string { if m != nil { - return m.Id + return m.Key } return "" } -func (m *Record) GetTheme() string { +func (m *Record) GetPayload() *Settings { if m != nil { - return m.Theme + return m.Payload } - return "" + return nil } type Query struct { @@ -106,23 +106,67 @@ func (m *Query) GetId() string { return "" } +type Settings struct { + Theme string `protobuf:"bytes,2,opt,name=theme,proto3" json:"theme,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Settings) Reset() { *m = Settings{} } +func (m *Settings) String() string { return proto.CompactTextString(m) } +func (*Settings) ProtoMessage() {} +func (*Settings) Descriptor() ([]byte, []int) { + return fileDescriptor_e3c84319968a576b, []int{2} +} + +func (m *Settings) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Settings.Unmarshal(m, b) +} +func (m *Settings) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Settings.Marshal(b, m, deterministic) +} +func (m *Settings) XXX_Merge(src proto.Message) { + xxx_messageInfo_Settings.Merge(m, src) +} +func (m *Settings) XXX_Size() int { + return xxx_messageInfo_Settings.Size(m) +} +func (m *Settings) XXX_DiscardUnknown() { + xxx_messageInfo_Settings.DiscardUnknown(m) +} + +var xxx_messageInfo_Settings proto.InternalMessageInfo + +func (m *Settings) GetTheme() string { + if m != nil { + return m.Theme + } + return "" +} + func init() { - proto.RegisterType((*Record)(nil), "Record") - proto.RegisterType((*Query)(nil), "Query") + proto.RegisterType((*Record)(nil), "settings.Record") + proto.RegisterType((*Query)(nil), "settings.Query") + proto.RegisterType((*Settings)(nil), "settings.Settings") } func init() { proto.RegisterFile("pkg/proto/v0/accounts.proto", fileDescriptor_e3c84319968a576b) } var fileDescriptor_e3c84319968a576b = []byte{ - // 160 bytes of a gzipped FileDescriptorProto + // 211 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0xc8, 0x4e, 0xd7, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x33, 0xd0, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, - 0x29, 0xd6, 0x03, 0x8b, 0x28, 0xe9, 0x71, 0xb1, 0x05, 0xa5, 0x26, 0xe7, 0x17, 0xa5, 0x08, 0xf1, - 0x71, 0x31, 0x65, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x31, 0x65, 0xa6, 0x08, 0x89, - 0x70, 0xb1, 0x96, 0x64, 0xa4, 0xe6, 0xa6, 0x4a, 0x30, 0x81, 0x85, 0x20, 0x1c, 0x25, 0x71, 0x2e, - 0xd6, 0xc0, 0xd2, 0xd4, 0xa2, 0x4a, 0x74, 0xe5, 0x46, 0x4e, 0x5c, 0xfc, 0xc1, 0xa9, 0x25, 0x25, - 0x99, 0x79, 0xe9, 0xc5, 0xc1, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x42, 0xe2, 0x5c, 0xcc, 0xc1, - 0xa9, 0x25, 0x42, 0xec, 0x7a, 0x10, 0x1b, 0xa4, 0x60, 0x0c, 0x21, 0x31, 0x2e, 0x66, 0xf7, 0xd4, - 0x12, 0x21, 0x36, 0x3d, 0xb0, 0x51, 0x70, 0x71, 0x27, 0xf6, 0x28, 0x56, 0xb0, 0xab, 0x92, 0xd8, - 0xc0, 0x94, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x77, 0x5d, 0x07, 0xb2, 0xbb, 0x00, 0x00, 0x00, + 0x29, 0xd6, 0x03, 0x8b, 0x08, 0x71, 0x14, 0xa7, 0x96, 0x94, 0x64, 0xe6, 0xa5, 0x17, 0x2b, 0x79, + 0x70, 0xb1, 0x05, 0xa5, 0x26, 0xe7, 0x17, 0xa5, 0x08, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x4a, + 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, 0x98, 0x42, 0x3a, 0x5c, 0xec, 0x05, 0x89, 0x95, 0x39, + 0xf9, 0x89, 0x29, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x42, 0x7a, 0x30, 0x7d, 0x7a, 0xc1, + 0x50, 0x46, 0x10, 0x4c, 0x89, 0x92, 0x38, 0x17, 0x6b, 0x60, 0x69, 0x6a, 0x51, 0xa5, 0x10, 0x1f, + 0x17, 0x53, 0x66, 0x0a, 0xd4, 0x1c, 0xa6, 0xcc, 0x14, 0x25, 0x05, 0x2e, 0x0e, 0x98, 0x6a, 0x21, + 0x11, 0x2e, 0xd6, 0x92, 0x8c, 0xd4, 0xdc, 0x54, 0xb0, 0x81, 0x9c, 0x41, 0x10, 0x8e, 0x51, 0x1a, + 0x17, 0x3f, 0x4c, 0x45, 0x70, 0x6a, 0x51, 0x59, 0x66, 0x72, 0xaa, 0x90, 0x26, 0x17, 0x73, 0x70, + 0x6a, 0x89, 0x90, 0x00, 0xc2, 0x46, 0x88, 0x33, 0xa5, 0x30, 0x44, 0x84, 0x34, 0xb8, 0x98, 0xdd, + 0x53, 0x4b, 0x84, 0xf8, 0x11, 0x12, 0x60, 0x77, 0x60, 0xaa, 0x74, 0x62, 0x8f, 0x62, 0x05, 0xfb, + 0x3f, 0x89, 0x0d, 0x4c, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x28, 0x61, 0x84, 0x13, 0x25, + 0x01, 0x00, 0x00, } diff --git a/pkg/proto/v0/accounts.pb.micro.go b/pkg/proto/v0/accounts.pb.micro.go index 15473f36d1..56a3c88a4f 100644 --- a/pkg/proto/v0/accounts.pb.micro.go +++ b/pkg/proto/v0/accounts.pb.micro.go @@ -48,7 +48,7 @@ func NewSettingsService(name string, c client.Client) SettingsService { c = client.NewClient() } if len(name) == 0 { - name = "settingsservice" + name = "settings" } return &settingsService{ c: c, diff --git a/pkg/proto/v0/accounts.proto b/pkg/proto/v0/accounts.proto index 14f4fda453..68c93a5f74 100644 --- a/pkg/proto/v0/accounts.proto +++ b/pkg/proto/v0/accounts.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +package settings; option go_package = "proto"; service SettingsService { @@ -8,10 +9,14 @@ service SettingsService { } message Record { - string id = 1; - string theme = 2; + string key = 1; + Settings payload = 2; } message Query { string id = 1; +} + +message Settings { + string theme = 2; } \ No newline at end of file diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index bde7b72c98..b0c51b188f 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -3,7 +3,6 @@ package service import ( "context" "encoding/json" - "log" mstore "github.com/micro/go-micro/v2/store" "github.com/owncloud/ocis-accounts/pkg/proto/v0" @@ -20,17 +19,16 @@ type Service struct{} // Set implements the SettingsServiceHandler interface generated on accounts.pb.micro.go func (s Service) Set(c context.Context, req *proto.Record, res *proto.Record) error { - // uses a store manager to persist account information st := store.New() - data, err := json.Marshal([]byte(`{"theme": "dark"}`)) + settingsJSON, err := json.Marshal(req.Payload) if err != nil { - // deal with this accordingly and not panicking - log.Panic(err) + // TODO deal with this } + record := mstore.Record{ - Key: req.Id, - Value: data, + Key: req.Key, + Value: settingsJSON, } return st.Write(&record) diff --git a/pkg/store/filesystem/store.go b/pkg/store/filesystem/store.go index 98a04d88cd..ace07ec622 100644 --- a/pkg/store/filesystem/store.go +++ b/pkg/store/filesystem/store.go @@ -37,7 +37,7 @@ func (s *Store) Read(key string, opts ...mstore.ReadOption) ([]*mstore.Record, e // Write implements the store interface func (s *Store) Write(rec *mstore.Record) error { - if rec.Key == "" { + if len(rec.Key) < 1 { return fmt.Errorf("%v", "key is empty") }