mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-10 01:51:07 +09:00
refactor for the new protoc gen w/o underscores
This commit is contained in:
parent
db56f61f47
commit
824f9932e3
18 changed files with 325 additions and 325 deletions
4
Makefile
4
Makefile
|
@ -68,5 +68,5 @@ setup-protoc:
|
|||
protos:
|
||||
$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct)
|
||||
cd pb/protos; protoc --gogofaster_out=$(P_STRUCT):.. *.proto
|
||||
cd pb/protos/service; PACKAGE_PATH=github.com/anytypeio/go-anytype-middleware/pb protoc -I=.. -I=. --gogofast_out=plugins=gomobile:../../../lib service.proto
|
||||
cd pb/protos; protoc --doc_out=../../docs --doc_opt=markdown,proto.md service/*.proto *.proto
|
||||
cd pb/protos/service; GOGO_NO_UNDERSCORE=1 PACKAGE_PATH=github.com/anytypeio/go-anytype-middleware/pb protoc -I=.. -I=. --gogofast_out=plugins=gomobile:../../../lib service.proto
|
||||
cd pb/protos; GOGO_NO_UNDERSCORE=1 protoc --doc_out=../../docs --doc_opt=markdown,proto.md service/*.proto *.proto
|
||||
|
|
106
core/account.go
106
core/account.go
|
@ -11,11 +11,11 @@ import (
|
|||
"github.com/anytypeio/go-anytype-middleware/pb"
|
||||
)
|
||||
|
||||
var avatarSizes = []pb.Model_Image_Size{pb.Model_Image_SMALL, pb.Model_Image_LARGE}
|
||||
var avatarSizes = []pb.ModelImageSize{pb.ModelImage_SMALL, pb.ModelImage_LARGE}
|
||||
|
||||
func (mw *Middleware) AccountCreate(req *pb.Rpc_Account_Create_Request) *pb.Rpc_Account_Create_Response {
|
||||
response := func(account *pb.Model_Account, code pb.Rpc_Account_Create_Response_Error_Code, err error) *pb.Rpc_Account_Create_Response {
|
||||
m := &pb.Rpc_Account_Create_Response{Account: account, Error: &pb.Rpc_Account_Create_Response_Error{Code: code}}
|
||||
func (mw *Middleware) AccountCreate(req *pb.RpcAccountCreateRequest) *pb.RpcAccountCreateResponse {
|
||||
response := func(account *pb.ModelAccount, code pb.RpcAccountCreateResponseErrorCode, err error) *pb.RpcAccountCreateResponse {
|
||||
m := &pb.RpcAccountCreateResponse{Account: account, Error: &pb.RpcAccountCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -30,61 +30,61 @@ func (mw *Middleware) AccountCreate(req *pb.Rpc_Account_Create_Request) *pb.Rpc_
|
|||
|
||||
account, err := core.WalletAccountAt(mw.mnemonic, len(mw.localAccounts), "")
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Create_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcAccountCreateResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
err = core.WalletInitRepo(mw.rootPath, account.Seed())
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Create_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcAccountCreateResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
anytype, err := core.New(mw.rootPath, account.Address())
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Create_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcAccountCreateResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
mw.Anytype = anytype
|
||||
newAcc := &pb.Model_Account{Id: account.Address()}
|
||||
newAcc := &pb.ModelAccount{Id: account.Address()}
|
||||
|
||||
err = mw.Run()
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE, err)
|
||||
}
|
||||
|
||||
err = mw.AccountSetName(req.Name)
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME, err)
|
||||
}
|
||||
newAcc.Name, err = mw.Textile.Name()
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME, err)
|
||||
}
|
||||
|
||||
if req.GetAvatarLocalPath() != "" {
|
||||
_, err := mw.AccountSetAvatar(req.GetAvatarLocalPath())
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
}
|
||||
|
||||
hash, err := mw.Textile.Avatar()
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
}
|
||||
newAcc.Avatar = &pb.Model_Account_Avatar{Avatar: &pb.Model_Account_Avatar_Image{Image: &pb.Model_Image{hash, avatarSizes}}}
|
||||
newAcc.Avatar = &pb.ModelAccountAvatar{Avatar: &pb.ModelAccountAvatarAvatarOfImage{Image: &pb.ModelImage{hash, avatarSizes}}}
|
||||
} else if req.GetAvatarColor() != "" {
|
||||
err := mw.AccountSetAvatarColor(req.GetAvatarColor())
|
||||
if err != nil {
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR, err)
|
||||
}
|
||||
}
|
||||
|
||||
mw.localAccounts = append(mw.localAccounts, newAcc)
|
||||
return response(newAcc, pb.Rpc_Account_Create_Response_Error_NULL, nil)
|
||||
return response(newAcc, pb.RpcAccountCreateResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_Account_Recover_Response {
|
||||
response := func(code pb.Rpc_Account_Recover_Response_Error_Code, err error) *pb.Rpc_Account_Recover_Response {
|
||||
m := &pb.Rpc_Account_Recover_Response{Error: &pb.Rpc_Account_Recover_Response_Error{Code: code}}
|
||||
func (mw *Middleware) AccountRecover(_ *pb.RpcAccountRecoverRequest) *pb.RpcAccountRecoverResponse {
|
||||
response := func(code pb.RpcAccountRecoverResponseErrorCode, err error) *pb.RpcAccountRecoverResponse {
|
||||
m := &pb.RpcAccountRecoverResponse{Error: &pb.RpcAccountRecoverResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -92,15 +92,15 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
return m
|
||||
}
|
||||
|
||||
sendAccountAddEvent := func(index int, account *pb.Model_Account) {
|
||||
m := &pb.Event{Message: &pb.Event_AccountShow{AccountShow: &pb.Event_Account_Show{Index: int64(index), Account: account}}}
|
||||
sendAccountAddEvent := func(index int, account *pb.ModelAccount) {
|
||||
m := &pb.Event{Message: &pb.EventMessageOfAccountShow{AccountShow: &pb.EventAccountShow{Index: int64(index), Account: account}}}
|
||||
if mw.SendEvent != nil {
|
||||
mw.SendEvent(m)
|
||||
}
|
||||
}
|
||||
|
||||
if mw.mnemonic == "" {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NEED_TO_RECOVER_WALLET_FIRST, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NEED_TO_RECOVER_WALLET_FIRST, nil)
|
||||
}
|
||||
|
||||
shouldCancel := false
|
||||
|
@ -129,32 +129,32 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
sendAccountAddEvent(index, mw.localAccounts[index])
|
||||
index++
|
||||
if shouldCancel {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NULL, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// now let's start the first account to perform cafe contacts search queries
|
||||
account, err := core.WalletAccountAt(mw.mnemonic, 0, "")
|
||||
if err != nil {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_WALLET_RECOVER_NOT_PERFORMED, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_WALLET_RECOVER_NOT_PERFORMED, err)
|
||||
}
|
||||
|
||||
err = core.WalletInitRepo(mw.rootPath, account.Seed())
|
||||
if err != nil && err != core.ErrRepoExists {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
}
|
||||
|
||||
anytype, err := core.New(mw.rootPath, account.Address())
|
||||
if err != nil {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
err = anytype.Run()
|
||||
if err != nil {
|
||||
if err == core.ErrRepoCorrupted {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_LOCAL_REPO_EXISTS_BUT_CORRUPTED, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_LOCAL_REPO_EXISTS_BUT_CORRUPTED, err)
|
||||
}
|
||||
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_FAILED_TO_RUN_NODE, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_FAILED_TO_RUN_NODE, err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
@ -165,7 +165,7 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
}()
|
||||
|
||||
if shouldCancel {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -190,7 +190,7 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
// todo: add goroutine to query multiple accounts at once
|
||||
account, err := core.WalletAccountAt(mw.mnemonic, index, "")
|
||||
if err != nil {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_WALLET_RECOVER_NOT_PERFORMED, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_WALLET_RECOVER_NOT_PERFORMED, err)
|
||||
}
|
||||
|
||||
var ctx context.Context
|
||||
|
@ -199,20 +199,20 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
|
||||
if err != nil || contact == nil {
|
||||
if index == 0 {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NO_ACCOUNTS_FOUND, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_NO_ACCOUNTS_FOUND, err)
|
||||
}
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
if contact.Name == "" {
|
||||
if index == 0 {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NO_ACCOUNTS_FOUND, err)
|
||||
return response(pb.RpcAccountRecoverResponseError_NO_ACCOUNTS_FOUND, err)
|
||||
}
|
||||
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
newAcc := &pb.Model_Account{Id: account.Address(), Name: contact.Name}
|
||||
newAcc := &pb.ModelAccount{Id: account.Address(), Name: contact.Name}
|
||||
|
||||
if contact.Avatar != "" {
|
||||
newAcc.Avatar = getAvatarFromString(contact.Avatar)
|
||||
|
@ -222,15 +222,15 @@ func (mw *Middleware) AccountRecover(_ *pb.Rpc_Account_Recover_Request) *pb.Rpc_
|
|||
mw.localAccounts = append(mw.localAccounts, newAcc)
|
||||
|
||||
if shouldCancel {
|
||||
return response(pb.Rpc_Account_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcAccountRecoverResponseError_NULL, nil)
|
||||
}
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
func (mw *Middleware) AccountSelect(req *pb.Rpc_Account_Select_Request) *pb.Rpc_Account_Select_Response {
|
||||
response := func(account *pb.Model_Account, code pb.Rpc_Account_Select_Response_Error_Code, err error) *pb.Rpc_Account_Select_Response {
|
||||
m := &pb.Rpc_Account_Select_Response{Account: account, Error: &pb.Rpc_Account_Select_Response_Error{Code: code}}
|
||||
func (mw *Middleware) AccountSelect(req *pb.RpcAccountSelectRequest) *pb.RpcAccountSelectResponse {
|
||||
response := func(account *pb.ModelAccount, code pb.RpcAccountSelectResponseErrorCode, err error) *pb.RpcAccountSelectResponse {
|
||||
m := &pb.RpcAccountSelectResponse{Account: account, Error: &pb.RpcAccountSelectResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -249,23 +249,23 @@ func (mw *Middleware) AccountSelect(req *pb.Rpc_Account_Select_Request) *pb.Rpc_
|
|||
|
||||
if _, err := os.Stat(filepath.Join(mw.rootPath, req.Id)); os.IsNotExist(err) {
|
||||
if mw.mnemonic == "" {
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_LOCAL_REPO_NOT_EXISTS_AND_MNEMONIC_NOT_SET, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_LOCAL_REPO_NOT_EXISTS_AND_MNEMONIC_NOT_SET, err)
|
||||
}
|
||||
|
||||
account, err := core.WalletAccountAt(mw.mnemonic, len(mw.localAccounts), "")
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
err = core.WalletInitRepo(mw.rootPath, account.Seed())
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
}
|
||||
}
|
||||
|
||||
anytype, err := core.New(mw.rootPath, req.Id)
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
mw.Anytype = anytype
|
||||
|
@ -273,22 +273,22 @@ func (mw *Middleware) AccountSelect(req *pb.Rpc_Account_Select_Request) *pb.Rpc_
|
|||
err = mw.Run()
|
||||
if err != nil {
|
||||
if err == core.ErrRepoCorrupted {
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_LOCAL_REPO_EXISTS_BUT_CORRUPTED, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_LOCAL_REPO_EXISTS_BUT_CORRUPTED, err)
|
||||
}
|
||||
|
||||
return response(nil, pb.Rpc_Account_Select_Response_Error_FAILED_TO_RUN_NODE, err)
|
||||
return response(nil, pb.RpcAccountSelectResponseError_FAILED_TO_RUN_NODE, err)
|
||||
}
|
||||
|
||||
acc := &pb.Model_Account{Id: req.Id}
|
||||
acc := &pb.ModelAccount{Id: req.Id}
|
||||
|
||||
acc.Name, err = mw.Anytype.Textile.Name()
|
||||
if err != nil {
|
||||
return response(acc, pb.Rpc_Account_Select_Response_Error_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
return response(acc, pb.RpcAccountSelectResponseError_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
}
|
||||
|
||||
avatarHashOrColor, err := mw.Anytype.Textile.Avatar()
|
||||
if err != nil {
|
||||
return response(acc, pb.Rpc_Account_Select_Response_Error_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
return response(acc, pb.RpcAccountSelectResponseError_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
}
|
||||
|
||||
if acc.Name == "" && avatarHashOrColor == "" {
|
||||
|
@ -304,7 +304,7 @@ func (mw *Middleware) AccountSelect(req *pb.Rpc_Account_Select_Request) *pb.Rpc_
|
|||
|
||||
contact, err := anytype.AccountRequestStoredContact(context.Background(), req.Id)
|
||||
if err != nil {
|
||||
return response(acc, pb.Rpc_Account_Select_Response_Error_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
return response(acc, pb.RpcAccountSelectResponseError_FAILED_TO_FIND_ACCOUNT_INFO, err)
|
||||
}
|
||||
acc.Name = contact.Name
|
||||
avatarHashOrColor = contact.Avatar
|
||||
|
@ -314,13 +314,13 @@ func (mw *Middleware) AccountSelect(req *pb.Rpc_Account_Select_Request) *pb.Rpc_
|
|||
acc.Avatar = getAvatarFromString(avatarHashOrColor)
|
||||
}
|
||||
|
||||
return response(acc, pb.Rpc_Account_Select_Response_Error_NULL, nil)
|
||||
return response(acc, pb.RpcAccountSelectResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
func getAvatarFromString(avatarHashOrColor string) *pb.Model_Account_Avatar {
|
||||
func getAvatarFromString(avatarHashOrColor string) *pb.ModelAccountAvatar {
|
||||
if strings.HasPrefix(avatarHashOrColor, "#") {
|
||||
return &pb.Model_Account_Avatar{&pb.Model_Account_Avatar_Color{avatarHashOrColor}}
|
||||
return &pb.ModelAccountAvatar{&pb.ModelAccountAvatarAvatarOfColor{avatarHashOrColor}}
|
||||
} else {
|
||||
return &pb.Model_Account_Avatar{&pb.Model_Account_Avatar_Image{&pb.Model_Image{avatarHashOrColor, avatarSizes}}}
|
||||
return &pb.ModelAccountAvatar{&pb.ModelAccountAvatarAvatarOfImage{&pb.ModelImage{avatarHashOrColor, avatarSizes}}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
func createWallet(t *testing.T) *Middleware {
|
||||
mw := &Middleware{}
|
||||
rootPath := os.TempDir()
|
||||
resp := mw.WalletCreate(&pb.Rpc_Wallet_Create_Request{RootPath: rootPath})
|
||||
require.Equal(t, pb.Rpc_Wallet_Create_Response_Error_NULL, resp.Error.Code, resp.Error.Code, "WalletCreate error should be 0")
|
||||
resp := mw.WalletCreate(&pb.RpcWalletCreateRequest{RootPath: rootPath})
|
||||
require.Equal(t, pb.RpcWalletCreateResponseError_NULL, resp.Error.Code, resp.Error.Code, "WalletCreate error should be 0")
|
||||
require.Equal(t, 12, len(strings.Split(resp.Mnemonic, " ")), "WalletCreate should return 12 words")
|
||||
return mw
|
||||
}
|
||||
|
@ -22,37 +22,37 @@ func createWallet(t *testing.T) *Middleware {
|
|||
func recoverWallet(t *testing.T, mnemonic string) *Middleware {
|
||||
mw := &Middleware{}
|
||||
rootPath := os.TempDir()
|
||||
resp := mw.WalletRecover(&pb.Rpc_Wallet_Recover_Request{RootPath: rootPath, Mnemonic: mnemonic})
|
||||
require.Equal(t, pb.Rpc_Wallet_Recover_Response_Error_NULL, resp.Error.Code, "WalletRecover error should be 0")
|
||||
resp := mw.WalletRecover(&pb.RpcWalletRecoverRequest{RootPath: rootPath, Mnemonic: mnemonic})
|
||||
require.Equal(t, pb.RpcWalletRecoverResponseError_NULL, resp.Error.Code, "WalletRecover error should be 0")
|
||||
return mw
|
||||
}
|
||||
|
||||
func Test_AccountCreate(t *testing.T) {
|
||||
func TestAccountCreate(t *testing.T) {
|
||||
mw := createWallet(t)
|
||||
|
||||
accountCreateResp := mw.AccountCreate(&pb.Rpc_Account_Create_Request{Name: "name_test", Avatar: &pb.Rpc_Account_Create_Request_AvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_test", accountCreateResp.Account.Name, "AccountCreate_Response has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
accountCreateResp := mw.AccountCreate(&pb.RpcAccountCreateRequest{Name: "name_test", Avatar: &pb.RpcAccountCreateRequestAvatarOfAvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_test", accountCreateResp.Account.Name, "AccountCreateResponse has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
|
||||
imageGetBlobResp := mw.ImageGetBlob(&pb.Rpc_Image_Get_Blob_Request{Id: accountCreateResp.Account.Avatar.GetImage().Id, Size_: pb.Model_Image_SMALL})
|
||||
require.Equal(t, pb.Rpc_Image_Get_Blob_Response_Error_NULL, imageGetBlobResp.Error.Code, "ImageGetBlob_Response contains error: %+v", imageGetBlobResp.Error)
|
||||
imageGetBlobResp := mw.ImageGetBlob(&pb.RpcImageGetBlobRequest{Id: accountCreateResp.Account.Avatar.GetImage().Id, Size_: pb.ModelImage_SMALL})
|
||||
require.Equal(t, pb.RpcImageGetBlobResponseError_NULL, imageGetBlobResp.Error.Code, "ImageGetBlobResponse contains error: %+v", imageGetBlobResp.Error)
|
||||
require.True(t, len(imageGetBlobResp.Blob) > 0, "ava size should be greater than 0")
|
||||
|
||||
err := mw.Stop()
|
||||
require.NoError(t, err, "failed to stop mw")
|
||||
}
|
||||
|
||||
func Test_AccountRecover_LocalWithoutRestart(t *testing.T) {
|
||||
func TestAccountRecoverLocalWithoutRestart(t *testing.T) {
|
||||
mw := createWallet(t)
|
||||
|
||||
accountCreateResp := mw.AccountCreate(&pb.Rpc_Account_Create_Request{Name: "name_to_test_recover", Avatar: &pb.Rpc_Account_Create_Request_AvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_to_test_recover", accountCreateResp.Account.Name, "AccountCreate_Response has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
accountCreateResp := mw.AccountCreate(&pb.RpcAccountCreateRequest{Name: "name_to_test_recover", Avatar: &pb.RpcAccountCreateRequestAvatarOfAvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_to_test_recover", accountCreateResp.Account.Name, "AccountCreateResponse has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
|
||||
err := mw.Stop()
|
||||
require.NoError(t, err, "failed to stop node")
|
||||
|
||||
var accountCh = make(chan *pb.Model_Account, 10)
|
||||
var accountCh = make(chan *pb.ModelAccount, 10)
|
||||
mw.SendEvent = func(event *pb.Event) {
|
||||
if aa, ok := event.Message.(*pb.Event_AccountShow); ok {
|
||||
if aa, ok := event.Message.(*pb.EventMessageOfAccountShow); ok {
|
||||
if aa.AccountShow.Index != 0 {
|
||||
return
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ func Test_AccountRecover_LocalWithoutRestart(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
walletRecoverResp := mw.WalletRecover(&pb.Rpc_Wallet_Recover_Request{RootPath: mw.rootPath, Mnemonic: mw.mnemonic})
|
||||
require.Equal(t, pb.Rpc_Wallet_Recover_Response_Error_NULL, walletRecoverResp.Error.Code, "WalletRecover_Response contains error: %+v", walletRecoverResp.Error)
|
||||
walletRecoverResp := mw.WalletRecover(&pb.RpcWalletRecoverRequest{RootPath: mw.rootPath, Mnemonic: mw.mnemonic})
|
||||
require.Equal(t, pb.RpcWalletRecoverResponseError_NULL, walletRecoverResp.Error.Code, "WalletRecoverResponse contains error: %+v", walletRecoverResp.Error)
|
||||
|
||||
accountRecoverResp := mw.AccountRecover(&pb.Rpc_Account_Recover_Request{})
|
||||
require.Equal(t, pb.Rpc_Account_Recover_Response_Error_NULL, accountRecoverResp.Error.Code, "AccountRecover_Response contains error: %+v", accountRecoverResp.Error)
|
||||
accountRecoverResp := mw.AccountRecover(&pb.RpcAccountRecoverRequest{})
|
||||
require.Equal(t, pb.RpcAccountRecoverResponseError_NULL, accountRecoverResp.Error.Code, "AccountRecoverResponse contains error: %+v", accountRecoverResp.Error)
|
||||
|
||||
var account *pb.Model_Account
|
||||
var account *pb.ModelAccount
|
||||
select {
|
||||
case account = <-accountCh:
|
||||
break
|
||||
|
@ -80,11 +80,11 @@ func Test_AccountRecover_LocalWithoutRestart(t *testing.T) {
|
|||
require.NoError(t, err, "failed to stop mw")
|
||||
}
|
||||
|
||||
func Test_AccountRecover_LocalAfterRestart(t *testing.T) {
|
||||
func TestAccountRecoverLocalAfterRestart(t *testing.T) {
|
||||
mw := createWallet(t)
|
||||
|
||||
accountCreateResp := mw.AccountCreate(&pb.Rpc_Account_Create_Request{Name: "name_to_test_recover", Avatar: &pb.Rpc_Account_Create_Request_AvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_to_test_recover", accountCreateResp.Account.Name, "AccountCreate_Response has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
accountCreateResp := mw.AccountCreate(&pb.RpcAccountCreateRequest{Name: "name_to_test_recover", Avatar: &pb.RpcAccountCreateRequestAvatarOfAvatarLocalPath{"testdata/pic1.jpg"}})
|
||||
require.Equal(t, "name_to_test_recover", accountCreateResp.Account.Name, "AccountCreateResponse has account with wrong name '%s'", accountCreateResp.Account.Name)
|
||||
|
||||
err := mw.Stop()
|
||||
require.NoError(t, err, "failed to stop node")
|
||||
|
@ -94,9 +94,9 @@ func Test_AccountRecover_LocalAfterRestart(t *testing.T) {
|
|||
// reset singleton to emulate restart
|
||||
mw = &Middleware{}
|
||||
|
||||
var accountCh = make(chan *pb.Model_Account, 10)
|
||||
var accountCh = make(chan *pb.ModelAccount, 10)
|
||||
mw.SendEvent = func(event *pb.Event) {
|
||||
if aa, ok := event.Message.(*pb.Event_AccountShow); ok {
|
||||
if aa, ok := event.Message.(*pb.EventMessageOfAccountShow); ok {
|
||||
if aa.AccountShow.Index != 0 {
|
||||
return
|
||||
}
|
||||
|
@ -105,13 +105,13 @@ func Test_AccountRecover_LocalAfterRestart(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
walletRecoverResp := mw.WalletRecover(&pb.Rpc_Wallet_Recover_Request{RootPath: rootPath, Mnemonic: mnemonic})
|
||||
require.Equal(t, pb.Rpc_Wallet_Recover_Response_Error_NULL, walletRecoverResp.Error.Code, "WalletRecover_Response contains error: %+v", walletRecoverResp.Error)
|
||||
walletRecoverResp := mw.WalletRecover(&pb.RpcWalletRecoverRequest{RootPath: rootPath, Mnemonic: mnemonic})
|
||||
require.Equal(t, pb.RpcWalletRecoverResponseError_NULL, walletRecoverResp.Error.Code, "WalletRecoverResponse contains error: %+v", walletRecoverResp.Error)
|
||||
|
||||
accountRecoverResp := mw.AccountRecover(&pb.Rpc_Account_Recover_Request{})
|
||||
require.Equal(t, pb.Rpc_Account_Recover_Response_Error_NULL, accountRecoverResp.Error.Code, "AccountRecover_Response contains error: %+v", accountRecoverResp.Error)
|
||||
accountRecoverResp := mw.AccountRecover(&pb.RpcAccountRecoverRequest{})
|
||||
require.Equal(t, pb.RpcAccountRecoverResponseError_NULL, accountRecoverResp.Error.Code, "AccountRecoverResponse contains error: %+v", accountRecoverResp.Error)
|
||||
|
||||
var account *pb.Model_Account
|
||||
var account *pb.ModelAccount
|
||||
select {
|
||||
case account = <-accountCh:
|
||||
break
|
||||
|
@ -124,19 +124,19 @@ func Test_AccountRecover_LocalAfterRestart(t *testing.T) {
|
|||
err = mw.Stop()
|
||||
}
|
||||
|
||||
func Test_AccountRecover_RemoteNotExisting(t *testing.T) {
|
||||
func TestAccountRecoverRemoteNotExisting(t *testing.T) {
|
||||
mw := recoverWallet(t, "limit oxygen february destroy subway toddler umbrella nose praise shield afford eager")
|
||||
require.Equal(t, len(mw.localAccounts), 0, "localAccounts should be empty, instead got length = %d", len(mw.localAccounts))
|
||||
|
||||
var account *pb.Model_Account
|
||||
var account *pb.ModelAccount
|
||||
mw.SendEvent = func(event *pb.Event) {
|
||||
if aa, ok := event.Message.(*pb.Event_AccountShow); ok {
|
||||
if aa, ok := event.Message.(*pb.EventMessageOfAccountShow); ok {
|
||||
account = aa.AccountShow.Account
|
||||
}
|
||||
}
|
||||
|
||||
accountRecoverResp := mw.AccountRecover(&pb.Rpc_Account_Recover_Request{})
|
||||
require.Equal(t, pb.Rpc_Account_Recover_Response_Error_NO_ACCOUNTS_FOUND, accountRecoverResp.Error.Code, "AccountRecover_Response contains error: %+v", accountRecoverResp.Error)
|
||||
accountRecoverResp := mw.AccountRecover(&pb.RpcAccountRecoverRequest{})
|
||||
require.Equal(t, pb.RpcAccountRecoverResponseError_NO_ACCOUNTS_FOUND, accountRecoverResp.Error.Code, "AccountRecoverResponse contains error: %+v", accountRecoverResp.Error)
|
||||
|
||||
require.Nil(t, account, "account shouldn't be recovered")
|
||||
|
||||
|
@ -144,13 +144,13 @@ func Test_AccountRecover_RemoteNotExisting(t *testing.T) {
|
|||
require.NoError(t, err, "failed to stop mw")
|
||||
}
|
||||
|
||||
func Test_RecoverRemoteExisting(t *testing.T) {
|
||||
func TestRecoverRemoteExisting(t *testing.T) {
|
||||
mw := recoverWallet(t, "input blame switch simple fatigue fragile grab goose unusual identify abuse use")
|
||||
require.Equal(t, len(mw.localAccounts), 0, "localAccounts should be empty, instead got length = %d", len(mw.localAccounts))
|
||||
|
||||
var accountCh = make(chan *pb.Model_Account, 10)
|
||||
var accountCh = make(chan *pb.ModelAccount, 10)
|
||||
mw.SendEvent = func(event *pb.Event) {
|
||||
if aa, ok := event.Message.(*pb.Event_AccountShow); ok {
|
||||
if aa, ok := event.Message.(*pb.EventMessageOfAccountShow); ok {
|
||||
if aa.AccountShow.Index != 0 {
|
||||
return
|
||||
}
|
||||
|
@ -159,10 +159,10 @@ func Test_RecoverRemoteExisting(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
accountRecoverResp := mw.AccountRecover(&pb.Rpc_Account_Recover_Request{})
|
||||
require.Equal(t, pb.Rpc_Account_Recover_Response_Error_NULL, accountRecoverResp.Error.Code, "AccountRecover_Response contains error: %+v", accountRecoverResp.Error)
|
||||
accountRecoverResp := mw.AccountRecover(&pb.RpcAccountRecoverRequest{})
|
||||
require.Equal(t, pb.RpcAccountRecoverResponseError_NULL, accountRecoverResp.Error.Code, "AccountRecoverResponse contains error: %+v", accountRecoverResp.Error)
|
||||
|
||||
var account *pb.Model_Account
|
||||
var account *pb.ModelAccount
|
||||
select {
|
||||
case account = <-accountCh:
|
||||
break
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"github.com/anytypeio/go-anytype-middleware/pb"
|
||||
)
|
||||
|
||||
func (mw *Middleware) BlockCreate(req *pb.Rpc_Block_Create_Request) *pb.Rpc_Block_Create_Response {
|
||||
response := func(code pb.Rpc_Block_Create_Response_Error_Code, err error) *pb.Rpc_Block_Create_Response {
|
||||
m := &pb.Rpc_Block_Create_Response{Error: &pb.Rpc_Block_Create_Response_Error{Code: code}}
|
||||
func (mw *Middleware) BlockCreate(req *pb.RpcBlockCreateRequest) *pb.RpcBlockCreateResponse {
|
||||
response := func(code pb.RpcBlockCreateResponseErrorCode, err error) *pb.RpcBlockCreateResponse {
|
||||
m := &pb.RpcBlockCreateResponse{Error: &pb.RpcBlockCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -14,20 +14,20 @@ func (mw *Middleware) BlockCreate(req *pb.Rpc_Block_Create_Request) *pb.Rpc_Bloc
|
|||
return m
|
||||
}
|
||||
|
||||
/*block := &pb.Model_Block{} // TODO
|
||||
/*block := &pb.ModelBlock{} // TODO
|
||||
|
||||
m := &pb.Event{Message: &pb.Event_Block_Create{&pb.Rpc_Block_Create{Block: block}}}
|
||||
m := &pb.Event{Message: &pb.EventBlockCreate{&pb.RpcBlockCreate{Block: block}}}
|
||||
|
||||
if mw.SendEvent != nil {
|
||||
mw.SendEvent(m)
|
||||
}*/
|
||||
|
||||
return response(pb.Rpc_Block_Create_Response_Error_NULL, nil)
|
||||
return response(pb.RpcBlockCreateResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
func (mw *Middleware) BlockOpen(req *pb.Rpc_Block_Open_Request) *pb.Rpc_Block_Open_Response {
|
||||
response := func(code pb.Rpc_Block_Open_Response_Error_Code, err error) *pb.Rpc_Block_Open_Response {
|
||||
m := &pb.Rpc_Block_Open_Response{Error: &pb.Rpc_Block_Open_Response_Error{Code: code}}
|
||||
func (mw *Middleware) BlockOpen(req *pb.RpcBlockOpenRequest) *pb.RpcBlockOpenResponse {
|
||||
response := func(code pb.RpcBlockOpenResponseErrorCode, err error) *pb.RpcBlockOpenResponse {
|
||||
m := &pb.RpcBlockOpenResponse{Error: &pb.RpcBlockOpenResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -35,20 +35,20 @@ func (mw *Middleware) BlockOpen(req *pb.Rpc_Block_Open_Request) *pb.Rpc_Block_Op
|
|||
return m
|
||||
}
|
||||
|
||||
/*block := &pb.Model_Block{} // TODO
|
||||
/*block := &pb.ModelBlock{} // TODO
|
||||
|
||||
m := &pb.Event{Message: &pb.Event_Block_Show{&pb.Rpc_Block_Show{Block: block}}}
|
||||
m := &pb.Event{Message: &pb.EventBlockShow{&pb.RpcBlockShow{Block: block}}}
|
||||
|
||||
if mw.SendEvent != nil {
|
||||
mw.SendEvent(m)
|
||||
}*/
|
||||
|
||||
return response(pb.Rpc_Block_Open_Response_Error_NULL, nil)
|
||||
return response(pb.RpcBlockOpenResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
func (mw *Middleware) BlockUpdate(req *pb.Rpc_Block_Update_Request) *pb.Rpc_Block_Update_Response {
|
||||
response := func(code pb.Rpc_Block_Update_Response_Error_Code, err error) *pb.Rpc_Block_Update_Response {
|
||||
m := &pb.Rpc_Block_Update_Response{Error: &pb.Rpc_Block_Update_Response_Error{Code: code}}
|
||||
func (mw *Middleware) BlockUpdate(req *pb.RpcBlockUpdateRequest) *pb.RpcBlockUpdateResponse {
|
||||
response := func(code pb.RpcBlockUpdateResponseErrorCode, err error) *pb.RpcBlockUpdateResponse {
|
||||
m := &pb.RpcBlockUpdateResponse{Error: &pb.RpcBlockUpdateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ func (mw *Middleware) BlockUpdate(req *pb.Rpc_Block_Update_Request) *pb.Rpc_Bloc
|
|||
}
|
||||
|
||||
/*
|
||||
changes := &pb.Rpc_Block_Changes{} // TODO
|
||||
changes := &pb.RpcBlockChanges{} // TODO
|
||||
|
||||
m := &pb.Event{Message: &pb.Event_Block_Update{&pb.Rpc_Block_Update{changes}}}
|
||||
m := &pb.Event{Message: &pb.EventBlockUpdate{&pb.RpcBlockUpdate{changes}}}
|
||||
|
||||
if mw.SendEvent != nil {
|
||||
mw.SendEvent(m)
|
||||
}*/
|
||||
|
||||
return response(pb.Rpc_Block_Update_Response_Error_NULL, nil)
|
||||
return response(pb.RpcBlockUpdateResponseError_NULL, nil)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ type Middleware struct {
|
|||
pin string
|
||||
mnemonic string
|
||||
accountSearchCancel context.CancelFunc
|
||||
localAccounts []*pb.Model_Account
|
||||
localAccounts []*pb.ModelAccount
|
||||
SendEvent func(event *pb.Event)
|
||||
*libCore.Anytype
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"github.com/anytypeio/go-anytype-middleware/pb"
|
||||
)
|
||||
|
||||
func (mw *Middleware) BlockHistoryMove(req *pb.Rpc_Block_History_Move_Request) *pb.Rpc_Block_History_Move_Response {
|
||||
response := func(code pb.Rpc_Block_History_Move_Response_Error_Code, err error) *pb.Rpc_Block_History_Move_Response {
|
||||
m := &pb.Rpc_Block_History_Move_Response{Error: &pb.Rpc_Block_History_Move_Response_Error{Code: code}}
|
||||
func (mw *Middleware) BlockHistoryMove(req *pb.RpcBlockHistoryMoveRequest) *pb.RpcBlockHistoryMoveResponse {
|
||||
response := func(code pb.RpcBlockHistoryMoveResponseErrorCode, err error) *pb.RpcBlockHistoryMoveResponse {
|
||||
m := &pb.RpcBlockHistoryMoveResponse{Error: &pb.RpcBlockHistoryMoveResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ func (mw *Middleware) BlockHistoryMove(req *pb.Rpc_Block_History_Move_Request) *
|
|||
|
||||
// TODO
|
||||
|
||||
return response(pb.Rpc_Block_History_Move_Response_Error_NULL, nil)
|
||||
return response(pb.RpcBlockHistoryMoveResponseError_NULL, nil)
|
||||
}
|
||||
|
|
40
core/ipfs.go
40
core/ipfs.go
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/textileio/go-textile/ipfs"
|
||||
)
|
||||
|
||||
func (mw *Middleware) IpfsGetFile(req *pb.Rpc_Ipfs_Get_File_Request) *pb.Rpc_Ipfs_Get_File_Response {
|
||||
response := func(data []byte, media string, name string, code pb.Rpc_Ipfs_Get_File_Response_Error_Code, err error) *pb.Rpc_Ipfs_Get_File_Response {
|
||||
m := &pb.Rpc_Ipfs_Get_File_Response{Data: data, Media: media, Error: &pb.Rpc_Ipfs_Get_File_Response_Error{Code: code}}
|
||||
func (mw *Middleware) IpfsGetFile(req *pb.RpcIpfsGetFileRequest) *pb.RpcIpfsGetFileResponse {
|
||||
response := func(data []byte, media string, name string, code pb.RpcIpfsGetFileResponseErrorCode, err error) *pb.RpcIpfsGetFileResponse {
|
||||
m := &pb.RpcIpfsGetFileResponse{Data: data, Media: media, Error: &pb.RpcIpfsGetFileResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -22,25 +22,25 @@ func (mw *Middleware) IpfsGetFile(req *pb.Rpc_Ipfs_Get_File_Request) *pb.Rpc_Ipf
|
|||
reader, info, err := mw.Anytype.Textile.Node().FileContent(req.Id)
|
||||
if err != nil {
|
||||
if err == core2.ErrFileNotFound {
|
||||
return response(nil, "", "", pb.Rpc_Ipfs_Get_File_Response_Error_NOT_FOUND, err)
|
||||
return response(nil, "", "", pb.RpcIpfsGetFileResponseError_NOT_FOUND, err)
|
||||
}
|
||||
|
||||
return response(nil, "", "", pb.Rpc_Ipfs_Get_File_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, "", "", pb.RpcIpfsGetFileResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(reader)
|
||||
if err != nil {
|
||||
return response(nil, "", "", pb.Rpc_Ipfs_Get_File_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, "", "", pb.RpcIpfsGetFileResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
return response(data, info.Media, info.Name, pb.Rpc_Ipfs_Get_File_Response_Error_NULL, nil)
|
||||
return response(data, info.Media, info.Name, pb.RpcIpfsGetFileResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
/*
|
||||
//exportMobile IpfsGetData
|
||||
func IpfsGetData(b []byte) []byte {
|
||||
response := func(data []byte, code pb.Rpc_Ipfs_GetData_Response_Error_Code, err error) []byte {
|
||||
m := &pb.Rpc_Ipfs_GetData_Response{Data: data, Error: &pb.Rpc_Ipfs_GetData_Response_Error{Code: code}}
|
||||
response := func(data []byte, code pb.RpcIpfsGetDataResponseErrorCode, err error) []byte {
|
||||
m := &pb.RpcIpfsGetDataResponse{Data: data, Error: &pb.RpcIpfsGetDataResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -48,29 +48,29 @@ func IpfsGetData(b []byte) []byte {
|
|||
return Marshal(m)
|
||||
}
|
||||
|
||||
var q pb.Rpc_Ipfs_GetData_Request
|
||||
var q pb.RpcIpfsGetDataRequest
|
||||
err := proto.Unmarshal(b, &q)
|
||||
if err != nil {
|
||||
return response(nil, pb.Rpc_Ipfs_GetData_Response_Error_BAD_INPUT, err)
|
||||
return response(nil, pb.RpcIpfsGetDataResponseError_BAD_INPUT, err)
|
||||
}
|
||||
|
||||
data, err := ipfs.DataAtPath(mw.Anytype.Textile.Node().Ipfs(), q.Id)
|
||||
if err != nil {
|
||||
if err == core2.ErrFileNotFound {
|
||||
return response(nil, pb.Rpc_Ipfs_GetData_Response_Error_NOT_FOUND, err)
|
||||
return response(nil, pb.RpcIpfsGetDataResponseError_NOT_FOUND, err)
|
||||
}
|
||||
|
||||
return response(nil, pb.Rpc_Ipfs_GetData_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcIpfsGetDataResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
return response(data, pb.Rpc_Ipfs_GetData_Response_Error_NULL, nil)
|
||||
return response(data, pb.RpcIpfsGetDataResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
func (mw *Middleware) ImageGetBlob(req *pb.Rpc_Image_Get_Blob_Request) *pb.Rpc_Image_Get_Blob_Response {
|
||||
response := func(blob []byte, code pb.Rpc_Image_Get_Blob_Response_Error_Code, err error) *pb.Rpc_Image_Get_Blob_Response {
|
||||
m := &pb.Rpc_Image_Get_Blob_Response{Blob: blob, Error: &pb.Rpc_Image_Get_Blob_Response_Error{Code: code}}
|
||||
func (mw *Middleware) ImageGetBlob(req *pb.RpcImageGetBlobRequest) *pb.RpcImageGetBlobResponse {
|
||||
response := func(blob []byte, code pb.RpcImageGetBlobResponseErrorCode, err error) *pb.RpcImageGetBlobResponse {
|
||||
m := &pb.RpcImageGetBlobResponse{Blob: blob, Error: &pb.RpcImageGetBlobResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -81,11 +81,11 @@ func (mw *Middleware) ImageGetBlob(req *pb.Rpc_Image_Get_Blob_Request) *pb.Rpc_I
|
|||
data, err := ipfs.DataAtPath(mw.Anytype.Textile.Node().Ipfs(), req.Id+"/0/"+strings.ToLower(req.GetSize_().String())+"/content")
|
||||
if err != nil {
|
||||
if err == core2.ErrFileNotFound {
|
||||
return response(nil, pb.Rpc_Image_Get_Blob_Response_Error_NOT_FOUND, err)
|
||||
return response(nil, pb.RpcImageGetBlobResponseError_NOT_FOUND, err)
|
||||
}
|
||||
|
||||
return response(nil, pb.Rpc_Image_Get_Blob_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response(nil, pb.RpcImageGetBlobResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
return response(data, pb.Rpc_Image_Get_Blob_Response_Error_NULL, nil)
|
||||
return response(data, pb.RpcImageGetBlobResponseError_NULL, nil)
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"github.com/anytypeio/go-anytype-middleware/pb"
|
||||
)
|
||||
|
||||
func (mw *Middleware) LogSend(req *pb.Rpc_Log_Send_Request) *pb.Rpc_Log_Send_Response {
|
||||
response := func(code pb.Rpc_Log_Send_Response_Error_Code, err error) *pb.Rpc_Log_Send_Response {
|
||||
m := &pb.Rpc_Log_Send_Response{Error: &pb.Rpc_Log_Send_Response_Error{Code: code}}
|
||||
func (mw *Middleware) LogSend(req *pb.RpcLogSendRequest) *pb.RpcLogSendResponse {
|
||||
response := func(code pb.RpcLogSendResponseErrorCode, err error) *pb.RpcLogSendResponse {
|
||||
m := &pb.RpcLogSendResponse{Error: &pb.RpcLogSendResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -15,19 +15,19 @@ func (mw *Middleware) LogSend(req *pb.Rpc_Log_Send_Request) *pb.Rpc_Log_Send_Res
|
|||
}
|
||||
|
||||
switch req.Level {
|
||||
case pb.Rpc_Log_Send_Request_FATAL:
|
||||
case pb.RpcLogSendRequest_FATAL:
|
||||
log.Fatal(req.Message)
|
||||
case pb.Rpc_Log_Send_Request_PANIC:
|
||||
case pb.RpcLogSendRequest_PANIC:
|
||||
log.Panic(req.Message)
|
||||
case pb.Rpc_Log_Send_Request_DEBUG:
|
||||
case pb.RpcLogSendRequest_DEBUG:
|
||||
log.Debug(req.Message)
|
||||
case pb.Rpc_Log_Send_Request_INFO:
|
||||
case pb.RpcLogSendRequest_INFO:
|
||||
log.Info(req.Message)
|
||||
case pb.Rpc_Log_Send_Request_WARNING:
|
||||
case pb.RpcLogSendRequest_WARNING:
|
||||
log.Warning(req.Message)
|
||||
case pb.Rpc_Log_Send_Request_ERROR:
|
||||
case pb.RpcLogSendRequest_ERROR:
|
||||
log.Error(req.Message)
|
||||
}
|
||||
|
||||
return response(pb.Rpc_Log_Send_Response_Error_NULL, nil)
|
||||
return response(pb.RpcLogSendResponseError_NULL, nil)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_Log(t *testing.T) {
|
||||
func TestLog(t *testing.T) {
|
||||
mw := Middleware{}
|
||||
file, err := ioutil.TempFile("", "testlog")
|
||||
require.NoError(t, err)
|
||||
|
@ -21,13 +21,13 @@ func Test_Log(t *testing.T) {
|
|||
os.Setenv("GOLOG_FILE", file.Name())
|
||||
logger.SetupLogging()
|
||||
logger.SetDebugLogging()
|
||||
for level, levelText := range map[pb.Rpc_Log_Send_Request_Level]string{
|
||||
pb.Rpc_Log_Send_Request_ERROR: "[31mERROR",
|
||||
pb.Rpc_Log_Send_Request_WARNING: "[33mWARNI",
|
||||
for level, levelText := range map[pb.RpcLogSendRequestLevel]string{
|
||||
pb.RpcLogSendRequest_ERROR: "[31mERROR",
|
||||
pb.RpcLogSendRequest_WARNING: "[33mWARNI",
|
||||
} {
|
||||
text := fmt.Sprintf("test_log_%s", time.Now().String())
|
||||
resp := mw.LogSend(&pb.Rpc_Log_Send_Request{Message: text, Level: level})
|
||||
require.Equal(t, pb.Rpc_Log_Send_Response_Error_NULL, resp.Error.Code, "LogSendResponse contains error: %+v", resp.Error)
|
||||
resp := mw.LogSend(&pb.RpcLogSendRequest{Message: text, Level: level})
|
||||
require.Equal(t, pb.RpcLogSendResponseError_NULL, resp.Error.Code, "LogSendResponse contains error: %+v", resp.Error)
|
||||
|
||||
b, err := ioutil.ReadFile(file.Name())
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
// Set by ldflags
|
||||
var GitCommit, GitBranch, GitState, GitSummary, BuildDate string
|
||||
|
||||
func (mw *Middleware) VersionGet(req *pb.Rpc_Version_Get_Request) *pb.Rpc_Version_Get_Response {
|
||||
response := func(version, details string, code pb.Rpc_Version_Get_Response_Error_Code, err error) *pb.Rpc_Version_Get_Response {
|
||||
m := &pb.Rpc_Version_Get_Response{Version: version, Error: &pb.Rpc_Version_Get_Response_Error{Code: code}}
|
||||
func (mw *Middleware) VersionGet(req *pb.RpcVersionGetRequest) *pb.RpcVersionGetResponse {
|
||||
response := func(version, details string, code pb.RpcVersionGetResponseErrorCode, err error) *pb.RpcVersionGetResponse {
|
||||
m := &pb.RpcVersionGetResponse{Version: version, Error: &pb.RpcVersionGetResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ func (mw *Middleware) VersionGet(req *pb.Rpc_Version_Get_Request) *pb.Rpc_Versio
|
|||
}
|
||||
|
||||
if len(GitSummary) == 0 {
|
||||
return response("", "", pb.Rpc_Version_Get_Response_Error_VERSION_IS_EMPTY, nil)
|
||||
return response("", "", pb.RpcVersionGetResponseError_VERSION_IS_EMPTY, nil)
|
||||
}
|
||||
|
||||
details := fmt.Sprintf("build on %s from %s at #%s(%s)", BuildDate, GitCommit, GitBranch, GitState)
|
||||
|
||||
return response(GitSummary, details, pb.Rpc_Version_Get_Response_Error_NULL, nil)
|
||||
return response(GitSummary, details, pb.RpcVersionGetResponseError_NULL, nil)
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
|
||||
const wordCount int = 12
|
||||
|
||||
func (mw *Middleware) WalletCreate(req *pb.Rpc_Wallet_Create_Request) *pb.Rpc_Wallet_Create_Response {
|
||||
response := func(mnemonic string, code pb.Rpc_Wallet_Create_Response_Error_Code, err error) *pb.Rpc_Wallet_Create_Response {
|
||||
m := &pb.Rpc_Wallet_Create_Response{Mnemonic: mnemonic, Error: &pb.Rpc_Wallet_Create_Response_Error{Code: code}}
|
||||
func (mw *Middleware) WalletCreate(req *pb.RpcWalletCreateRequest) *pb.RpcWalletCreateResponse {
|
||||
response := func(mnemonic string, code pb.RpcWalletCreateResponseErrorCode, err error) *pb.RpcWalletCreateResponse {
|
||||
m := &pb.RpcWalletCreateResponse{Mnemonic: mnemonic, Error: &pb.RpcWalletCreateResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -24,22 +24,22 @@ func (mw *Middleware) WalletCreate(req *pb.Rpc_Wallet_Create_Request) *pb.Rpc_Wa
|
|||
|
||||
err := os.MkdirAll(mw.rootPath, 0700)
|
||||
if err != nil {
|
||||
return response("", pb.Rpc_Wallet_Create_Response_Error_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
return response("", pb.RpcWalletCreateResponseError_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
}
|
||||
|
||||
mnemonic, err := core.WalletGenerateMnemonic(wordCount)
|
||||
if err != nil {
|
||||
return response("", pb.Rpc_Wallet_Create_Response_Error_UNKNOWN_ERROR, err)
|
||||
return response("", pb.RpcWalletCreateResponseError_UNKNOWN_ERROR, err)
|
||||
}
|
||||
|
||||
mw.mnemonic = mnemonic
|
||||
|
||||
return response(mnemonic, pb.Rpc_Wallet_Create_Response_Error_NULL, nil)
|
||||
return response(mnemonic, pb.RpcWalletCreateResponseError_NULL, nil)
|
||||
}
|
||||
|
||||
func (mw *Middleware) WalletRecover(req *pb.Rpc_Wallet_Recover_Request) *pb.Rpc_Wallet_Recover_Response {
|
||||
response := func(code pb.Rpc_Wallet_Recover_Response_Error_Code, err error) *pb.Rpc_Wallet_Recover_Response {
|
||||
m := &pb.Rpc_Wallet_Recover_Response{Error: &pb.Rpc_Wallet_Recover_Response_Error{Code: code}}
|
||||
func (mw *Middleware) WalletRecover(req *pb.RpcWalletRecoverRequest) *pb.RpcWalletRecoverResponse {
|
||||
response := func(code pb.RpcWalletRecoverResponseErrorCode, err error) *pb.RpcWalletRecoverResponse {
|
||||
m := &pb.RpcWalletRecoverResponse{Error: &pb.RpcWalletRecoverResponseError{Code: code}}
|
||||
if err != nil {
|
||||
m.Error.Description = err.Error()
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ func (mw *Middleware) WalletRecover(req *pb.Rpc_Wallet_Recover_Request) *pb.Rpc_
|
|||
|
||||
err := os.MkdirAll(mw.rootPath, 0700)
|
||||
if err != nil {
|
||||
return response(pb.Rpc_Wallet_Recover_Response_Error_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
return response(pb.RpcWalletRecoverResponseError_FAILED_TO_CREATE_LOCAL_REPO, err)
|
||||
}
|
||||
|
||||
// test if mnemonic is correct
|
||||
_, err = core.WalletAccountAt(req.Mnemonic, 0, "")
|
||||
if err != nil {
|
||||
return response(pb.Rpc_Wallet_Recover_Response_Error_BAD_INPUT, err)
|
||||
return response(pb.RpcWalletRecoverResponseError_BAD_INPUT, err)
|
||||
}
|
||||
|
||||
return response(pb.Rpc_Wallet_Recover_Response_Error_NULL, nil)
|
||||
return response(pb.RpcWalletRecoverResponseError_NULL, nil)
|
||||
}
|
||||
|
|
|
@ -10,24 +10,24 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_Unpack(t *testing.T) {
|
||||
b, _ := proto.Marshal(&pb.Rpc_Wallet_Recover_Response{})
|
||||
func TestUnpack(t *testing.T) {
|
||||
b, _ := proto.Marshal(&pb.RpcWalletRecoverResponse{})
|
||||
|
||||
var msg pb.Rpc_Wallet_Recover_Response
|
||||
var msg pb.RpcWalletRecoverResponse
|
||||
err := proto.Unmarshal(b, &msg)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func Test_EventHandler(t *testing.T) {
|
||||
func TestEventHandler(t *testing.T) {
|
||||
var eventReceived *pb.Event
|
||||
mw = &core.Middleware{}
|
||||
SetEventHandler(func(event *pb.Event) {
|
||||
eventReceived = event
|
||||
})
|
||||
|
||||
eventSent := &pb.Event{Message: &pb.Event_AccountShow{AccountShow: &pb.Event_Account_Show{Index: 0, Account: &pb.Model_Account{Id: "1", Name: "name"}}}}
|
||||
eventSent := &pb.Event{Message: &pb.EventMessageOfAccountShow{AccountShow: &pb.EventAccountShow{Index: 0, Account: &pb.ModelAccount{Id: "1", Name: "name"}}}}
|
||||
mw.SendEvent(eventSent)
|
||||
|
||||
require.Equal(t, eventSent, eventReceived, "eventReceived not equal to eventSent: %s %s", eventSent, eventReceived)
|
||||
|
|
|
@ -58,18 +58,18 @@ var fileDescriptor_a0b84a42fa06f626 = []byte{
|
|||
var clientCommandsHandler ClientCommandsHandler
|
||||
|
||||
type ClientCommandsHandler interface {
|
||||
WalletCreate(*pb.Rpc_Wallet_Create_Request) *pb.Rpc_Wallet_Create_Response
|
||||
WalletRecover(*pb.Rpc_Wallet_Recover_Request) *pb.Rpc_Wallet_Recover_Response
|
||||
AccountRecover(*pb.Rpc_Account_Recover_Request) *pb.Rpc_Account_Recover_Response
|
||||
AccountCreate(*pb.Rpc_Account_Create_Request) *pb.Rpc_Account_Create_Response
|
||||
AccountSelect(*pb.Rpc_Account_Select_Request) *pb.Rpc_Account_Select_Response
|
||||
ImageGetBlob(*pb.Rpc_Image_Get_Blob_Request) *pb.Rpc_Image_Get_Blob_Response
|
||||
VersionGet(*pb.Rpc_Version_Get_Request) *pb.Rpc_Version_Get_Response
|
||||
LogSend(*pb.Rpc_Log_Send_Request) *pb.Rpc_Log_Send_Response
|
||||
BlockOpen(*pb.Rpc_Block_Open_Request) *pb.Rpc_Block_Open_Response
|
||||
BlockCreate(*pb.Rpc_Block_Create_Request) *pb.Rpc_Block_Create_Response
|
||||
BlockUpdate(*pb.Rpc_Block_Update_Request) *pb.Rpc_Block_Update_Response
|
||||
BlockHistoryMove(*pb.Rpc_Block_History_Move_Request) *pb.Rpc_Block_History_Move_Response
|
||||
WalletCreate(*pb.RpcWalletCreateRequest) *pb.RpcWalletCreateResponse
|
||||
WalletRecover(*pb.RpcWalletRecoverRequest) *pb.RpcWalletRecoverResponse
|
||||
AccountRecover(*pb.RpcAccountRecoverRequest) *pb.RpcAccountRecoverResponse
|
||||
AccountCreate(*pb.RpcAccountCreateRequest) *pb.RpcAccountCreateResponse
|
||||
AccountSelect(*pb.RpcAccountSelectRequest) *pb.RpcAccountSelectResponse
|
||||
ImageGetBlob(*pb.RpcImageGetBlobRequest) *pb.RpcImageGetBlobResponse
|
||||
VersionGet(*pb.RpcVersionGetRequest) *pb.RpcVersionGetResponse
|
||||
LogSend(*pb.RpcLogSendRequest) *pb.RpcLogSendResponse
|
||||
BlockOpen(*pb.RpcBlockOpenRequest) *pb.RpcBlockOpenResponse
|
||||
BlockCreate(*pb.RpcBlockCreateRequest) *pb.RpcBlockCreateResponse
|
||||
BlockUpdate(*pb.RpcBlockUpdateRequest) *pb.RpcBlockUpdateResponse
|
||||
BlockHistoryMove(*pb.RpcBlockHistoryMoveRequest) *pb.RpcBlockHistoryMoveResponse
|
||||
}
|
||||
|
||||
func registerClientCommandsHandler(srv ClientCommandsHandler) {
|
||||
|
@ -77,9 +77,9 @@ func registerClientCommandsHandler(srv ClientCommandsHandler) {
|
|||
}
|
||||
|
||||
func WalletCreate(b []byte) []byte {
|
||||
in := new(pb.Rpc_Wallet_Create_Request)
|
||||
in := new(pb.RpcWalletCreateRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Wallet_Create_Response{Error: &pb.Rpc_Wallet_Create_Response_Error{Code: pb.Rpc_Wallet_Create_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcWalletCreateResponse{Error: &pb.RpcWalletCreateResponseError{Code: pb.RpcWalletCreateResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.WalletCreate(in).Marshal()
|
||||
|
@ -87,9 +87,9 @@ func WalletCreate(b []byte) []byte {
|
|||
}
|
||||
|
||||
func WalletRecover(b []byte) []byte {
|
||||
in := new(pb.Rpc_Wallet_Recover_Request)
|
||||
in := new(pb.RpcWalletRecoverRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Wallet_Recover_Response{Error: &pb.Rpc_Wallet_Recover_Response_Error{Code: pb.Rpc_Wallet_Recover_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcWalletRecoverResponse{Error: &pb.RpcWalletRecoverResponseError{Code: pb.RpcWalletRecoverResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.WalletRecover(in).Marshal()
|
||||
|
@ -97,9 +97,9 @@ func WalletRecover(b []byte) []byte {
|
|||
}
|
||||
|
||||
func AccountRecover(b []byte) []byte {
|
||||
in := new(pb.Rpc_Account_Recover_Request)
|
||||
in := new(pb.RpcAccountRecoverRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Account_Recover_Response{Error: &pb.Rpc_Account_Recover_Response_Error{Code: pb.Rpc_Account_Recover_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcAccountRecoverResponse{Error: &pb.RpcAccountRecoverResponseError{Code: pb.RpcAccountRecoverResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.AccountRecover(in).Marshal()
|
||||
|
@ -107,9 +107,9 @@ func AccountRecover(b []byte) []byte {
|
|||
}
|
||||
|
||||
func AccountCreate(b []byte) []byte {
|
||||
in := new(pb.Rpc_Account_Create_Request)
|
||||
in := new(pb.RpcAccountCreateRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Account_Create_Response{Error: &pb.Rpc_Account_Create_Response_Error{Code: pb.Rpc_Account_Create_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcAccountCreateResponse{Error: &pb.RpcAccountCreateResponseError{Code: pb.RpcAccountCreateResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.AccountCreate(in).Marshal()
|
||||
|
@ -117,9 +117,9 @@ func AccountCreate(b []byte) []byte {
|
|||
}
|
||||
|
||||
func AccountSelect(b []byte) []byte {
|
||||
in := new(pb.Rpc_Account_Select_Request)
|
||||
in := new(pb.RpcAccountSelectRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Account_Select_Response{Error: &pb.Rpc_Account_Select_Response_Error{Code: pb.Rpc_Account_Select_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcAccountSelectResponse{Error: &pb.RpcAccountSelectResponseError{Code: pb.RpcAccountSelectResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.AccountSelect(in).Marshal()
|
||||
|
@ -127,9 +127,9 @@ func AccountSelect(b []byte) []byte {
|
|||
}
|
||||
|
||||
func ImageGetBlob(b []byte) []byte {
|
||||
in := new(pb.Rpc_Image_Get_Blob_Request)
|
||||
in := new(pb.RpcImageGetBlobRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Image_Get_Blob_Response{Error: &pb.Rpc_Image_Get_Blob_Response_Error{Code: pb.Rpc_Image_Get_Blob_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcImageGetBlobResponse{Error: &pb.RpcImageGetBlobResponseError{Code: pb.RpcImageGetBlobResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.ImageGetBlob(in).Marshal()
|
||||
|
@ -137,9 +137,9 @@ func ImageGetBlob(b []byte) []byte {
|
|||
}
|
||||
|
||||
func VersionGet(b []byte) []byte {
|
||||
in := new(pb.Rpc_Version_Get_Request)
|
||||
in := new(pb.RpcVersionGetRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Version_Get_Response{Error: &pb.Rpc_Version_Get_Response_Error{Code: pb.Rpc_Version_Get_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcVersionGetResponse{Error: &pb.RpcVersionGetResponseError{Code: pb.RpcVersionGetResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.VersionGet(in).Marshal()
|
||||
|
@ -147,9 +147,9 @@ func VersionGet(b []byte) []byte {
|
|||
}
|
||||
|
||||
func LogSend(b []byte) []byte {
|
||||
in := new(pb.Rpc_Log_Send_Request)
|
||||
in := new(pb.RpcLogSendRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Log_Send_Response{Error: &pb.Rpc_Log_Send_Response_Error{Code: pb.Rpc_Log_Send_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcLogSendResponse{Error: &pb.RpcLogSendResponseError{Code: pb.RpcLogSendResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.LogSend(in).Marshal()
|
||||
|
@ -157,9 +157,9 @@ func LogSend(b []byte) []byte {
|
|||
}
|
||||
|
||||
func BlockOpen(b []byte) []byte {
|
||||
in := new(pb.Rpc_Block_Open_Request)
|
||||
in := new(pb.RpcBlockOpenRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Block_Open_Response{Error: &pb.Rpc_Block_Open_Response_Error{Code: pb.Rpc_Block_Open_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcBlockOpenResponse{Error: &pb.RpcBlockOpenResponseError{Code: pb.RpcBlockOpenResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.BlockOpen(in).Marshal()
|
||||
|
@ -167,9 +167,9 @@ func BlockOpen(b []byte) []byte {
|
|||
}
|
||||
|
||||
func BlockCreate(b []byte) []byte {
|
||||
in := new(pb.Rpc_Block_Create_Request)
|
||||
in := new(pb.RpcBlockCreateRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Block_Create_Response{Error: &pb.Rpc_Block_Create_Response_Error{Code: pb.Rpc_Block_Create_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcBlockCreateResponse{Error: &pb.RpcBlockCreateResponseError{Code: pb.RpcBlockCreateResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.BlockCreate(in).Marshal()
|
||||
|
@ -177,9 +177,9 @@ func BlockCreate(b []byte) []byte {
|
|||
}
|
||||
|
||||
func BlockUpdate(b []byte) []byte {
|
||||
in := new(pb.Rpc_Block_Update_Request)
|
||||
in := new(pb.RpcBlockUpdateRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Block_Update_Response{Error: &pb.Rpc_Block_Update_Response_Error{Code: pb.Rpc_Block_Update_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcBlockUpdateResponse{Error: &pb.RpcBlockUpdateResponseError{Code: pb.RpcBlockUpdateResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.BlockUpdate(in).Marshal()
|
||||
|
@ -187,9 +187,9 @@ func BlockUpdate(b []byte) []byte {
|
|||
}
|
||||
|
||||
func BlockHistoryMove(b []byte) []byte {
|
||||
in := new(pb.Rpc_Block_History_Move_Request)
|
||||
in := new(pb.RpcBlockHistoryMoveRequest)
|
||||
if err := in.Unmarshal(b); err != nil {
|
||||
resp, _ := (&pb.Rpc_Block_History_Move_Response{Error: &pb.Rpc_Block_History_Move_Response_Error{Code: pb.Rpc_Block_History_Move_Response_Error_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
resp, _ := (&pb.RpcBlockHistoryMoveResponse{Error: &pb.RpcBlockHistoryMoveResponseError{Code: pb.RpcBlockHistoryMoveResponseError_BAD_INPUT, Description: err.Error()}}).Marshal()
|
||||
return resp
|
||||
}
|
||||
resp, _ := clientCommandsHandler.BlockHistoryMove(in).Marshal()
|
||||
|
|
|
@ -101,7 +101,7 @@ type Change_Block_Header struct {
|
|||
// *Change_Block_Header_Name
|
||||
// *Change_Block_Header_Icon
|
||||
// *Change_Block_Header_Permissions
|
||||
Change isChange_Block_Header_Change `protobuf_oneof:"change"`
|
||||
Change isChange_Block_HeaderChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *Change_Block_Header) Reset() { *m = Change_Block_Header{} }
|
||||
|
@ -137,8 +137,8 @@ func (m *Change_Block_Header) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Change_Block_Header proto.InternalMessageInfo
|
||||
|
||||
type isChange_Block_Header_Change interface {
|
||||
isChange_Block_Header_Change()
|
||||
type isChange_Block_HeaderChange interface {
|
||||
isChange_Block_HeaderChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -159,13 +159,13 @@ type Change_Block_Header_Permissions struct {
|
|||
Permissions *Model_Block_Header_Permissions `protobuf:"bytes,5,opt,name=permissions,proto3,oneof" json:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
func (*Change_Block_Header_Id) isChange_Block_Header_Change() {}
|
||||
func (*Change_Block_Header_Type) isChange_Block_Header_Change() {}
|
||||
func (*Change_Block_Header_Name) isChange_Block_Header_Change() {}
|
||||
func (*Change_Block_Header_Icon) isChange_Block_Header_Change() {}
|
||||
func (*Change_Block_Header_Permissions) isChange_Block_Header_Change() {}
|
||||
func (*Change_Block_Header_Id) isChange_Block_HeaderChange() {}
|
||||
func (*Change_Block_Header_Type) isChange_Block_HeaderChange() {}
|
||||
func (*Change_Block_Header_Name) isChange_Block_HeaderChange() {}
|
||||
func (*Change_Block_Header_Icon) isChange_Block_HeaderChange() {}
|
||||
func (*Change_Block_Header_Permissions) isChange_Block_HeaderChange() {}
|
||||
|
||||
func (m *Change_Block_Header) GetChange() isChange_Block_Header_Change {
|
||||
func (m *Change_Block_Header) GetChange() isChange_Block_HeaderChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ type Change_Block_Content_Page struct {
|
|||
// Types that are valid to be assigned to Change:
|
||||
// *Change_Block_Content_Page_Style
|
||||
// *Change_Block_Content_Page_Block
|
||||
Change isChange_Block_Content_Page_Change `protobuf_oneof:"change"`
|
||||
Change isChange_Block_Content_PageChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *Change_Block_Content_Page) Reset() { *m = Change_Block_Content_Page{} }
|
||||
|
@ -338,8 +338,8 @@ func (m *Change_Block_Content_Page) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Change_Block_Content_Page proto.InternalMessageInfo
|
||||
|
||||
type isChange_Block_Content_Page_Change interface {
|
||||
isChange_Block_Content_Page_Change()
|
||||
type isChange_Block_Content_PageChange interface {
|
||||
isChange_Block_Content_PageChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -351,10 +351,10 @@ type Change_Block_Content_Page_Block struct {
|
|||
Block *Model_Block `protobuf:"bytes,2,opt,name=block,proto3,oneof" json:"block,omitempty"`
|
||||
}
|
||||
|
||||
func (*Change_Block_Content_Page_Style) isChange_Block_Content_Page_Change() {}
|
||||
func (*Change_Block_Content_Page_Block) isChange_Block_Content_Page_Change() {}
|
||||
func (*Change_Block_Content_Page_Style) isChange_Block_Content_PageChange() {}
|
||||
func (*Change_Block_Content_Page_Block) isChange_Block_Content_PageChange() {}
|
||||
|
||||
func (m *Change_Block_Content_Page) GetChange() isChange_Block_Content_Page_Change {
|
||||
func (m *Change_Block_Content_Page) GetChange() isChange_Block_Content_PageChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ type Change_Block_Content_Dashboard struct {
|
|||
// Types that are valid to be assigned to Change:
|
||||
// *Change_Block_Content_Dashboard_Style
|
||||
// *Change_Block_Content_Dashboard_Header
|
||||
Change isChange_Block_Content_Dashboard_Change `protobuf_oneof:"change"`
|
||||
Change isChange_Block_Content_DashboardChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *Change_Block_Content_Dashboard) Reset() { *m = Change_Block_Content_Dashboard{} }
|
||||
|
@ -423,8 +423,8 @@ func (m *Change_Block_Content_Dashboard) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Change_Block_Content_Dashboard proto.InternalMessageInfo
|
||||
|
||||
type isChange_Block_Content_Dashboard_Change interface {
|
||||
isChange_Block_Content_Dashboard_Change()
|
||||
type isChange_Block_Content_DashboardChange interface {
|
||||
isChange_Block_Content_DashboardChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -436,10 +436,10 @@ type Change_Block_Content_Dashboard_Header struct {
|
|||
Header *Model_Block_Header `protobuf:"bytes,2,opt,name=header,proto3,oneof" json:"header,omitempty"`
|
||||
}
|
||||
|
||||
func (*Change_Block_Content_Dashboard_Style) isChange_Block_Content_Dashboard_Change() {}
|
||||
func (*Change_Block_Content_Dashboard_Header) isChange_Block_Content_Dashboard_Change() {}
|
||||
func (*Change_Block_Content_Dashboard_Style) isChange_Block_Content_DashboardChange() {}
|
||||
func (*Change_Block_Content_Dashboard_Header) isChange_Block_Content_DashboardChange() {}
|
||||
|
||||
func (m *Change_Block_Content_Dashboard) GetChange() isChange_Block_Content_Dashboard_Change {
|
||||
func (m *Change_Block_Content_Dashboard) GetChange() isChange_Block_Content_DashboardChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ type Change_Block_Content_Media struct {
|
|||
// Types that are valid to be assigned to Change:
|
||||
// *Change_Block_Content_Media_Link
|
||||
// *Change_Block_Content_Media_State
|
||||
Change isChange_Block_Content_Media_Change `protobuf_oneof:"change"`
|
||||
Change isChange_Block_Content_MediaChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *Change_Block_Content_Media) Reset() { *m = Change_Block_Content_Media{} }
|
||||
|
@ -508,8 +508,8 @@ func (m *Change_Block_Content_Media) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Change_Block_Content_Media proto.InternalMessageInfo
|
||||
|
||||
type isChange_Block_Content_Media_Change interface {
|
||||
isChange_Block_Content_Media_Change()
|
||||
type isChange_Block_Content_MediaChange interface {
|
||||
isChange_Block_Content_MediaChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -521,10 +521,10 @@ type Change_Block_Content_Media_State struct {
|
|||
State Model_Block_Content_Media_State `protobuf:"varint,2,opt,name=state,proto3,enum=anytype.Model_Block_Content_Media_State,oneof" json:"state,omitempty"`
|
||||
}
|
||||
|
||||
func (*Change_Block_Content_Media_Link) isChange_Block_Content_Media_Change() {}
|
||||
func (*Change_Block_Content_Media_State) isChange_Block_Content_Media_Change() {}
|
||||
func (*Change_Block_Content_Media_Link) isChange_Block_Content_MediaChange() {}
|
||||
func (*Change_Block_Content_Media_State) isChange_Block_Content_MediaChange() {}
|
||||
|
||||
func (m *Change_Block_Content_Media) GetChange() isChange_Block_Content_Media_Change {
|
||||
func (m *Change_Block_Content_Media) GetChange() isChange_Block_Content_MediaChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ type Change_Block_Content_Text struct {
|
|||
// *Change_Block_Content_Text_MarkerType
|
||||
// *Change_Block_Content_Text_Checkable
|
||||
// *Change_Block_Content_Text_Checked
|
||||
Change isChange_Block_Content_Text_Change `protobuf_oneof:"change"`
|
||||
Change isChange_Block_Content_TextChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *Change_Block_Content_Text) Reset() { *m = Change_Block_Content_Text{} }
|
||||
|
@ -598,8 +598,8 @@ func (m *Change_Block_Content_Text) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Change_Block_Content_Text proto.InternalMessageInfo
|
||||
|
||||
type isChange_Block_Content_Text_Change interface {
|
||||
isChange_Block_Content_Text_Change()
|
||||
type isChange_Block_Content_TextChange interface {
|
||||
isChange_Block_Content_TextChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -626,15 +626,15 @@ type Change_Block_Content_Text_Checked struct {
|
|||
Checked bool `protobuf:"varint,7,opt,name=checked,proto3,oneof" json:"checked,omitempty"`
|
||||
}
|
||||
|
||||
func (*Change_Block_Content_Text_Text) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Style) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Marks) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Toggleable) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_MarkerType) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Checkable) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Checked) isChange_Block_Content_Text_Change() {}
|
||||
func (*Change_Block_Content_Text_Text) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_Style) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_Marks) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_Toggleable) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_MarkerType) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_Checkable) isChange_Block_Content_TextChange() {}
|
||||
func (*Change_Block_Content_Text_Checked) isChange_Block_Content_TextChange() {}
|
||||
|
||||
func (m *Change_Block_Content_Text) GetChange() isChange_Block_Content_Text_Change {
|
||||
func (m *Change_Block_Content_Text) GetChange() isChange_Block_Content_TextChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ type BlocksListSingleChange struct {
|
|||
// *BlocksListSingleChange_Page
|
||||
// *BlocksListSingleChange_Dashboard
|
||||
// *BlocksListSingleChange_Media
|
||||
Change isBlocksListSingleChange_Change `protobuf_oneof:"change"`
|
||||
Change isBlocksListSingleChangeChange `protobuf_oneof:"change"`
|
||||
}
|
||||
|
||||
func (m *BlocksListSingleChange) Reset() { *m = BlocksListSingleChange{} }
|
||||
|
@ -748,8 +748,8 @@ func (m *BlocksListSingleChange) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_BlocksListSingleChange proto.InternalMessageInfo
|
||||
|
||||
type isBlocksListSingleChange_Change interface {
|
||||
isBlocksListSingleChange_Change()
|
||||
type isBlocksListSingleChangeChange interface {
|
||||
isBlocksListSingleChangeChange()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -773,14 +773,14 @@ type BlocksListSingleChange_Media struct {
|
|||
Media *Change_Block_Content_Media `protobuf:"bytes,7,opt,name=media,proto3,oneof" json:"media,omitempty"`
|
||||
}
|
||||
|
||||
func (*BlocksListSingleChange_Text) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_BlockHeader) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_BlockChildren) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_Page) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_Dashboard) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_Media) isBlocksListSingleChange_Change() {}
|
||||
func (*BlocksListSingleChange_Text) isBlocksListSingleChangeChange() {}
|
||||
func (*BlocksListSingleChange_BlockHeader) isBlocksListSingleChangeChange() {}
|
||||
func (*BlocksListSingleChange_BlockChildren) isBlocksListSingleChangeChange() {}
|
||||
func (*BlocksListSingleChange_Page) isBlocksListSingleChangeChange() {}
|
||||
func (*BlocksListSingleChange_Dashboard) isBlocksListSingleChangeChange() {}
|
||||
func (*BlocksListSingleChange_Media) isBlocksListSingleChangeChange() {}
|
||||
|
||||
func (m *BlocksListSingleChange) GetChange() isBlocksListSingleChange_Change {
|
||||
func (m *BlocksListSingleChange) GetChange() isBlocksListSingleChangeChange {
|
||||
if m != nil {
|
||||
return m.Change
|
||||
}
|
||||
|
|
|
@ -1870,7 +1870,7 @@ type Rpc_Account_Create_Request struct {
|
|||
// Types that are valid to be assigned to Avatar:
|
||||
// *Rpc_Account_Create_Request_AvatarLocalPath
|
||||
// *Rpc_Account_Create_Request_AvatarColor
|
||||
Avatar isRpc_Account_Create_Request_Avatar `protobuf_oneof:"avatar"`
|
||||
Avatar isRpc_Account_Create_RequestAvatar `protobuf_oneof:"avatar"`
|
||||
}
|
||||
|
||||
func (m *Rpc_Account_Create_Request) Reset() { *m = Rpc_Account_Create_Request{} }
|
||||
|
@ -1906,8 +1906,8 @@ func (m *Rpc_Account_Create_Request) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Rpc_Account_Create_Request proto.InternalMessageInfo
|
||||
|
||||
type isRpc_Account_Create_Request_Avatar interface {
|
||||
isRpc_Account_Create_Request_Avatar()
|
||||
type isRpc_Account_Create_RequestAvatar interface {
|
||||
isRpc_Account_Create_RequestAvatar()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -1919,10 +1919,10 @@ type Rpc_Account_Create_Request_AvatarColor struct {
|
|||
AvatarColor string `protobuf:"bytes,3,opt,name=avatarColor,proto3,oneof" json:"avatarColor,omitempty"`
|
||||
}
|
||||
|
||||
func (*Rpc_Account_Create_Request_AvatarLocalPath) isRpc_Account_Create_Request_Avatar() {}
|
||||
func (*Rpc_Account_Create_Request_AvatarColor) isRpc_Account_Create_Request_Avatar() {}
|
||||
func (*Rpc_Account_Create_Request_AvatarLocalPath) isRpc_Account_Create_RequestAvatar() {}
|
||||
func (*Rpc_Account_Create_Request_AvatarColor) isRpc_Account_Create_RequestAvatar() {}
|
||||
|
||||
func (m *Rpc_Account_Create_Request) GetAvatar() isRpc_Account_Create_Request_Avatar {
|
||||
func (m *Rpc_Account_Create_Request) GetAvatar() isRpc_Account_Create_RequestAvatar {
|
||||
if m != nil {
|
||||
return m.Avatar
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ type Event struct {
|
|||
// *Event_UserBlockLeft
|
||||
// *Event_UserBlockSelectRange
|
||||
// *Event_FilesUpload
|
||||
Message isEvent_Message `protobuf_oneof:"message"`
|
||||
Message isEventMessage `protobuf_oneof:"message"`
|
||||
}
|
||||
|
||||
func (m *Event) Reset() { *m = Event{} }
|
||||
|
@ -69,8 +69,8 @@ func (m *Event) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Event proto.InternalMessageInfo
|
||||
|
||||
type isEvent_Message interface {
|
||||
isEvent_Message()
|
||||
type isEventMessage interface {
|
||||
isEventMessage()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -103,17 +103,17 @@ type Event_FilesUpload struct {
|
|||
FilesUpload *Event_Block_FilesUpload `protobuf:"bytes,9,opt,name=filesUpload,proto3,oneof" json:"filesUpload,omitempty"`
|
||||
}
|
||||
|
||||
func (*Event_AccountShow) isEvent_Message() {}
|
||||
func (*Event_BlockShow) isEvent_Message() {}
|
||||
func (*Event_BlockUpdate) isEvent_Message() {}
|
||||
func (*Event_BlockCreate) isEvent_Message() {}
|
||||
func (*Event_UserBlockTextRange) isEvent_Message() {}
|
||||
func (*Event_UserBlockJoin) isEvent_Message() {}
|
||||
func (*Event_UserBlockLeft) isEvent_Message() {}
|
||||
func (*Event_UserBlockSelectRange) isEvent_Message() {}
|
||||
func (*Event_FilesUpload) isEvent_Message() {}
|
||||
func (*Event_AccountShow) isEventMessage() {}
|
||||
func (*Event_BlockShow) isEventMessage() {}
|
||||
func (*Event_BlockUpdate) isEventMessage() {}
|
||||
func (*Event_BlockCreate) isEventMessage() {}
|
||||
func (*Event_UserBlockTextRange) isEventMessage() {}
|
||||
func (*Event_UserBlockJoin) isEventMessage() {}
|
||||
func (*Event_UserBlockLeft) isEventMessage() {}
|
||||
func (*Event_UserBlockSelectRange) isEventMessage() {}
|
||||
func (*Event_FilesUpload) isEventMessage() {}
|
||||
|
||||
func (m *Event) GetMessage() isEvent_Message {
|
||||
func (m *Event) GetMessage() isEventMessage {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ type Model_Block struct {
|
|||
// *Model_Block_Media
|
||||
// *Model_Block_Layout
|
||||
// *Model_Block_Div
|
||||
Content isModel_Block_Content `protobuf_oneof:"content"`
|
||||
Content isModel_BlockContent `protobuf_oneof:"content"`
|
||||
}
|
||||
|
||||
func (m *Model_Block) Reset() { *m = Model_Block{} }
|
||||
|
@ -457,8 +457,8 @@ func (m *Model_Block) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Model_Block proto.InternalMessageInfo
|
||||
|
||||
type isModel_Block_Content interface {
|
||||
isModel_Block_Content()
|
||||
type isModel_BlockContent interface {
|
||||
isModel_BlockContent()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -485,15 +485,15 @@ type Model_Block_Div struct {
|
|||
Div *Model_Block_Content_Div `protobuf:"bytes,17,opt,name=div,proto3,oneof" json:"div,omitempty"`
|
||||
}
|
||||
|
||||
func (*Model_Block_Dashboard) isModel_Block_Content() {}
|
||||
func (*Model_Block_Page) isModel_Block_Content() {}
|
||||
func (*Model_Block_Dataview) isModel_Block_Content() {}
|
||||
func (*Model_Block_Text) isModel_Block_Content() {}
|
||||
func (*Model_Block_Media) isModel_Block_Content() {}
|
||||
func (*Model_Block_Layout) isModel_Block_Content() {}
|
||||
func (*Model_Block_Div) isModel_Block_Content() {}
|
||||
func (*Model_Block_Dashboard) isModel_BlockContent() {}
|
||||
func (*Model_Block_Page) isModel_BlockContent() {}
|
||||
func (*Model_Block_Dataview) isModel_BlockContent() {}
|
||||
func (*Model_Block_Text) isModel_BlockContent() {}
|
||||
func (*Model_Block_Media) isModel_BlockContent() {}
|
||||
func (*Model_Block_Layout) isModel_BlockContent() {}
|
||||
func (*Model_Block_Div) isModel_BlockContent() {}
|
||||
|
||||
func (m *Model_Block) GetContent() isModel_Block_Content {
|
||||
func (m *Model_Block) GetContent() isModel_BlockContent {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
|
@ -1127,7 +1127,7 @@ type Model_Block_Content_Media struct {
|
|||
// *Model_Block_Content_Media_Video
|
||||
// *Model_Block_Content_Media_Image
|
||||
// *Model_Block_Content_Media_File
|
||||
Preview isModel_Block_Content_Media_Preview `protobuf_oneof:"preview"`
|
||||
Preview isModel_Block_Content_MediaPreview `protobuf_oneof:"preview"`
|
||||
}
|
||||
|
||||
func (m *Model_Block_Content_Media) Reset() { *m = Model_Block_Content_Media{} }
|
||||
|
@ -1163,8 +1163,8 @@ func (m *Model_Block_Content_Media) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Model_Block_Content_Media proto.InternalMessageInfo
|
||||
|
||||
type isModel_Block_Content_Media_Preview interface {
|
||||
isModel_Block_Content_Media_Preview()
|
||||
type isModel_Block_Content_MediaPreview interface {
|
||||
isModel_Block_Content_MediaPreview()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -1179,11 +1179,11 @@ type Model_Block_Content_Media_File struct {
|
|||
File *Model_Block_Content_Media_FilePreview `protobuf:"bytes,103,opt,name=file,proto3,oneof" json:"file,omitempty"`
|
||||
}
|
||||
|
||||
func (*Model_Block_Content_Media_Video) isModel_Block_Content_Media_Preview() {}
|
||||
func (*Model_Block_Content_Media_Image) isModel_Block_Content_Media_Preview() {}
|
||||
func (*Model_Block_Content_Media_File) isModel_Block_Content_Media_Preview() {}
|
||||
func (*Model_Block_Content_Media_Video) isModel_Block_Content_MediaPreview() {}
|
||||
func (*Model_Block_Content_Media_Image) isModel_Block_Content_MediaPreview() {}
|
||||
func (*Model_Block_Content_Media_File) isModel_Block_Content_MediaPreview() {}
|
||||
|
||||
func (m *Model_Block_Content_Media) GetPreview() isModel_Block_Content_Media_Preview {
|
||||
func (m *Model_Block_Content_Media) GetPreview() isModel_Block_Content_MediaPreview {
|
||||
if m != nil {
|
||||
return m.Preview
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ type Model_Struct_Value struct {
|
|||
// *Model_Struct_Value_BoolValue
|
||||
// *Model_Struct_Value_StructValue
|
||||
// *Model_Struct_Value_ListValue
|
||||
Kind isModel_Struct_Value_Kind `protobuf_oneof:"kind"`
|
||||
Kind isModel_Struct_ValueKind `protobuf_oneof:"kind"`
|
||||
}
|
||||
|
||||
func (m *Model_Struct_Value) Reset() { *m = Model_Struct_Value{} }
|
||||
|
@ -1599,8 +1599,8 @@ func (m *Model_Struct_Value) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Model_Struct_Value proto.InternalMessageInfo
|
||||
|
||||
type isModel_Struct_Value_Kind interface {
|
||||
isModel_Struct_Value_Kind()
|
||||
type isModel_Struct_ValueKind interface {
|
||||
isModel_Struct_ValueKind()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -1624,14 +1624,14 @@ type Model_Struct_Value_ListValue struct {
|
|||
ListValue *Model_Struct_ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof" json:"list_value,omitempty"`
|
||||
}
|
||||
|
||||
func (*Model_Struct_Value_NullValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_NumberValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_StringValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_BoolValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_StructValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_ListValue) isModel_Struct_Value_Kind() {}
|
||||
func (*Model_Struct_Value_NullValue) isModel_Struct_ValueKind() {}
|
||||
func (*Model_Struct_Value_NumberValue) isModel_Struct_ValueKind() {}
|
||||
func (*Model_Struct_Value_StringValue) isModel_Struct_ValueKind() {}
|
||||
func (*Model_Struct_Value_BoolValue) isModel_Struct_ValueKind() {}
|
||||
func (*Model_Struct_Value_StructValue) isModel_Struct_ValueKind() {}
|
||||
func (*Model_Struct_Value_ListValue) isModel_Struct_ValueKind() {}
|
||||
|
||||
func (m *Model_Struct_Value) GetKind() isModel_Struct_Value_Kind {
|
||||
func (m *Model_Struct_Value) GetKind() isModel_Struct_ValueKind {
|
||||
if m != nil {
|
||||
return m.Kind
|
||||
}
|
||||
|
@ -1805,7 +1805,7 @@ type Model_Account_Avatar struct {
|
|||
// Types that are valid to be assigned to Avatar:
|
||||
// *Model_Account_Avatar_Image
|
||||
// *Model_Account_Avatar_Color
|
||||
Avatar isModel_Account_Avatar_Avatar `protobuf_oneof:"avatar"`
|
||||
Avatar isModel_Account_AvatarAvatar `protobuf_oneof:"avatar"`
|
||||
}
|
||||
|
||||
func (m *Model_Account_Avatar) Reset() { *m = Model_Account_Avatar{} }
|
||||
|
@ -1841,8 +1841,8 @@ func (m *Model_Account_Avatar) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Model_Account_Avatar proto.InternalMessageInfo
|
||||
|
||||
type isModel_Account_Avatar_Avatar interface {
|
||||
isModel_Account_Avatar_Avatar()
|
||||
type isModel_Account_AvatarAvatar interface {
|
||||
isModel_Account_AvatarAvatar()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -1854,10 +1854,10 @@ type Model_Account_Avatar_Color struct {
|
|||
Color string `protobuf:"bytes,2,opt,name=color,proto3,oneof" json:"color,omitempty"`
|
||||
}
|
||||
|
||||
func (*Model_Account_Avatar_Image) isModel_Account_Avatar_Avatar() {}
|
||||
func (*Model_Account_Avatar_Color) isModel_Account_Avatar_Avatar() {}
|
||||
func (*Model_Account_Avatar_Image) isModel_Account_AvatarAvatar() {}
|
||||
func (*Model_Account_Avatar_Color) isModel_Account_AvatarAvatar() {}
|
||||
|
||||
func (m *Model_Account_Avatar) GetAvatar() isModel_Account_Avatar_Avatar {
|
||||
func (m *Model_Account_Avatar) GetAvatar() isModel_Account_AvatarAvatar {
|
||||
if m != nil {
|
||||
return m.Avatar
|
||||
}
|
||||
|
|
|
@ -45,17 +45,17 @@ message Model {
|
|||
|
||||
LAYOUT = 8;
|
||||
DIV = 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Content {
|
||||
message Layout {
|
||||
Style style = 1;
|
||||
|
||||
|
||||
enum Style {
|
||||
ROW = 0;
|
||||
COLUMN = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Div {}
|
||||
|
@ -146,7 +146,7 @@ message Model {
|
|||
message FilePreview {
|
||||
string name = 1;
|
||||
string icon = 2;
|
||||
}
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0;
|
||||
|
@ -167,14 +167,14 @@ message Model {
|
|||
}
|
||||
|
||||
Style style = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Range {
|
||||
int32 from = 1;
|
||||
int32 to = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message Struct {
|
||||
// Unordered map of dynamically typed values.
|
||||
|
@ -203,7 +203,7 @@ message Model {
|
|||
// `ListValue` is a wrapper around a repeated field of values.
|
||||
message ListValue {
|
||||
repeated Value values = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +223,7 @@ message Model {
|
|||
string color = 2; // Color of the avatar, if no image
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Image {
|
||||
string id = 1;
|
||||
|
@ -233,7 +233,7 @@ message Model {
|
|||
LARGE = 0;
|
||||
SMALL = 1;
|
||||
THUMB = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Video {
|
||||
|
@ -247,7 +247,7 @@ message Model {
|
|||
HD_1080p = 3;
|
||||
UHD_1440p = 4;
|
||||
UHD_2160p = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue