mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-29 17:51:56 -06:00
Fix backfill maybe
This commit is contained in:
parent
b0c897c1d3
commit
0be99a3bdf
|
@ -124,7 +124,7 @@ func Backfill(
|
||||||
}
|
}
|
||||||
|
|
||||||
txn := gomatrixserverlib.Transaction{
|
txn := gomatrixserverlib.Transaction{
|
||||||
Origin: cfg.Matrix.ServerName,
|
Origin: request.Destination(),
|
||||||
PDUs: eventJSONs,
|
PDUs: eventJSONs,
|
||||||
OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()),
|
OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ func NewRoomserverAPI(
|
||||||
Queryer: &query.Queryer{
|
Queryer: &query.Queryer{
|
||||||
DB: roomserverDB,
|
DB: roomserverDB,
|
||||||
Cache: base.Caches,
|
Cache: base.Caches,
|
||||||
ServerName: base.Cfg.Global.ServerName,
|
IsLocalServerName: base.Cfg.Global.IsLocalServerName,
|
||||||
ServerACLs: serverACLs,
|
ServerACLs: serverACLs,
|
||||||
},
|
},
|
||||||
// perform-er structs get initialised when we have a federation sender to use
|
// perform-er structs get initialised when we have a federation sender to use
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (r *Backfiller) PerformBackfill(
|
||||||
// if we are requesting the backfill then we need to do a federation hit
|
// if we are requesting the backfill then we need to do a federation hit
|
||||||
// TODO: we could be more sensible and fetch as many events we already have then request the rest
|
// TODO: we could be more sensible and fetch as many events we already have then request the rest
|
||||||
// which is what the syncapi does already.
|
// which is what the syncapi does already.
|
||||||
if !r.IsLocalServerName(request.ServerName) {
|
if r.IsLocalServerName(request.ServerName) {
|
||||||
return r.backfillViaFederation(ctx, request, response)
|
return r.backfillViaFederation(ctx, request, response)
|
||||||
}
|
}
|
||||||
// someone else is requesting the backfill, try to service their request.
|
// someone else is requesting the backfill, try to service their request.
|
||||||
|
@ -120,8 +120,10 @@ func (r *Backfiller) backfillViaFederation(ctx context.Context, req *api.Perform
|
||||||
// Specifically the test "Outbound federation can backfill events"
|
// Specifically the test "Outbound federation can backfill events"
|
||||||
events, err := gomatrixserverlib.RequestBackfill(
|
events, err := gomatrixserverlib.RequestBackfill(
|
||||||
ctx, req.VirtualHost, requester,
|
ctx, req.VirtualHost, requester,
|
||||||
r.KeyRing, req.RoomID, info.RoomVersion, req.PrevEventIDs(), 100)
|
r.KeyRing, req.RoomID, info.RoomVersion, req.PrevEventIDs(), 100,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logrus.WithError(err).Errorf("gomatrixserverlib.RequestBackfill failed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.WithField("room_id", req.RoomID).Infof("backfilled %d events", len(events))
|
logrus.WithField("room_id", req.RoomID).Infof("backfilled %d events", len(events))
|
||||||
|
|
|
@ -39,7 +39,7 @@ import (
|
||||||
type Queryer struct {
|
type Queryer struct {
|
||||||
DB storage.Database
|
DB storage.Database
|
||||||
Cache caching.RoomServerCaches
|
Cache caching.RoomServerCaches
|
||||||
ServerName gomatrixserverlib.ServerName
|
IsLocalServerName func(gomatrixserverlib.ServerName) bool
|
||||||
ServerACLs *acls.ServerACLs
|
ServerACLs *acls.ServerACLs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ func (r *Queryer) QueryServerJoinedToRoom(
|
||||||
}
|
}
|
||||||
response.RoomExists = true
|
response.RoomExists = true
|
||||||
|
|
||||||
if request.ServerName == r.ServerName || request.ServerName == "" {
|
if r.IsLocalServerName(request.ServerName) || request.ServerName == "" {
|
||||||
response.IsInRoom, err = r.DB.GetLocalServerInRoom(ctx, info.RoomNID)
|
response.IsInRoom, err = r.DB.GetLocalServerInRoom(ctx, info.RoomNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("r.DB.GetLocalServerInRoom: %w", err)
|
return fmt.Errorf("r.DB.GetLocalServerInRoom: %w", err)
|
||||||
|
|
|
@ -528,6 +528,7 @@ func (r *messagesReq) backfill(roomID string, backwardsExtremities map[string][]
|
||||||
BackwardsExtremities: backwardsExtremities,
|
BackwardsExtremities: backwardsExtremities,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
ServerName: r.cfg.Matrix.ServerName,
|
ServerName: r.cfg.Matrix.ServerName,
|
||||||
|
VirtualHost: r.device.UserDomain(),
|
||||||
}, &res)
|
}, &res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("PerformBackfill failed: %w", err)
|
return nil, fmt.Errorf("PerformBackfill failed: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue