mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-12-27 09:56:12 +00:00
Avoid panic due to being unable to query the userID
This commit is contained in:
parent
5267cc0f54
commit
3e314e028e
|
@ -16,7 +16,9 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -411,13 +413,26 @@ func JoinedHostsFromEvents(ctx context.Context, evs []gomatrixserverlib.PDU, rsA
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var domain spec.ServerName
|
||||
userID, err := rsAPI.QueryUserIDForSender(ctx, *validRoomID, spec.SenderID(*ev.StateKey()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if errors.As(err, new(base64.CorruptInputError)) {
|
||||
// Fallback to using the "old" way of getting the user domain, avoids
|
||||
// "illegal base64 data at input byte 0" errors
|
||||
// FIXME: we should do this in QueryUserIDForSender instead
|
||||
_, domain, err = gomatrixserverlib.SplitID('@', *ev.StateKey())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
domain = userID.Domain()
|
||||
}
|
||||
|
||||
joinedHosts = append(joinedHosts, types.JoinedHost{
|
||||
MemberEventID: ev.EventID(), ServerName: userID.Domain(),
|
||||
MemberEventID: ev.EventID(), ServerName: domain,
|
||||
})
|
||||
}
|
||||
return joinedHosts, nil
|
||||
|
|
Loading…
Reference in a new issue