diff --git a/app/commands/_packages.txt b/app/commands/_packages.txt deleted file mode 100644 index 4377efd..0000000 --- a/app/commands/_packages.txt +++ /dev/null @@ -1,4 +0,0 @@ -google.golang.org/protobuf version=1.28.1 url=https://github.com/protocolbuffers/protobuf-go -github.com/gorilla/websocket version=1.5.0 url=https://github.com/gorilla/websocket -github.com/gorilla/securecookie version=1.1.1 url=https://github.com/gorilla/securecookie -gopkg.in/yaml.v2 version=2.4.0 url=https://github.com/go-yaml/yaml \ No newline at end of file diff --git a/app/commands/get_packages.go b/app/commands/get_packages.go index 90a18f4..8c4f993 100644 --- a/app/commands/get_packages.go +++ b/app/commands/get_packages.go @@ -1,14 +1,14 @@ package commands -import ( - _ "embed" +import . "github.com/reiver/greatape/components/contracts" - . "github.com/reiver/greatape/components/contracts" -) - -//go:embed _packages.txt -var packages []byte +const packages = ` + google.golang.org/protobuf version=1.28.1 url=https://github.com/protocolbuffers/protobuf-go + github.com/gorilla/websocket version=1.5.0 url=https://github.com/gorilla/websocket + github.com/gorilla/securecookie version=1.1.1 url=https://github.com/gorilla/securecookie + gopkg.in/yaml.v2 version=2.4.0 url=https://github.com/go-yaml/yaml +` func GetPackages(x IDispatcher) (IGetPackagesResult, error) { - return x.NewGetPackagesResult(packages), nil + return x.NewGetPackagesResult([]byte(packages)), nil } diff --git a/components/api/operations/authorize_interaction_operation.go b/components/api/operations/authorize_interaction_operation.go index e1f4e66..c7b30be 100644 --- a/components/api/operations/authorize_interaction_operation.go +++ b/components/api/operations/authorize_interaction_operation.go @@ -37,15 +37,3 @@ func (operation *authorizeInteractionOperation) OutputContainer() Pointer { func (operation *authorizeInteractionOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*AuthorizeInteractionRequest)) } - -/* -func (operation *authorizeInteractionOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/change_password_operation.go b/components/api/operations/change_password_operation.go index a073c70..7768aba 100644 --- a/components/api/operations/change_password_operation.go +++ b/components/api/operations/change_password_operation.go @@ -37,15 +37,3 @@ func (operation *changePasswordOperation) OutputContainer() Pointer { func (operation *changePasswordOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*ChangePasswordRequest)) } - -/* -func (operation *changePasswordOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/check_username_availability_operation.go b/components/api/operations/check_username_availability_operation.go index e409e92..55ae467 100644 --- a/components/api/operations/check_username_availability_operation.go +++ b/components/api/operations/check_username_availability_operation.go @@ -37,15 +37,3 @@ func (operation *checkUsernameAvailabilityOperation) OutputContainer() Pointer { func (operation *checkUsernameAvailabilityOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*CheckUsernameAvailabilityRequest)) } - -/* -func (operation *checkUsernameAvailabilityOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/echo_operation.go b/components/api/operations/echo_operation.go index 1a66d1a..b9c7857 100644 --- a/components/api/operations/echo_operation.go +++ b/components/api/operations/echo_operation.go @@ -37,15 +37,3 @@ func (operation *echoOperation) OutputContainer() Pointer { func (operation *echoOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*EchoRequest)) } - -/* -func (operation *echoOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/follow_actor_operation.go b/components/api/operations/follow_actor_operation.go index 351e6d7..a1e5305 100644 --- a/components/api/operations/follow_actor_operation.go +++ b/components/api/operations/follow_actor_operation.go @@ -37,15 +37,3 @@ func (operation *followActorOperation) OutputContainer() Pointer { func (operation *followActorOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*FollowActorRequest)) } - -/* -func (operation *followActorOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_actor_operation.go b/components/api/operations/get_actor_operation.go index 1e7304a..434f370 100644 --- a/components/api/operations/get_actor_operation.go +++ b/components/api/operations/get_actor_operation.go @@ -37,15 +37,3 @@ func (operation *getActorOperation) OutputContainer() Pointer { func (operation *getActorOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetActorRequest)) } - -/* -func (operation *getActorOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_followers_operation.go b/components/api/operations/get_followers_operation.go index 0df6497..f0fe073 100644 --- a/components/api/operations/get_followers_operation.go +++ b/components/api/operations/get_followers_operation.go @@ -37,15 +37,3 @@ func (operation *getFollowersOperation) OutputContainer() Pointer { func (operation *getFollowersOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetFollowersRequest)) } - -/* -func (operation *getFollowersOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_following_operation.go b/components/api/operations/get_following_operation.go index fc86af0..851a2f2 100644 --- a/components/api/operations/get_following_operation.go +++ b/components/api/operations/get_following_operation.go @@ -37,15 +37,3 @@ func (operation *getFollowingOperation) OutputContainer() Pointer { func (operation *getFollowingOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetFollowingRequest)) } - -/* -func (operation *getFollowingOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_inbox_operation.go b/components/api/operations/get_inbox_operation.go index c0e2d98..83c2e13 100644 --- a/components/api/operations/get_inbox_operation.go +++ b/components/api/operations/get_inbox_operation.go @@ -37,15 +37,3 @@ func (operation *getInboxOperation) OutputContainer() Pointer { func (operation *getInboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetInboxRequest)) } - -/* -func (operation *getInboxOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_outbox_operation.go b/components/api/operations/get_outbox_operation.go index 47c2e59..7662157 100644 --- a/components/api/operations/get_outbox_operation.go +++ b/components/api/operations/get_outbox_operation.go @@ -37,15 +37,3 @@ func (operation *getOutboxOperation) OutputContainer() Pointer { func (operation *getOutboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetOutboxRequest)) } - -/* -func (operation *getOutboxOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_packages_operation.go b/components/api/operations/get_packages_operation.go index 17ebe73..73ddec6 100644 --- a/components/api/operations/get_packages_operation.go +++ b/components/api/operations/get_packages_operation.go @@ -37,15 +37,3 @@ func (operation *getPackagesOperation) OutputContainer() Pointer { func (operation *getPackagesOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetPackagesRequest)) } - -/* -func (operation *getPackagesOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/get_profile_by_user_operation.go b/components/api/operations/get_profile_by_user_operation.go index eb5729d..a36efb0 100644 --- a/components/api/operations/get_profile_by_user_operation.go +++ b/components/api/operations/get_profile_by_user_operation.go @@ -37,15 +37,3 @@ func (operation *getProfileByUserOperation) OutputContainer() Pointer { func (operation *getProfileByUserOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*GetProfileByUserRequest)) } - -/* -func (operation *getProfileByUserOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/login_operation.go b/components/api/operations/login_operation.go index a725b43..6c3607b 100644 --- a/components/api/operations/login_operation.go +++ b/components/api/operations/login_operation.go @@ -37,15 +37,3 @@ func (operation *loginOperation) OutputContainer() Pointer { func (operation *loginOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*LoginRequest)) } - -/* -func (operation *loginOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/logout_operation.go b/components/api/operations/logout_operation.go index 9e3572c..a5da1d7 100644 --- a/components/api/operations/logout_operation.go +++ b/components/api/operations/logout_operation.go @@ -37,15 +37,3 @@ func (operation *logoutOperation) OutputContainer() Pointer { func (operation *logoutOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*LogoutRequest)) } - -/* -func (operation *logoutOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/post_to_inbox_operation.go b/components/api/operations/post_to_inbox_operation.go index 4c8c807..db88f3f 100644 --- a/components/api/operations/post_to_inbox_operation.go +++ b/components/api/operations/post_to_inbox_operation.go @@ -37,15 +37,3 @@ func (operation *postToInboxOperation) OutputContainer() Pointer { func (operation *postToInboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*PostToInboxRequest)) } - -/* -func (operation *postToInboxOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/post_to_outbox_operation.go b/components/api/operations/post_to_outbox_operation.go index 8baab1a..c0e299c 100644 --- a/components/api/operations/post_to_outbox_operation.go +++ b/components/api/operations/post_to_outbox_operation.go @@ -37,15 +37,3 @@ func (operation *postToOutboxOperation) OutputContainer() Pointer { func (operation *postToOutboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*PostToOutboxRequest)) } - -/* -func (operation *postToOutboxOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/reset_password_operation.go b/components/api/operations/reset_password_operation.go index 276744c..124f03c 100644 --- a/components/api/operations/reset_password_operation.go +++ b/components/api/operations/reset_password_operation.go @@ -37,15 +37,3 @@ func (operation *resetPasswordOperation) OutputContainer() Pointer { func (operation *resetPasswordOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*ResetPasswordRequest)) } - -/* -func (operation *resetPasswordOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/signup_operation.go b/components/api/operations/signup_operation.go index 954e407..60cd11f 100644 --- a/components/api/operations/signup_operation.go +++ b/components/api/operations/signup_operation.go @@ -37,15 +37,3 @@ func (operation *signupOperation) OutputContainer() Pointer { func (operation *signupOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*SignupRequest)) } - -/* -func (operation *signupOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/update_profile_by_user_operation.go b/components/api/operations/update_profile_by_user_operation.go index 9616bb8..2a07355 100644 --- a/components/api/operations/update_profile_by_user_operation.go +++ b/components/api/operations/update_profile_by_user_operation.go @@ -37,15 +37,3 @@ func (operation *updateProfileByUserOperation) OutputContainer() Pointer { func (operation *updateProfileByUserOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*UpdateProfileByUserRequest)) } - -/* -func (operation *updateProfileByUserOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/verify_operation.go b/components/api/operations/verify_operation.go index 30ee3da..378919f 100644 --- a/components/api/operations/verify_operation.go +++ b/components/api/operations/verify_operation.go @@ -37,15 +37,3 @@ func (operation *verifyOperation) OutputContainer() Pointer { func (operation *verifyOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*VerifyRequest)) } - -/* -func (operation *verifyOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/operations/webfinger_operation.go b/components/api/operations/webfinger_operation.go index d503a50..5597f70 100644 --- a/components/api/operations/webfinger_operation.go +++ b/components/api/operations/webfinger_operation.go @@ -37,15 +37,3 @@ func (operation *webfingerOperation) OutputContainer() Pointer { func (operation *webfingerOperation) Execute(context IContext, payload Pointer) (Pointer, error) { return operation.run(context, payload.(*WebfingerRequest)) } - -/* -func (operation *webfingerOperation) ExecutionTimeLimits() (Duration, Duration, Duration) { - var ( - TIME_LIMIT_WARNING Duration = 20_000_000 - TIME_LIMIT_ALERT Duration = 35_000_000 - TIME_LIMIT_CRITICAL Duration = 50_000_000 - ) - - return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL -} -*/ diff --git a/components/api/services/authorize_interaction_service.go b/components/api/services/authorize_interaction_service.go index b391440..69ddf34 100644 --- a/components/api/services/authorize_interaction_service.go +++ b/components/api/services/authorize_interaction_service.go @@ -3,27 +3,22 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func AuthorizeInteractionService(context IContext, input *AuthorizeInteractionRequest) (result *AuthorizeInteractionResult, err error) { - conductor := core.Conductor + source := "authorize_interaction" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "authorize_interaction", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "authorize_interaction", input, result, err) }() - - _result, _err := conductor.AuthorizeInteraction(input.Uri, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.AuthorizeInteraction(input.Uri, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*AuthorizeInteractionResult) - result.Uri = _result.Uri() - result.Success = _result.Success() + result.Uri = commandResult.Uri() + result.Success = commandResult.Success() return result, nil } diff --git a/components/api/services/change_password_service.go b/components/api/services/change_password_service.go index 8acc46c..d50e16e 100644 --- a/components/api/services/change_password_service.go +++ b/components/api/services/change_password_service.go @@ -3,25 +3,19 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func ChangePasswordService(context IContext, input *ChangePasswordRequest) (result *ChangePasswordResult, err error) { - conductor := core.Conductor + source := "change_password" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "change_password", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "change_password", input, result, err) }() - - _result, _err := conductor.ChangePassword(input.CurrentPassword, input.NewPassword, context.Identity()) - if _err != nil { - err = _err + if _, err = Conductor.ChangePassword(input.CurrentPassword, input.NewPassword, context.Identity()); err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*ChangePasswordResult) return result, nil } diff --git a/components/api/services/check_username_availability_service.go b/components/api/services/check_username_availability_service.go index 07b13e1..fc89bf7 100644 --- a/components/api/services/check_username_availability_service.go +++ b/components/api/services/check_username_availability_service.go @@ -3,26 +3,21 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func CheckUsernameAvailabilityService(context IContext, input *CheckUsernameAvailabilityRequest) (result *CheckUsernameAvailabilityResult, err error) { - conductor := core.Conductor + source := "check_username_availability" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "check_username_availability", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "check_username_availability", input, result, err) }() - - _result, _err := conductor.CheckUsernameAvailability(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.CheckUsernameAvailability(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*CheckUsernameAvailabilityResult) - result.IsAvailable = _result.IsAvailable() + result.IsAvailable = commandResult.IsAvailable() return result, nil } diff --git a/components/api/services/echo_service.go b/components/api/services/echo_service.go index a3320f7..6a4c967 100644 --- a/components/api/services/echo_service.go +++ b/components/api/services/echo_service.go @@ -3,39 +3,34 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func EchoService(context IContext, input *EchoRequest) (result *EchoResult, err error) { - conductor := core.Conductor - - conductor.LogRemoteCall(context, INITIALIZE, "echo", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "echo", input, result, err) }() + source := "echo" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() var inputDocument IDocument if input.Document != nil { var err error - if inputDocument, err = conductor.NewDocument(input.Document.Id, input.Document.Content); err == nil { + if inputDocument, err = Conductor.NewDocument(input.Document.Id, input.Document.Content); err == nil { } else { return nil, err } } - _result, _err := conductor.Echo(inputDocument, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.Echo(inputDocument, context.Identity()) + if err != nil { return nil, err } - _ = _result - var outputDocument *Document = nil - if _result.Document() != nil { + if commandResult.Document() != nil { outputDocument = &Document{ - Id: _result.Document().Id(), - Content: _result.Document().Content(), + Id: commandResult.Document().Id(), + Content: commandResult.Document().Content(), } } diff --git a/components/api/services/follow_actor_service.go b/components/api/services/follow_actor_service.go index 4ca3c19..9f70a85 100644 --- a/components/api/services/follow_actor_service.go +++ b/components/api/services/follow_actor_service.go @@ -3,26 +3,21 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func FollowActorService(context IContext, input *FollowActorRequest) (result *FollowActorResult, err error) { - conductor := core.Conductor + source := "follow_actor" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "follow_actor", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "follow_actor", input, result, err) }() - - _result, _err := conductor.FollowActor(input.Username, input.Acct, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.FollowActor(input.Username, input.Acct, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*FollowActorResult) - result.Url = _result.Url() + result.Url = commandResult.Url() return result, nil } diff --git a/components/api/services/get_actor_service.go b/components/api/services/get_actor_service.go index d7ae071..a364f08 100644 --- a/components/api/services/get_actor_service.go +++ b/components/api/services/get_actor_service.go @@ -3,71 +3,66 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetActorService(context IContext, input *GetActorRequest) (result *GetActorResult, err error) { - conductor := core.Conductor + source := "get_actor" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_actor", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_actor", input, result, err) }() - - _result, _err := conductor.GetActor(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetActor(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - var outputIcon *ActivityPubMedia = nil - if _result.Icon() != nil { + if commandResult.Icon() != nil { outputIcon = &ActivityPubMedia{ - MediaType: _result.Icon().MediaType(), - Type: _result.Icon().Type(), - Url: _result.Icon().Url(), - Width: _result.Icon().Width(), - Height: _result.Icon().Height(), + MediaType: commandResult.Icon().MediaType(), + Type: commandResult.Icon().Type(), + Url: commandResult.Icon().Url(), + Width: commandResult.Icon().Width(), + Height: commandResult.Icon().Height(), } } var outputImage *ActivityPubMedia = nil - if _result.Image() != nil { + if commandResult.Image() != nil { outputImage = &ActivityPubMedia{ - MediaType: _result.Image().MediaType(), - Type: _result.Image().Type(), - Url: _result.Image().Url(), - Width: _result.Image().Width(), - Height: _result.Image().Height(), + MediaType: commandResult.Image().MediaType(), + Type: commandResult.Image().Type(), + Url: commandResult.Image().Url(), + Width: commandResult.Image().Width(), + Height: commandResult.Image().Height(), } } var outputPublicKey *ActivityPubPublicKey = nil - if _result.PublicKey() != nil { + if commandResult.PublicKey() != nil { outputPublicKey = &ActivityPubPublicKey{ - Id: _result.PublicKey().Id(), - Owner: _result.PublicKey().Owner(), - PublicKeyPem: _result.PublicKey().PublicKeyPem(), + Id: commandResult.PublicKey().Id(), + Owner: commandResult.PublicKey().Owner(), + PublicKeyPem: commandResult.PublicKey().PublicKeyPem(), } } result = context.ResultContainer().(*GetActorResult) - result.Context = _result.Context() - result.Id = _result.Id() - result.Followers = _result.Followers() - result.Following = _result.Following() - result.Inbox = _result.Inbox() - result.Outbox = _result.Outbox() - result.Name = _result.Name() - result.PreferredUsername = _result.PreferredUsername() - result.Type = _result.Type() - result.Url = _result.Url() + result.Context = commandResult.Context() + result.Id = commandResult.Id() + result.Followers = commandResult.Followers() + result.Following = commandResult.Following() + result.Inbox = commandResult.Inbox() + result.Outbox = commandResult.Outbox() + result.Name = commandResult.Name() + result.PreferredUsername = commandResult.PreferredUsername() + result.Type = commandResult.Type() + result.Url = commandResult.Url() result.Icon = outputIcon result.Image = outputImage result.PublicKey = outputPublicKey - result.Summary = _result.Summary() - result.Published = _result.Published() + result.Summary = commandResult.Summary() + result.Published = commandResult.Published() return result, nil } diff --git a/components/api/services/get_followers_service.go b/components/api/services/get_followers_service.go index 0666078..7bce9ea 100644 --- a/components/api/services/get_followers_service.go +++ b/components/api/services/get_followers_service.go @@ -3,31 +3,26 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetFollowersService(context IContext, input *GetFollowersRequest) (result *GetFollowersResult, err error) { - conductor := core.Conductor + source := "get_followers" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_followers", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_followers", input, result, err) }() - - _result, _err := conductor.GetFollowers(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetFollowers(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*GetFollowersResult) - result.Context = _result.Context() - result.Id = _result.Id() - result.Type = _result.Type() - result.TotalItems = _result.TotalItems() - result.OrderedItems = _result.OrderedItems() - result.First = _result.First() + result.Context = commandResult.Context() + result.Id = commandResult.Id() + result.Type = commandResult.Type() + result.TotalItems = commandResult.TotalItems() + result.OrderedItems = commandResult.OrderedItems() + result.First = commandResult.First() return result, nil } diff --git a/components/api/services/get_following_service.go b/components/api/services/get_following_service.go index a041055..d04e112 100644 --- a/components/api/services/get_following_service.go +++ b/components/api/services/get_following_service.go @@ -3,31 +3,26 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetFollowingService(context IContext, input *GetFollowingRequest) (result *GetFollowingResult, err error) { - conductor := core.Conductor + source := "get_following" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_following", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_following", input, result, err) }() - - _result, _err := conductor.GetFollowing(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetFollowing(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*GetFollowingResult) - result.Context = _result.Context() - result.Id = _result.Id() - result.Type = _result.Type() - result.TotalItems = _result.TotalItems() - result.OrderedItems = _result.OrderedItems() - result.First = _result.First() + result.Context = commandResult.Context() + result.Id = commandResult.Id() + result.Type = commandResult.Type() + result.TotalItems = commandResult.TotalItems() + result.OrderedItems = commandResult.OrderedItems() + result.First = commandResult.First() return result, nil } diff --git a/components/api/services/get_inbox_service.go b/components/api/services/get_inbox_service.go index 67c1c06..016ae61 100644 --- a/components/api/services/get_inbox_service.go +++ b/components/api/services/get_inbox_service.go @@ -3,27 +3,22 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetInboxService(context IContext, input *GetInboxRequest) (result *GetInboxResult, err error) { - conductor := core.Conductor + source := "get_inbox" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_inbox", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_inbox", input, result, err) }() - - _result, _err := conductor.GetInbox(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetInbox(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - outputOrderedItems := make([]*ActivityPubActivity, 0) - for _, orderedItem := range _result.OrderedItems() { + for _, orderedItem := range commandResult.OrderedItems() { if orderedItem == nil { continue } @@ -58,11 +53,11 @@ func GetInboxService(context IContext, input *GetInboxRequest) (result *GetInbox } result = context.ResultContainer().(*GetInboxResult) - result.Context = _result.Context() - result.Id = _result.Id() - result.Type = _result.Type() - result.TotalItems = _result.TotalItems() + result.Context = commandResult.Context() + result.Id = commandResult.Id() + result.Type = commandResult.Type() + result.TotalItems = commandResult.TotalItems() result.OrderedItems = outputOrderedItems - result.First = _result.First() + result.First = commandResult.First() return result, nil } diff --git a/components/api/services/get_outbox_service.go b/components/api/services/get_outbox_service.go index e6caacf..913c3da 100644 --- a/components/api/services/get_outbox_service.go +++ b/components/api/services/get_outbox_service.go @@ -3,27 +3,22 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetOutboxService(context IContext, input *GetOutboxRequest) (result *GetOutboxResult, err error) { - conductor := core.Conductor + source := "get_outbox" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_outbox", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_outbox", input, result, err) }() - - _result, _err := conductor.GetOutbox(input.Username, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetOutbox(input.Username, context.Identity()) + if err != nil { return nil, err } - _ = _result - outputOrderedItems := make([]*ActivityPubActivity, 0) - for _, orderedItem := range _result.OrderedItems() { + for _, orderedItem := range commandResult.OrderedItems() { if orderedItem == nil { continue } @@ -58,11 +53,11 @@ func GetOutboxService(context IContext, input *GetOutboxRequest) (result *GetOut } result = context.ResultContainer().(*GetOutboxResult) - result.Context = _result.Context() - result.Id = _result.Id() - result.Type = _result.Type() - result.TotalItems = _result.TotalItems() + result.Context = commandResult.Context() + result.Id = commandResult.Id() + result.Type = commandResult.Type() + result.TotalItems = commandResult.TotalItems() result.OrderedItems = outputOrderedItems - result.First = _result.First() + result.First = commandResult.First() return result, nil } diff --git a/components/api/services/get_packages_service.go b/components/api/services/get_packages_service.go index 6f1e270..2b48c96 100644 --- a/components/api/services/get_packages_service.go +++ b/components/api/services/get_packages_service.go @@ -3,26 +3,21 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetPackagesService(context IContext, input *GetPackagesRequest) (result *GetPackagesResult, err error) { - conductor := core.Conductor + source := "get_packages" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_packages", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_packages", input, result, err) }() - - _result, _err := conductor.GetPackages(context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetPackages(context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*GetPackagesResult) - result.Body = _result.Body() + result.Body = commandResult.Body() return result, nil } diff --git a/components/api/services/get_profile_by_user_service.go b/components/api/services/get_profile_by_user_service.go index f38834e..751ce53 100644 --- a/components/api/services/get_profile_by_user_service.go +++ b/components/api/services/get_profile_by_user_service.go @@ -3,31 +3,26 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func GetProfileByUserService(context IContext, input *GetProfileByUserRequest) (result *GetProfileByUserResult, err error) { - conductor := core.Conductor + source := "get_profile_by_user" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "get_profile_by_user", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_profile_by_user", input, result, err) }() - - _result, _err := conductor.GetProfileByUser(context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.GetProfileByUser(context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*GetProfileByUserResult) - result.Username = _result.Username() - result.DisplayName = _result.DisplayName() - result.Avatar = _result.Avatar() - result.Banner = _result.Banner() - result.Summary = _result.Summary() - result.Github = _result.Github() + result.Username = commandResult.Username() + result.DisplayName = commandResult.DisplayName() + result.Avatar = commandResult.Avatar() + result.Banner = commandResult.Banner() + result.Summary = commandResult.Summary() + result.Github = commandResult.Github() return result, nil } diff --git a/components/api/services/login_service.go b/components/api/services/login_service.go index 2070219..102bcea 100644 --- a/components/api/services/login_service.go +++ b/components/api/services/login_service.go @@ -3,28 +3,23 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func LoginService(context IContext, input *LoginRequest) (result *LoginResult, err error) { - conductor := core.Conductor + source := "login" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "login", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "login", input, result, err) }() - - _result, _err := conductor.Login(input.Email, input.Password, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.Login(input.Email, input.Password, context.Identity()) + if err != nil { return nil, err } - _ = _result - - context.SetCookie("Diamante", _result.Token()) + context.SetCookie("Diamante", commandResult.Token()) result = context.ResultContainer().(*LoginResult) - result.Username = _result.Username() - result.Token = _result.Token() + result.Username = commandResult.Username() + result.Token = commandResult.Token() return result, nil } diff --git a/components/api/services/logout_service.go b/components/api/services/logout_service.go index 1ab2bd3..f0f2481 100644 --- a/components/api/services/logout_service.go +++ b/components/api/services/logout_service.go @@ -3,25 +3,19 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func LogoutService(context IContext, input *LogoutRequest) (result *LogoutResult, err error) { - conductor := core.Conductor + source := "logout" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "logout", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "logout", input, result, err) }() - - _result, _err := conductor.Logout(context.Identity()) - if _err != nil { - err = _err + if _, err = Conductor.Logout(context.Identity()); err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*LogoutResult) return result, nil } diff --git a/components/api/services/post_to_inbox_service.go b/components/api/services/post_to_inbox_service.go index ee5940a..a056551 100644 --- a/components/api/services/post_to_inbox_service.go +++ b/components/api/services/post_to_inbox_service.go @@ -3,26 +3,21 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func PostToInboxService(context IContext, input *PostToInboxRequest) (result *PostToInboxResult, err error) { - conductor := core.Conductor + source := "post_to_inbox" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "post_to_inbox", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_inbox", input, result, err) }() - - _result, _err := conductor.PostToInbox(input.Username, input.Body, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.PostToInbox(input.Username, input.Body, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*PostToInboxResult) - result.Body = _result.Body() + result.Body = commandResult.Body() return result, nil } diff --git a/components/api/services/post_to_outbox_service.go b/components/api/services/post_to_outbox_service.go index 663a6d5..3768b55 100644 --- a/components/api/services/post_to_outbox_service.go +++ b/components/api/services/post_to_outbox_service.go @@ -3,26 +3,21 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func PostToOutboxService(context IContext, input *PostToOutboxRequest) (result *PostToOutboxResult, err error) { - conductor := core.Conductor + source := "post_to_outbox" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "post_to_outbox", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_outbox", input, result, err) }() - - _result, _err := conductor.PostToOutbox(input.Username, input.Body, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.PostToOutbox(input.Username, input.Body, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*PostToOutboxResult) - result.Body = _result.Body() + result.Body = commandResult.Body() return result, nil } diff --git a/components/api/services/reset_password_service.go b/components/api/services/reset_password_service.go index bb928ee..83442a9 100644 --- a/components/api/services/reset_password_service.go +++ b/components/api/services/reset_password_service.go @@ -3,25 +3,19 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func ResetPasswordService(context IContext, input *ResetPasswordRequest) (result *ResetPasswordResult, err error) { - conductor := core.Conductor + source := "reset_password" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "reset_password", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "reset_password", input, result, err) }() - - _result, _err := conductor.ResetPassword(input.UsernameOrEmail, context.Identity()) - if _err != nil { - err = _err + if _, err = Conductor.ResetPassword(input.UsernameOrEmail, context.Identity()); err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*ResetPasswordResult) return result, nil } diff --git a/components/api/services/signup_service.go b/components/api/services/signup_service.go index b612111..f941135 100644 --- a/components/api/services/signup_service.go +++ b/components/api/services/signup_service.go @@ -3,28 +3,23 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func SignupService(context IContext, input *SignupRequest) (result *SignupResult, err error) { - conductor := core.Conductor + source := "signup" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "signup", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "signup", input, result, err) }() - - _result, _err := conductor.Signup(input.Username, input.Email, input.Password, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.Signup(input.Username, input.Email, input.Password, context.Identity()) + if err != nil { return nil, err } - _ = _result - - context.SetCookie("Diamante", _result.Token()) + context.SetCookie("Diamante", commandResult.Token()) result = context.ResultContainer().(*SignupResult) - result.Token = _result.Token() - result.Code = _result.Code() + result.Token = commandResult.Token() + result.Code = commandResult.Code() return result, nil } diff --git a/components/api/services/system_call_service.go b/components/api/services/system_call_service.go index 09d9e76..c4cf397 100644 --- a/components/api/services/system_call_service.go +++ b/components/api/services/system_call_service.go @@ -7,16 +7,14 @@ import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/constants" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func SystemCallService(context IContext, input *SystemCallRequest) (result *SystemCallResult, err error) { - conductor := core.Conductor - - conductor.LogRemoteCall(context, INITIALIZE, "system_call", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "system_call", input, result, err) }() + source := "system_call" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() context.Logger().SysCall(fmt.Sprintf("SYSCALL: %s", input.Command)) @@ -34,7 +32,7 @@ func SystemCallService(context IContext, input *SystemCallRequest) (result *Syst } componentName := args[1] - if component := conductor.GetSystemComponent(componentName); component == nil { + if component := Conductor.GetSystemComponent(componentName); component == nil { return nil, ERROR_SYSTEM_COMPONENT_NOT_FOUND } else if err := component.Reload(); err != nil { return nil, err diff --git a/components/api/services/update_profile_by_user_service.go b/components/api/services/update_profile_by_user_service.go index 730b235..a57ecb5 100644 --- a/components/api/services/update_profile_by_user_service.go +++ b/components/api/services/update_profile_by_user_service.go @@ -3,30 +3,25 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func UpdateProfileByUserService(context IContext, input *UpdateProfileByUserRequest) (result *UpdateProfileByUserResult, err error) { - conductor := core.Conductor + source := "update_profile_by_user" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "update_profile_by_user", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "update_profile_by_user", input, result, err) }() - - _result, _err := conductor.UpdateProfileByUser(input.DisplayName, input.Avatar, input.Banner, input.Summary, input.Github, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.UpdateProfileByUser(input.DisplayName, input.Avatar, input.Banner, input.Summary, input.Github, context.Identity()) + if err != nil { return nil, err } - _ = _result - result = context.ResultContainer().(*UpdateProfileByUserResult) - result.DisplayName = _result.DisplayName() - result.Avatar = _result.Avatar() - result.Banner = _result.Banner() - result.Summary = _result.Summary() - result.Github = _result.Github() + result.DisplayName = commandResult.DisplayName() + result.Avatar = commandResult.Avatar() + result.Banner = commandResult.Banner() + result.Summary = commandResult.Summary() + result.Github = commandResult.Github() return result, nil } diff --git a/components/api/services/verify_service.go b/components/api/services/verify_service.go index e11aaf2..c37a3f9 100644 --- a/components/api/services/verify_service.go +++ b/components/api/services/verify_service.go @@ -3,27 +3,22 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func VerifyService(context IContext, input *VerifyRequest) (result *VerifyResult, err error) { - conductor := core.Conductor + source := "verify" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "verify", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "verify", input, result, err) }() - - _result, _err := conductor.Verify(input.Email, input.Token, input.Code, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.Verify(input.Email, input.Token, input.Code, context.Identity()) + if err != nil { return nil, err } - _ = _result - - context.SetCookie("Diamante", _result.Token()) + context.SetCookie("Diamante", commandResult.Token()) result = context.ResultContainer().(*VerifyResult) - result.Token = _result.Token() + result.Token = commandResult.Token() return result, nil } diff --git a/components/api/services/webfinger_service.go b/components/api/services/webfinger_service.go index 67e464d..5f36570 100644 --- a/components/api/services/webfinger_service.go +++ b/components/api/services/webfinger_service.go @@ -3,27 +3,22 @@ package services import ( . "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/contracts" - "github.com/reiver/greatape/components/core" + . "github.com/reiver/greatape/components/core" . "github.com/xeronith/diamante/contracts/service" ) -// noinspection GoUnusedParameter func WebfingerService(context IContext, input *WebfingerRequest) (result *WebfingerResult, err error) { - conductor := core.Conductor + source := "webfinger" + /* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err) + defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }() - conductor.LogRemoteCall(context, INITIALIZE, "webfinger", input, result, err) - defer func() { conductor.LogRemoteCall(context, FINALIZE, "webfinger", input, result, err) }() - - _result, _err := conductor.Webfinger(input.Resource, context.Identity()) - if _err != nil { - err = _err + commandResult, err := Conductor.Webfinger(input.Resource, context.Identity()) + if err != nil { return nil, err } - _ = _result - outputLinks := make([]*ActivityPubLink, 0) - for _, link := range _result.Links() { + for _, link := range commandResult.Links() { if link == nil { continue } @@ -37,8 +32,8 @@ func WebfingerService(context IContext, input *WebfingerRequest) (result *Webfin } result = context.ResultContainer().(*WebfingerResult) - result.Aliases = _result.Aliases() + result.Aliases = commandResult.Aliases() result.Links = outputLinks - result.Subject = _result.Subject() + result.Subject = commandResult.Subject() return result, nil } diff --git a/components/contracts/system_component.go b/components/contracts/system_component.go index eb1dc9c..25d554f 100644 --- a/components/contracts/system_component.go +++ b/components/contracts/system_component.go @@ -9,8 +9,8 @@ import ( ) const ( - INITIALIZE = 0 - FINALIZE = 100 + INIT = 0 + DONE = 100 ) type (