kopia lustrzana https://github.com/reiver/greatape
Porównaj commity
3 Commity
071028aa39
...
a107dcd600
Autor | SHA1 | Data |
---|---|---|
Xeronith | a107dcd600 | |
Xeronith | d28e95bccd | |
Xeronith | e45f4634fd |
|
@ -0,0 +1,11 @@
|
||||||
|
package validators
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
. "github.com/reiver/greatape/components/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EmailIsValid(input string) bool {
|
||||||
|
return regexp.MustCompile(EMAIL).MatchString(input)
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package validators_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/reiver/greatape/app/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEmailValidator(test *testing.T) {
|
||||||
|
type arguments struct {
|
||||||
|
email string
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
expectation bool
|
||||||
|
arguments arguments
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"Case1",
|
||||||
|
false,
|
||||||
|
arguments{
|
||||||
|
email: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case2",
|
||||||
|
false,
|
||||||
|
arguments{
|
||||||
|
email: "user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case3",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "user@domain.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case4",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "user+plus@gmail.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case5",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "susan235@gmail.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case6",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "new_user@icloud.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case7",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "someone@somewhere.co.uk",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case8",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
email: "north.star@space.social",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
test.Run(testCase.name, func(test *testing.T) {
|
||||||
|
if result := validators.EmailIsValid(testCase.arguments.email); result != testCase.expectation {
|
||||||
|
test.Errorf("EmailIsValid() = %v, expected %v", result, testCase.expectation)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package validators
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
. "github.com/reiver/greatape/components/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func WebfingerIsValid(webfinger string) bool {
|
||||||
|
return regexp.MustCompile(WEBFINGER).MatchString(webfinger)
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package validators_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/reiver/greatape/app/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestWebfingerValidator(test *testing.T) {
|
||||||
|
type arguments struct {
|
||||||
|
webfinger string
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
expectation bool
|
||||||
|
arguments arguments
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"Case1",
|
||||||
|
false,
|
||||||
|
arguments{
|
||||||
|
webfinger: "somebody@somewhere.xyz",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case2",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
webfinger: "acct:somebody@somewhere.xyz",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case3",
|
||||||
|
true,
|
||||||
|
arguments{
|
||||||
|
webfinger: "acct:user@sub.domain.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Case4",
|
||||||
|
false,
|
||||||
|
arguments{
|
||||||
|
webfinger: "acct:user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
test.Run(testCase.name, func(test *testing.T) {
|
||||||
|
if result := validators.WebfingerIsValid(testCase.arguments.webfinger); result != testCase.expectation {
|
||||||
|
test.Errorf("WebfingerIsValid() = %v, expected %v", result, testCase.expectation)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -221,11 +221,12 @@ func (manager *spiManager) Echo(document IDocument, editor Identity) (result IEc
|
||||||
editor.Lock(ECHO_REQUEST)
|
editor.Lock(ECHO_REQUEST)
|
||||||
defer editor.Unlock(ECHO_REQUEST)
|
defer editor.Unlock(ECHO_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Echo(NewDispatcher(Conductor, editor), document); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Echo(dispatcher, document); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetServerConfigurationResult Implementation
|
//region IGetServerConfigurationResult Implementation
|
||||||
|
@ -268,11 +269,12 @@ func (manager *spiManager) GetServerConfiguration(editor Identity) (result IGetS
|
||||||
editor.Lock(GET_SERVER_CONFIGURATION_REQUEST)
|
editor.Lock(GET_SERVER_CONFIGURATION_REQUEST)
|
||||||
defer editor.Unlock(GET_SERVER_CONFIGURATION_REQUEST)
|
defer editor.Unlock(GET_SERVER_CONFIGURATION_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetServerConfiguration(NewDispatcher(Conductor, editor)); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetServerConfiguration(dispatcher); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region ICheckUsernameAvailabilityResult Implementation
|
//region ICheckUsernameAvailabilityResult Implementation
|
||||||
|
@ -307,11 +309,12 @@ func (manager *spiManager) CheckUsernameAvailability(username string, editor Ide
|
||||||
editor.Lock(CHECK_USERNAME_AVAILABILITY_REQUEST)
|
editor.Lock(CHECK_USERNAME_AVAILABILITY_REQUEST)
|
||||||
defer editor.Unlock(CHECK_USERNAME_AVAILABILITY_REQUEST)
|
defer editor.Unlock(CHECK_USERNAME_AVAILABILITY_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.CheckUsernameAvailability(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.CheckUsernameAvailability(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region ISignupResult Implementation
|
//region ISignupResult Implementation
|
||||||
|
@ -339,18 +342,14 @@ func (result signupResult) Code() string {
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) Signup(username string, email string, password string, editor Identity) (result ISignupResult, err error) {
|
func (manager *spiManager) Signup(username string, email string, password string, editor Identity) (result ISignupResult, err error) {
|
||||||
if email != "" {
|
|
||||||
if match, err := manager.Match(EMAIL, email); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if !match {
|
|
||||||
return nil, ERROR_INVALID_EMAIL_FOR_SIGNUP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !validators.UsernameIsValid(username) {
|
if !validators.UsernameIsValid(username) {
|
||||||
return nil, ERROR_INVALID_USERNAME_FOR_SIGNUP
|
return nil, ERROR_INVALID_USERNAME_FOR_SIGNUP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !validators.EmailIsValid(email) {
|
||||||
|
return nil, ERROR_INVALID_EMAIL_FOR_SIGNUP
|
||||||
|
}
|
||||||
|
|
||||||
if !validators.PasswordIsValid(password) {
|
if !validators.PasswordIsValid(password) {
|
||||||
return nil, ERROR_INVALID_PASSWORD_FOR_SIGNUP
|
return nil, ERROR_INVALID_PASSWORD_FOR_SIGNUP
|
||||||
}
|
}
|
||||||
|
@ -364,11 +363,12 @@ func (manager *spiManager) Signup(username string, email string, password string
|
||||||
editor.Lock(SIGNUP_REQUEST)
|
editor.Lock(SIGNUP_REQUEST)
|
||||||
defer editor.Unlock(SIGNUP_REQUEST)
|
defer editor.Unlock(SIGNUP_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Signup(NewDispatcher(Conductor, editor), username, email, password); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Signup(dispatcher, username, email, password); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IResendVerificationCodeResult Implementation
|
//region IResendVerificationCodeResult Implementation
|
||||||
|
@ -390,12 +390,8 @@ func (result resendVerificationCodeResult) Code() string {
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) ResendVerificationCode(email string, editor Identity) (result IResendVerificationCodeResult, err error) {
|
func (manager *spiManager) ResendVerificationCode(email string, editor Identity) (result IResendVerificationCodeResult, err error) {
|
||||||
if email != "" {
|
if !validators.EmailIsValid(email) {
|
||||||
if match, err := manager.Match(EMAIL, email); err != nil {
|
return nil, ERROR_INVALID_EMAIL_FOR_RESEND_VERIFICATION_CODE
|
||||||
return nil, err
|
|
||||||
} else if !match {
|
|
||||||
return nil, ERROR_INVALID_EMAIL_FOR_RESEND_VERIFICATION_CODE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -407,11 +403,12 @@ func (manager *spiManager) ResendVerificationCode(email string, editor Identity)
|
||||||
editor.Lock(RESEND_VERIFICATION_CODE_REQUEST)
|
editor.Lock(RESEND_VERIFICATION_CODE_REQUEST)
|
||||||
defer editor.Unlock(RESEND_VERIFICATION_CODE_REQUEST)
|
defer editor.Unlock(RESEND_VERIFICATION_CODE_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.ResendVerificationCode(NewDispatcher(Conductor, editor), email); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.ResendVerificationCode(dispatcher, email); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IVerifyResult Implementation
|
//region IVerifyResult Implementation
|
||||||
|
@ -433,12 +430,8 @@ func (result verifyResult) Token() string {
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) Verify(email string, token string, code string, editor Identity) (result IVerifyResult, err error) {
|
func (manager *spiManager) Verify(email string, token string, code string, editor Identity) (result IVerifyResult, err error) {
|
||||||
if email != "" {
|
if !validators.EmailIsValid(email) {
|
||||||
if match, err := manager.Match(EMAIL, email); err != nil {
|
return nil, ERROR_INVALID_EMAIL_FOR_VERIFY
|
||||||
return nil, err
|
|
||||||
} else if !match {
|
|
||||||
return nil, ERROR_INVALID_EMAIL_FOR_VERIFY
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -450,11 +443,12 @@ func (manager *spiManager) Verify(email string, token string, code string, edito
|
||||||
editor.Lock(VERIFY_REQUEST)
|
editor.Lock(VERIFY_REQUEST)
|
||||||
defer editor.Unlock(VERIFY_REQUEST)
|
defer editor.Unlock(VERIFY_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Verify(NewDispatcher(Conductor, editor), email, token, code); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Verify(dispatcher, email, token, code); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region ILoginResult Implementation
|
//region ILoginResult Implementation
|
||||||
|
@ -482,12 +476,8 @@ func (result loginResult) Token() string {
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) Login(email string, password string, editor Identity) (result ILoginResult, err error) {
|
func (manager *spiManager) Login(email string, password string, editor Identity) (result ILoginResult, err error) {
|
||||||
if email != "" {
|
if !validators.EmailIsValid(email) {
|
||||||
if match, err := manager.Match(EMAIL, email); err != nil {
|
return nil, ERROR_INVALID_EMAIL_FOR_LOGIN
|
||||||
return nil, err
|
|
||||||
} else if !match {
|
|
||||||
return nil, ERROR_INVALID_EMAIL_FOR_LOGIN
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !validators.PasswordIsValid(password) {
|
if !validators.PasswordIsValid(password) {
|
||||||
|
@ -503,11 +493,12 @@ func (manager *spiManager) Login(email string, password string, editor Identity)
|
||||||
editor.Lock(LOGIN_REQUEST)
|
editor.Lock(LOGIN_REQUEST)
|
||||||
defer editor.Unlock(LOGIN_REQUEST)
|
defer editor.Unlock(LOGIN_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Login(NewDispatcher(Conductor, editor), email, password); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Login(dispatcher, email, password); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetProfileByUserResult Implementation
|
//region IGetProfileByUserResult Implementation
|
||||||
|
@ -568,11 +559,12 @@ func (manager *spiManager) GetProfileByUser(editor Identity) (result IGetProfile
|
||||||
editor.Lock(GET_PROFILE_BY_USER_REQUEST)
|
editor.Lock(GET_PROFILE_BY_USER_REQUEST)
|
||||||
defer editor.Unlock(GET_PROFILE_BY_USER_REQUEST)
|
defer editor.Unlock(GET_PROFILE_BY_USER_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetProfileByUser(NewDispatcher(Conductor, editor)); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetProfileByUser(dispatcher); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IUpdateProfileByUserResult Implementation
|
//region IUpdateProfileByUserResult Implementation
|
||||||
|
@ -627,11 +619,12 @@ func (manager *spiManager) UpdateProfileByUser(displayName string, avatar string
|
||||||
editor.Lock(UPDATE_PROFILE_BY_USER_REQUEST)
|
editor.Lock(UPDATE_PROFILE_BY_USER_REQUEST)
|
||||||
defer editor.Unlock(UPDATE_PROFILE_BY_USER_REQUEST)
|
defer editor.Unlock(UPDATE_PROFILE_BY_USER_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.UpdateProfileByUser(NewDispatcher(Conductor, editor), displayName, avatar, banner, summary, github); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.UpdateProfileByUser(dispatcher, displayName, avatar, banner, summary, github); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IChangePasswordResult Implementation
|
//region IChangePasswordResult Implementation
|
||||||
|
@ -663,11 +656,12 @@ func (manager *spiManager) ChangePassword(currentPassword string, newPassword st
|
||||||
editor.Lock(CHANGE_PASSWORD_REQUEST)
|
editor.Lock(CHANGE_PASSWORD_REQUEST)
|
||||||
defer editor.Unlock(CHANGE_PASSWORD_REQUEST)
|
defer editor.Unlock(CHANGE_PASSWORD_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.ChangePassword(NewDispatcher(Conductor, editor), currentPassword, newPassword); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.ChangePassword(dispatcher, currentPassword, newPassword); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IResetPasswordResult Implementation
|
//region IResetPasswordResult Implementation
|
||||||
|
@ -691,11 +685,12 @@ func (manager *spiManager) ResetPassword(usernameOrEmail string, editor Identity
|
||||||
editor.Lock(RESET_PASSWORD_REQUEST)
|
editor.Lock(RESET_PASSWORD_REQUEST)
|
||||||
defer editor.Unlock(RESET_PASSWORD_REQUEST)
|
defer editor.Unlock(RESET_PASSWORD_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.ResetPassword(NewDispatcher(Conductor, editor), usernameOrEmail); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.ResetPassword(dispatcher, usernameOrEmail); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region ILogoutResult Implementation
|
//region ILogoutResult Implementation
|
||||||
|
@ -719,11 +714,12 @@ func (manager *spiManager) Logout(editor Identity) (result ILogoutResult, err er
|
||||||
editor.Lock(LOGOUT_REQUEST)
|
editor.Lock(LOGOUT_REQUEST)
|
||||||
defer editor.Unlock(LOGOUT_REQUEST)
|
defer editor.Unlock(LOGOUT_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Logout(NewDispatcher(Conductor, editor)); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Logout(dispatcher); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IWebfingerResult Implementation
|
//region IWebfingerResult Implementation
|
||||||
|
@ -757,9 +753,7 @@ func (result webfingerResult) Subject() string {
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) Webfinger(resource string, editor Identity) (result IWebfingerResult, err error) {
|
func (manager *spiManager) Webfinger(resource string, editor Identity) (result IWebfingerResult, err error) {
|
||||||
if match, err := manager.Match(WEBFINGER, resource); err != nil {
|
if !validators.WebfingerIsValid(resource) {
|
||||||
return nil, err
|
|
||||||
} else if !match {
|
|
||||||
return nil, ERROR_INVALID_RESOURCE_FOR_WEBFINGER
|
return nil, ERROR_INVALID_RESOURCE_FOR_WEBFINGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,11 +766,12 @@ func (manager *spiManager) Webfinger(resource string, editor Identity) (result I
|
||||||
editor.Lock(WEBFINGER_REQUEST)
|
editor.Lock(WEBFINGER_REQUEST)
|
||||||
defer editor.Unlock(WEBFINGER_REQUEST)
|
defer editor.Unlock(WEBFINGER_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.Webfinger(NewDispatcher(Conductor, editor), resource); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.Webfinger(dispatcher, resource); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetPackagesResult Implementation
|
//region IGetPackagesResult Implementation
|
||||||
|
@ -807,11 +802,12 @@ func (manager *spiManager) GetPackages(editor Identity) (result IGetPackagesResu
|
||||||
editor.Lock(GET_PACKAGES_REQUEST)
|
editor.Lock(GET_PACKAGES_REQUEST)
|
||||||
defer editor.Unlock(GET_PACKAGES_REQUEST)
|
defer editor.Unlock(GET_PACKAGES_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetPackages(NewDispatcher(Conductor, editor)); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetPackages(dispatcher); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetActorResult Implementation
|
//region IGetActorResult Implementation
|
||||||
|
@ -926,11 +922,12 @@ func (manager *spiManager) GetActor(username string, editor Identity) (result IG
|
||||||
editor.Lock(GET_ACTOR_REQUEST)
|
editor.Lock(GET_ACTOR_REQUEST)
|
||||||
defer editor.Unlock(GET_ACTOR_REQUEST)
|
defer editor.Unlock(GET_ACTOR_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetActor(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetActor(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IFollowActorResult Implementation
|
//region IFollowActorResult Implementation
|
||||||
|
@ -961,11 +958,12 @@ func (manager *spiManager) FollowActor(username string, acct string, editor Iden
|
||||||
editor.Lock(FOLLOW_ACTOR_REQUEST)
|
editor.Lock(FOLLOW_ACTOR_REQUEST)
|
||||||
defer editor.Unlock(FOLLOW_ACTOR_REQUEST)
|
defer editor.Unlock(FOLLOW_ACTOR_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.FollowActor(NewDispatcher(Conductor, editor), username, acct); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.FollowActor(dispatcher, username, acct); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IAuthorizeInteractionResult Implementation
|
//region IAuthorizeInteractionResult Implementation
|
||||||
|
@ -1002,11 +1000,12 @@ func (manager *spiManager) AuthorizeInteraction(uri string, editor Identity) (re
|
||||||
editor.Lock(AUTHORIZE_INTERACTION_REQUEST)
|
editor.Lock(AUTHORIZE_INTERACTION_REQUEST)
|
||||||
defer editor.Unlock(AUTHORIZE_INTERACTION_REQUEST)
|
defer editor.Unlock(AUTHORIZE_INTERACTION_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.AuthorizeInteraction(NewDispatcher(Conductor, editor), uri); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.AuthorizeInteraction(dispatcher, uri); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetFollowersResult Implementation
|
//region IGetFollowersResult Implementation
|
||||||
|
@ -1067,11 +1066,12 @@ func (manager *spiManager) GetFollowers(username string, editor Identity) (resul
|
||||||
editor.Lock(GET_FOLLOWERS_REQUEST)
|
editor.Lock(GET_FOLLOWERS_REQUEST)
|
||||||
defer editor.Unlock(GET_FOLLOWERS_REQUEST)
|
defer editor.Unlock(GET_FOLLOWERS_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetFollowers(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetFollowers(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetFollowingResult Implementation
|
//region IGetFollowingResult Implementation
|
||||||
|
@ -1132,11 +1132,12 @@ func (manager *spiManager) GetFollowing(username string, editor Identity) (resul
|
||||||
editor.Lock(GET_FOLLOWING_REQUEST)
|
editor.Lock(GET_FOLLOWING_REQUEST)
|
||||||
defer editor.Unlock(GET_FOLLOWING_REQUEST)
|
defer editor.Unlock(GET_FOLLOWING_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetFollowing(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetFollowing(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IPostToOutboxResult Implementation
|
//region IPostToOutboxResult Implementation
|
||||||
|
@ -1167,11 +1168,12 @@ func (manager *spiManager) PostToOutbox(username string, body []byte, editor Ide
|
||||||
editor.Lock(POST_TO_OUTBOX_REQUEST)
|
editor.Lock(POST_TO_OUTBOX_REQUEST)
|
||||||
defer editor.Unlock(POST_TO_OUTBOX_REQUEST)
|
defer editor.Unlock(POST_TO_OUTBOX_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.PostToOutbox(NewDispatcher(Conductor, editor), username, body); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.PostToOutbox(dispatcher, username, body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetOutboxResult Implementation
|
//region IGetOutboxResult Implementation
|
||||||
|
@ -1232,11 +1234,12 @@ func (manager *spiManager) GetOutbox(username string, editor Identity) (result I
|
||||||
editor.Lock(GET_OUTBOX_REQUEST)
|
editor.Lock(GET_OUTBOX_REQUEST)
|
||||||
defer editor.Unlock(GET_OUTBOX_REQUEST)
|
defer editor.Unlock(GET_OUTBOX_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetOutbox(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetOutbox(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IPostToInboxResult Implementation
|
//region IPostToInboxResult Implementation
|
||||||
|
@ -1267,11 +1270,12 @@ func (manager *spiManager) PostToInbox(username string, body []byte, editor Iden
|
||||||
editor.Lock(POST_TO_INBOX_REQUEST)
|
editor.Lock(POST_TO_INBOX_REQUEST)
|
||||||
defer editor.Unlock(POST_TO_INBOX_REQUEST)
|
defer editor.Unlock(POST_TO_INBOX_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.PostToInbox(NewDispatcher(Conductor, editor), username, body); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.PostToInbox(dispatcher, username, body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//region IGetInboxResult Implementation
|
//region IGetInboxResult Implementation
|
||||||
|
@ -1332,9 +1336,10 @@ func (manager *spiManager) GetInbox(username string, editor Identity) (result IG
|
||||||
editor.Lock(GET_INBOX_REQUEST)
|
editor.Lock(GET_INBOX_REQUEST)
|
||||||
defer editor.Unlock(GET_INBOX_REQUEST)
|
defer editor.Unlock(GET_INBOX_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.GetInbox(NewDispatcher(Conductor, editor), username); err != nil {
|
dispatcher := NewDispatcher(Conductor, editor)
|
||||||
|
if result, err = commands.GetInbox(dispatcher, username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ require (
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
github.com/sendgrid/sendgrid-go v3.12.0+incompatible
|
github.com/sendgrid/sendgrid-go v3.12.0+incompatible
|
||||||
github.com/valyala/fastjson v1.6.4
|
github.com/valyala/fastjson v1.6.4
|
||||||
github.com/xeronith/diamante v1.15.2
|
github.com/xeronith/diamante v1.15.3
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -64,8 +64,8 @@ github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLr
|
||||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/xeronith/diamante v1.15.2 h1:WQH6hzVEE6Rjcg3/ZepPC5LSbPXMNzYD1hHr5wEybOc=
|
github.com/xeronith/diamante v1.15.3 h1:ASks0WIidHUOhFVBs4HLpLEwFLz5/WGtt1AO9pYjX+o=
|
||||||
github.com/xeronith/diamante v1.15.2/go.mod h1:7kgdoRJVrQvML7Z9BT6di3XU1o2eTeE0hbwy66dMOrA=
|
github.com/xeronith/diamante v1.15.3/go.mod h1:7kgdoRJVrQvML7Z9BT6di3XU1o2eTeE0hbwy66dMOrA=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
|
Ładowanie…
Reference in New Issue