mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Fix tests
This commit is contained in:
parent
8a2115f026
commit
b4f158707f
|
|
@ -262,6 +262,8 @@ func (rp *RequestPool) appendAccountData(
|
||||||
}
|
}
|
||||||
if len(res.RoomAccountData[roomID]) > 0 {
|
if len(res.RoomAccountData[roomID]) > 0 {
|
||||||
events = append(events, res.RoomAccountData[roomID]...)
|
events = append(events, res.RoomAccountData[roomID]...)
|
||||||
|
} else if len(res.GlobalAccountData) > 0 {
|
||||||
|
events = append(events, res.GlobalAccountData...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,12 @@ type QueryAccessTokenResponse struct {
|
||||||
|
|
||||||
// QueryAccountDataRequest is the request for QueryAccountData
|
// QueryAccountDataRequest is the request for QueryAccountData
|
||||||
type QueryAccountDataRequest struct {
|
type QueryAccountDataRequest struct {
|
||||||
UserID string // required
|
UserID string // required: the user to get account data for.
|
||||||
RoomID string // optional: if specified only returns room account data
|
// TODO: This is a terribly confusing API shape :/
|
||||||
DataType string // optional: if specified only returns data matching this type
|
DataType string // optional: if specified returns only a single event matching this data type.
|
||||||
|
// optional: Only used if DataType is set. If blank returns global account data matching the data type.
|
||||||
|
// If set, returns only room account data matching this data type.
|
||||||
|
RoomID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryAccountDataResponse is the response for QueryAccountData
|
// QueryAccountDataResponse is the response for QueryAccountData
|
||||||
|
|
|
||||||
|
|
@ -81,14 +81,20 @@ func (a *UserInternalAPI) QueryAccountData(ctx context.Context, req *api.QueryAc
|
||||||
if domain != a.ServerName {
|
if domain != a.ServerName {
|
||||||
return fmt.Errorf("cannot query account data of remote users: got %s want %s", domain, a.ServerName)
|
return fmt.Errorf("cannot query account data of remote users: got %s want %s", domain, a.ServerName)
|
||||||
}
|
}
|
||||||
if req.DataType != "" && req.RoomID != "" {
|
if req.DataType != "" {
|
||||||
var event *gomatrixserverlib.ClientEvent
|
var event *gomatrixserverlib.ClientEvent
|
||||||
event, err = a.AccountDB.GetAccountDataByType(ctx, local, req.RoomID, req.DataType)
|
event, err = a.AccountDB.GetAccountDataByType(ctx, local, req.RoomID, req.DataType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
res.RoomAccountData = make(map[string][]gomatrixserverlib.ClientEvent)
|
if event != nil {
|
||||||
res.RoomAccountData[req.RoomID] = []gomatrixserverlib.ClientEvent{*event}
|
if req.RoomID != "" {
|
||||||
|
res.RoomAccountData = make(map[string][]gomatrixserverlib.ClientEvent)
|
||||||
|
res.RoomAccountData[req.RoomID] = []gomatrixserverlib.ClientEvent{*event}
|
||||||
|
} else {
|
||||||
|
res.GlobalAccountData = append(res.GlobalAccountData, *event)
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
global, rooms, err := a.AccountDB.GetAccountData(ctx, local)
|
global, rooms, err := a.AccountDB.GetAccountData(ctx, local)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue