Use SenderID Type (#3105)

This commit is contained in:
devonh 2023-06-07 17:14:35 +00:00 committed by GitHub
parent 7a1fd7f512
commit 8ea1a11105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 502 additions and 275 deletions

View file

@ -152,11 +152,19 @@ func (r *Leaver) performLeaveRoomByID(
}
// Prepare the template for the leave event.
userID := req.UserID
fullUserID, err := spec.NewUserID(req.UserID, true)
if err != nil {
return nil, err
}
senderID, err := r.RSAPI.QuerySenderIDForUser(ctx, req.RoomID, *fullUserID)
if err != nil {
return nil, err
}
senderIDString := string(senderID)
proto := gomatrixserverlib.ProtoEvent{
Type: spec.MRoomMember,
Sender: userID,
StateKey: &userID,
SenderID: senderIDString,
StateKey: &senderIDString,
RoomID: req.RoomID,
Redacts: "",
}
@ -168,10 +176,7 @@ func (r *Leaver) performLeaveRoomByID(
}
// Get the sender domain.
_, senderDomain, serr := r.Cfg.Matrix.SplitLocalID('@', proto.Sender)
if serr != nil {
return nil, fmt.Errorf("sender %q is invalid", proto.Sender)
}
senderDomain := fullUserID.Domain()
// We know that the user is in the room at this point so let's build
// a leave event.