mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 15:08:28 +00:00
Avoid panic due to being unable to query the userID
This commit is contained in:
parent
5267cc0f54
commit
3e314e028e
1 changed files with 17 additions and 2 deletions
|
@ -16,7 +16,9 @@ package consumers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
@ -411,13 +413,26 @@ func JoinedHostsFromEvents(ctx context.Context, evs []gomatrixserverlib.PDU, rsA
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var domain spec.ServerName
|
||||||
userID, err := rsAPI.QueryUserIDForSender(ctx, *validRoomID, spec.SenderID(*ev.StateKey()))
|
userID, err := rsAPI.QueryUserIDForSender(ctx, *validRoomID, spec.SenderID(*ev.StateKey()))
|
||||||
if err != nil {
|
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{
|
joinedHosts = append(joinedHosts, types.JoinedHost{
|
||||||
MemberEventID: ev.EventID(), ServerName: userID.Domain(),
|
MemberEventID: ev.EventID(), ServerName: domain,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return joinedHosts, nil
|
return joinedHosts, nil
|
||||||
|
|
Loading…
Reference in a new issue