mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 21:32:46 +00:00
Move MakeJoin logic to GMSL (#3081)
This commit is contained in:
parent
0489d16f95
commit
67d6876857
80 changed files with 1158 additions and 494 deletions
|
@ -64,14 +64,34 @@ type idServerStoreInviteResponse struct {
|
|||
}
|
||||
|
||||
var (
|
||||
// ErrMissingParameter is the error raised if a request for 3PID invite has
|
||||
// an incomplete body
|
||||
ErrMissingParameter = errors.New("'address', 'id_server' and 'medium' must all be supplied")
|
||||
// ErrNotTrusted is the error raised if an identity server isn't in the list
|
||||
// of trusted servers in the configuration file.
|
||||
ErrNotTrusted = errors.New("untrusted server")
|
||||
errMissingParameter = fmt.Errorf("'address', 'id_server' and 'medium' must all be supplied")
|
||||
errNotTrusted = fmt.Errorf("untrusted server")
|
||||
)
|
||||
|
||||
// ErrMissingParameter is the error raised if a request for 3PID invite has
|
||||
// an incomplete body
|
||||
type ErrMissingParameter struct{}
|
||||
|
||||
func (e ErrMissingParameter) Error() string {
|
||||
return errMissingParameter.Error()
|
||||
}
|
||||
|
||||
func (e ErrMissingParameter) Unwrap() error {
|
||||
return errMissingParameter
|
||||
}
|
||||
|
||||
// ErrNotTrusted is the error raised if an identity server isn't in the list
|
||||
// of trusted servers in the configuration file.
|
||||
type ErrNotTrusted struct{}
|
||||
|
||||
func (e ErrNotTrusted) Error() string {
|
||||
return errNotTrusted.Error()
|
||||
}
|
||||
|
||||
func (e ErrNotTrusted) Unwrap() error {
|
||||
return errNotTrusted
|
||||
}
|
||||
|
||||
// CheckAndProcessInvite analyses the body of an incoming membership request.
|
||||
// If the fields relative to a third-party-invite are all supplied, lookups the
|
||||
// matching Matrix ID from the given identity server. If no Matrix ID is
|
||||
|
@ -99,7 +119,7 @@ func CheckAndProcessInvite(
|
|||
} else if body.Address == "" || body.IDServer == "" || body.Medium == "" {
|
||||
// If at least one of the 3PID-specific fields is supplied but not all
|
||||
// of them, return an error
|
||||
err = ErrMissingParameter
|
||||
err = ErrMissingParameter{}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
// EmailAssociationRequest represents the request defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken
|
||||
|
@ -133,7 +134,7 @@ func CheckAssociation(
|
|||
return false, "", "", err
|
||||
}
|
||||
|
||||
if respBody.ErrCode == "M_SESSION_NOT_VALIDATED" {
|
||||
if respBody.ErrCode == string(spec.ErrorSessionNotValidated) {
|
||||
return false, "", "", nil
|
||||
} else if len(respBody.ErrCode) > 0 {
|
||||
return false, "", "", errors.New(respBody.Error)
|
||||
|
@ -186,5 +187,5 @@ func isTrusted(idServer string, cfg *config.ClientAPI) error {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
return ErrNotTrusted
|
||||
return ErrNotTrusted{}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue