mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-03 12:13:09 -06:00
Merge branch 'main' of github.com:matrix-org/dendrite into s7evink/roomsummary
This commit is contained in:
commit
c429b412d6
|
|
@ -129,6 +129,13 @@ func getState(
|
||||||
return nil, nil, &resErr
|
return nil, nil, &resErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if response.IsRejected {
|
||||||
|
return nil, nil, &util.JSONResponse{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
JSON: jsonerror.NotFound("Event not found"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !response.RoomExists {
|
if !response.RoomExists {
|
||||||
return nil, nil, &util.JSONResponse{Code: http.StatusNotFound, JSON: nil}
|
return nil, nil, &util.JSONResponse{Code: http.StatusNotFound, JSON: nil}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,8 @@ type QueryStateAndAuthChainResponse struct {
|
||||||
// The lists will be in an arbitrary order.
|
// The lists will be in an arbitrary order.
|
||||||
StateEvents []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
|
StateEvents []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
|
||||||
AuthChainEvents []*gomatrixserverlib.HeaderedEvent `json:"auth_chain_events"`
|
AuthChainEvents []*gomatrixserverlib.HeaderedEvent `json:"auth_chain_events"`
|
||||||
|
// True if the queried event was rejected earlier.
|
||||||
|
IsRejected bool `json:"is_rejected"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryRoomVersionCapabilitiesRequest asks for the default room version
|
// QueryRoomVersionCapabilitiesRequest asks for the default room version
|
||||||
|
|
|
||||||
|
|
@ -441,11 +441,11 @@ func (r *Queryer) QueryStateAndAuthChain(
|
||||||
}
|
}
|
||||||
|
|
||||||
var stateEvents []*gomatrixserverlib.Event
|
var stateEvents []*gomatrixserverlib.Event
|
||||||
stateEvents, err = r.loadStateAtEventIDs(ctx, info, request.PrevEventIDs)
|
stateEvents, rejected, err := r.loadStateAtEventIDs(ctx, info, request.PrevEventIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
response.IsRejected = rejected
|
||||||
response.PrevEventsExist = true
|
response.PrevEventsExist = true
|
||||||
|
|
||||||
// add the auth event IDs for the current state events too
|
// add the auth event IDs for the current state events too
|
||||||
|
|
@ -480,15 +480,23 @@ func (r *Queryer) QueryStateAndAuthChain(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Queryer) loadStateAtEventIDs(ctx context.Context, roomInfo *types.RoomInfo, eventIDs []string) ([]*gomatrixserverlib.Event, error) {
|
func (r *Queryer) loadStateAtEventIDs(ctx context.Context, roomInfo *types.RoomInfo, eventIDs []string) ([]*gomatrixserverlib.Event, bool, error) {
|
||||||
roomState := state.NewStateResolution(r.DB, roomInfo)
|
roomState := state.NewStateResolution(r.DB, roomInfo)
|
||||||
prevStates, err := r.DB.StateAtEventIDs(ctx, eventIDs)
|
prevStates, err := r.DB.StateAtEventIDs(ctx, eventIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case types.MissingEventError:
|
case types.MissingEventError:
|
||||||
return nil, nil
|
return nil, false, nil
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Currently only used on /state and /state_ids
|
||||||
|
rejected := false
|
||||||
|
for i := range prevStates {
|
||||||
|
if prevStates[i].IsRejected {
|
||||||
|
rejected = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,10 +505,12 @@ func (r *Queryer) loadStateAtEventIDs(ctx context.Context, roomInfo *types.RoomI
|
||||||
ctx, prevStates,
|
ctx, prevStates,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, rejected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return helpers.LoadStateEvents(ctx, r.DB, stateEntries)
|
events, err := helpers.LoadStateEvents(ctx, r.DB, stateEntries)
|
||||||
|
|
||||||
|
return events, rejected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventsFromIDs func(context.Context, []string) ([]types.Event, error)
|
type eventsFromIDs func(context.Context, []string) ([]types.Event, error)
|
||||||
|
|
|
||||||
|
|
@ -30,37 +30,7 @@ func (p *AccountDataStreamProvider) CompleteSync(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *types.SyncRequest,
|
req *types.SyncRequest,
|
||||||
) types.StreamPosition {
|
) types.StreamPosition {
|
||||||
dataReq := &userapi.QueryAccountDataRequest{
|
return p.IncrementalSync(ctx, req, 0, p.LatestPosition(ctx))
|
||||||
UserID: req.Device.UserID,
|
|
||||||
}
|
|
||||||
dataRes := &userapi.QueryAccountDataResponse{}
|
|
||||||
if err := p.userAPI.QueryAccountData(ctx, dataReq, dataRes); err != nil {
|
|
||||||
req.Log.WithError(err).Error("p.userAPI.QueryAccountData failed")
|
|
||||||
return p.LatestPosition(ctx)
|
|
||||||
}
|
|
||||||
for datatype, databody := range dataRes.GlobalAccountData {
|
|
||||||
req.Response.AccountData.Events = append(
|
|
||||||
req.Response.AccountData.Events,
|
|
||||||
gomatrixserverlib.ClientEvent{
|
|
||||||
Type: datatype,
|
|
||||||
Content: gomatrixserverlib.RawJSON(databody),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
for r, j := range req.Response.Rooms.Join {
|
|
||||||
for datatype, databody := range dataRes.RoomAccountData[r] {
|
|
||||||
j.AccountData.Events = append(
|
|
||||||
j.AccountData.Events,
|
|
||||||
gomatrixserverlib.ClientEvent{
|
|
||||||
Type: datatype,
|
|
||||||
Content: gomatrixserverlib.RawJSON(databody),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
req.Response.Rooms.Join[r] = j
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.LatestPosition(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *AccountDataStreamProvider) IncrementalSync(
|
func (p *AccountDataStreamProvider) IncrementalSync(
|
||||||
|
|
@ -72,10 +42,9 @@ func (p *AccountDataStreamProvider) IncrementalSync(
|
||||||
From: from,
|
From: from,
|
||||||
To: to,
|
To: to,
|
||||||
}
|
}
|
||||||
accountDataFilter := gomatrixserverlib.DefaultEventFilter() // TODO: use filter provided in req instead
|
|
||||||
|
|
||||||
dataTypes, err := p.DB.GetAccountDataInRange(
|
dataTypes, err := p.DB.GetAccountDataInRange(
|
||||||
ctx, req.Device.UserID, r, &accountDataFilter,
|
ctx, req.Device.UserID, r, &req.Filter.AccountData,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.Log.WithError(err).Error("p.DB.GetAccountDataInRange failed")
|
req.Log.WithError(err).Error("p.DB.GetAccountDataInRange failed")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
# Blacklisted until matrix-org/dendrite#862 is reverted due to Riot bug
|
|
||||||
|
|
||||||
Latest account data appears in v2 /sync
|
|
||||||
|
|
||||||
# Relies on a rejected PL event which will never be accepted into the DAG
|
# Relies on a rejected PL event which will never be accepted into the DAG
|
||||||
|
|
||||||
# Caused by <https://github.com/matrix-org/sytest/pull/911>
|
# Caused by <https://github.com/matrix-org/sytest/pull/911>
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ Can add account data
|
||||||
Can add account data to room
|
Can add account data to room
|
||||||
Can get account data without syncing
|
Can get account data without syncing
|
||||||
Can get room account data without syncing
|
Can get room account data without syncing
|
||||||
#Latest account data appears in v2 /sync
|
Latest account data appears in v2 /sync
|
||||||
New account data appears in incremental v2 /sync
|
New account data appears in incremental v2 /sync
|
||||||
Checking local federation server
|
Checking local federation server
|
||||||
Inbound federation can query profile data
|
Inbound federation can query profile data
|
||||||
|
|
@ -710,6 +710,10 @@ Old leaves are present in gapped incremental syncs
|
||||||
Leaves are present in non-gapped incremental syncs
|
Leaves are present in non-gapped incremental syncs
|
||||||
Members from the gap are included in gappy incr LL sync
|
Members from the gap are included in gappy incr LL sync
|
||||||
Presence can be set from sync
|
Presence can be set from sync
|
||||||
|
/state returns M_NOT_FOUND for a rejected message event
|
||||||
|
/state_ids returns M_NOT_FOUND for a rejected message event
|
||||||
|
/state returns M_NOT_FOUND for a rejected state event
|
||||||
|
/state_ids returns M_NOT_FOUND for a rejected state event
|
||||||
Unnamed room comes with a name summary
|
Unnamed room comes with a name summary
|
||||||
Named room comes with just joined member count summary
|
Named room comes with just joined member count summary
|
||||||
Room summary only has 5 heroes
|
Room summary only has 5 heroes
|
||||||
|
|
@ -90,6 +90,13 @@ func (a *UserInternalAPI) PerformAccountCreation(ctx context.Context, req *api.P
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inform the SyncAPI about the newly created push_rules
|
||||||
|
if err = a.SyncProducer.SendAccountData(acc.UserID, "", "m.push_rules"); err != nil {
|
||||||
|
util.GetLogger(ctx).WithFields(logrus.Fields{
|
||||||
|
"user_id": acc.UserID,
|
||||||
|
}).WithError(err).Warn("failed to send account data to the SyncAPI")
|
||||||
|
}
|
||||||
|
|
||||||
if req.AccountType == api.AccountTypeGuest {
|
if req.AccountType == api.AccountTypeGuest {
|
||||||
res.AccountCreated = true
|
res.AccountCreated = true
|
||||||
res.Account = acc
|
res.Account = acc
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue