From 122620940301454ebcc8a8a41e7cdd24132fe0cf Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 30 Aug 2017 11:40:19 +0100 Subject: [PATCH] Create package for handling 3pid processes and move invite processing there --- .../thirdpartyinvites.go => threepid/invites.go} | 6 +++--- .../matrix-org/dendrite/clientapi/writers/membership.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/github.com/matrix-org/dendrite/clientapi/{thirdpartyinvites/thirdpartyinvites.go => threepid/invites.go} (99%) diff --git a/src/github.com/matrix-org/dendrite/clientapi/thirdpartyinvites/thirdpartyinvites.go b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go similarity index 99% rename from src/github.com/matrix-org/dendrite/clientapi/thirdpartyinvites/thirdpartyinvites.go rename to src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go index c998a6522..244e5f632 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/thirdpartyinvites/thirdpartyinvites.go +++ b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package thirdpartyinvites +package threepid import ( "encoding/json" @@ -66,7 +66,7 @@ type idServerStoreInviteResponse struct { PublicKeys []common.PublicKey `json:"public_keys"` } -// CheckAndProcess analyses the body of an incoming membership request. +// 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 // associated to the given 3PID, asks the identity server to store the invite @@ -79,7 +79,7 @@ type idServerStoreInviteResponse struct { // must be processed as a non-3PID membership request. In the latter case, // fills the Matrix ID in the request body so a normal invite membership event // can be emitted. -func CheckAndProcess( +func CheckAndProcessInvite( req *http.Request, device *authtypes.Device, body *MembershipRequest, cfg config.Dendrite, queryAPI api.RoomserverQueryAPI, db *accounts.Database, producer *producers.RoomserverProducer, membership string, roomID string, diff --git a/src/github.com/matrix-org/dendrite/clientapi/writers/membership.go b/src/github.com/matrix-org/dendrite/clientapi/writers/membership.go index d58230473..6dd52a003 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/writers/membership.go +++ b/src/github.com/matrix-org/dendrite/clientapi/writers/membership.go @@ -23,7 +23,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/producers" - "github.com/matrix-org/dendrite/clientapi/thirdpartyinvites" + "github.com/matrix-org/dendrite/clientapi/threepid" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/roomserver/api" @@ -39,12 +39,12 @@ func SendMembership( roomID string, membership string, cfg config.Dendrite, queryAPI api.RoomserverQueryAPI, producer *producers.RoomserverProducer, ) util.JSONResponse { - var body thirdpartyinvites.MembershipRequest + var body threepid.MembershipRequest if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil { return *reqErr } - if res := thirdpartyinvites.CheckAndProcess( + if res := threepid.CheckAndProcessInvite( req, device, &body, cfg, queryAPI, accountDB, producer, membership, roomID, ); res != nil { return *res @@ -129,7 +129,7 @@ func loadProfile(userID string, cfg config.Dendrite, accountDB *accounts.Databas // In the latter case, if there was an issue retrieving the user ID from the request body, // returns a JSONResponse with a corresponding error code and message. func getMembershipStateKey( - body thirdpartyinvites.MembershipRequest, device *authtypes.Device, membership string, + body threepid.MembershipRequest, device *authtypes.Device, membership string, ) (stateKey string, reason string, response *util.JSONResponse) { if membership == "ban" || membership == "unban" || membership == "kick" || membership == "invite" { // If we're in this case, the state key is contained in the request body,