aboutsummaryrefslogtreecommitdiff
path: root/federationapi/routing/threepid.go
diff options
context:
space:
mode:
Diffstat (limited to 'federationapi/routing/threepid.go')
-rw-r--r--federationapi/routing/threepid.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/federationapi/routing/threepid.go b/federationapi/routing/threepid.go
index 76a2f3d5..360802de 100644
--- a/federationapi/routing/threepid.go
+++ b/federationapi/routing/threepid.go
@@ -140,22 +140,24 @@ func ExchangeThirdPartyInvite(
}
}
- _, senderDomain, err := cfg.Matrix.SplitLocalID('@', proto.Sender)
- if err != nil {
+ userID, err := rsAPI.QueryUserIDForSender(httpReq.Context(), roomID, spec.SenderID(proto.SenderID))
+ if err != nil || userID == nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
- JSON: spec.BadJSON("Invalid sender ID: " + err.Error()),
+ JSON: spec.BadJSON("Invalid sender ID"),
}
}
+ senderDomain := userID.Domain()
// Check that the state key is correct.
- _, targetDomain, err := gomatrixserverlib.SplitID('@', *proto.StateKey)
- if err != nil {
+ targetUserID, err := rsAPI.QueryUserIDForSender(httpReq.Context(), roomID, spec.SenderID(*proto.StateKey))
+ if err != nil || targetUserID == nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: spec.BadJSON("The event's state key isn't a Matrix user ID"),
}
}
+ targetDomain := targetUserID.Domain()
// Check that the target user is from the requesting homeserver.
if targetDomain != request.Origin() {
@@ -271,7 +273,7 @@ func createInviteFrom3PIDInvite(
// Build the event
proto := &gomatrixserverlib.ProtoEvent{
Type: "m.room.member",
- Sender: inv.Sender,
+ SenderID: inv.Sender,
RoomID: inv.RoomID,
StateKey: &inv.MXID,
}