mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Fix bugs
This commit is contained in:
parent
993d973cfa
commit
c79b1294ee
|
|
@ -33,6 +33,15 @@ func MakeLeave(
|
|||
rsAPI api.RoomserverInternalAPI,
|
||||
roomID, userID string,
|
||||
) util.JSONResponse {
|
||||
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
|
||||
verRes := api.QueryRoomVersionForRoomResponse{}
|
||||
if err := rsAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.InternalServerError(),
|
||||
}
|
||||
}
|
||||
|
||||
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
|
|
@ -87,7 +96,10 @@ func MakeLeave(
|
|||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: map[string]interface{}{"event": builder},
|
||||
JSON: map[string]interface{}{
|
||||
"room_version": verRes.RoomVersion,
|
||||
"event": builder,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,11 +193,8 @@ func (r *FederationSenderInternalAPI) PerformLeave(
|
|||
|
||||
// Work out if we support the room version that has been supplied in
|
||||
// the make_leave response.
|
||||
if respMakeLeave.RoomVersion == "" {
|
||||
respMakeLeave.RoomVersion = gomatrixserverlib.RoomVersionV1
|
||||
}
|
||||
if _, err = respMakeLeave.RoomVersion.EventFormat(); err != nil {
|
||||
return fmt.Errorf("respMakeLeave.RoomVersion.EventFormat: %w", err)
|
||||
return gomatrixserverlib.UnsupportedRoomVersionError{}
|
||||
}
|
||||
|
||||
// Build the leave event.
|
||||
|
|
|
|||
|
|
@ -155,9 +155,6 @@ func (r *RoomserverInternalAPI) performRejectInvite(
|
|||
return fmt.Errorf("fsAPI.PerformLeave: %w", err)
|
||||
}
|
||||
|
||||
// If this succeeded then we can clean up the invite.
|
||||
fmt.Println("REMOVE THE INVITE!")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -189,14 +186,19 @@ func (r *RoomserverInternalAPI) isInvitePending(
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("r.DB.GetInvitesForUser: %w", err)
|
||||
}
|
||||
fmt.Println("Sender user NIDs:", senderUserNIDs)
|
||||
if len(senderUserNIDs) == 0 {
|
||||
return "", fmt.Errorf("no senderUserNIDs")
|
||||
}
|
||||
|
||||
// Look up the user ID from the NID.
|
||||
senderUsers, err := r.DB.EventStateKeys(ctx, senderUserNIDs)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("r.DB.EventStateKeys: %w", err)
|
||||
}
|
||||
fmt.Println("Sender users:", senderUsers)
|
||||
if len(senderUsers) == 0 {
|
||||
return "", fmt.Errorf("no senderUsers")
|
||||
}
|
||||
|
||||
senderUser, senderUserFound := senderUsers[senderUserNIDs[0]]
|
||||
if !senderUserFound {
|
||||
return "", fmt.Errorf("missing user for NID %d (%+v)", senderUserNIDs[0], senderUsers)
|
||||
|
|
|
|||
Loading…
Reference in a new issue