mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 00:03:09 -06:00
Use the right client/fed struct in the response
This commit is contained in:
parent
0e911a0eea
commit
711ec94b5f
2
go.mod
2
go.mod
|
|
@ -23,7 +23,7 @@ require (
|
|||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200522092705-bc8506ccbcf3
|
||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201120163216-f2c7efb7446f
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201124110921-47d52651536f
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91
|
||||
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
||||
github.com/mattn/go-sqlite3 v1.14.2
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -573,6 +573,8 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20201116151724-6e7b24e4956c h1:ii
|
|||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201116151724-6e7b24e4956c/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201120163216-f2c7efb7446f h1:0hCJEq+2fnLoStRP9WnQ8ydrnqYFrge6jcvTSdMh1u4=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201120163216-f2c7efb7446f/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201124110921-47d52651536f h1:mAM+tB8HLr0U+VZ4yfvrAPOUF+Nrl48mFsoHfxF7O9I=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20201124110921-47d52651536f/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 h1:HJ6U3S3ljJqNffYMcIeAncp5qT/i+ZMiJ2JC2F0aXP4=
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE=
|
||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 h1:ntrLa/8xVzeSs8vHFHK25k0C+NV74sYMJnNSg5NoSRo=
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ type EventRelationshipResponse struct {
|
|||
Limited bool `json:"limited"`
|
||||
}
|
||||
|
||||
func toClientResponse(res *gomatrixserverlib.MSC2836EventRelationshipsResponse) *EventRelationshipResponse {
|
||||
out := &EventRelationshipResponse{
|
||||
Events: gomatrixserverlib.ToClientEvents(res.Events, gomatrixserverlib.FormatAll),
|
||||
Limited: res.Limited,
|
||||
NextBatch: res.NextBatch,
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Enable this MSC
|
||||
// nolint:gocyclo
|
||||
func Enable(
|
||||
|
|
@ -158,7 +167,7 @@ func eventRelationshipHandler(db Database, rsAPI roomserver.RoomserverInternalAP
|
|||
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: res,
|
||||
JSON: toClientResponse(res),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -196,8 +205,8 @@ func federatedEventRelationship(
|
|||
}
|
||||
}
|
||||
|
||||
func (rc *reqCtx) process() (*EventRelationshipResponse, *util.JSONResponse) {
|
||||
var res EventRelationshipResponse
|
||||
func (rc *reqCtx) process() (*gomatrixserverlib.MSC2836EventRelationshipsResponse, *util.JSONResponse) {
|
||||
var res gomatrixserverlib.MSC2836EventRelationshipsResponse
|
||||
var returnEvents []*gomatrixserverlib.HeaderedEvent
|
||||
// Can the user see (according to history visibility) event_id? If no, reject the request, else continue.
|
||||
event := rc.getLocalEvent(rc.req.EventID)
|
||||
|
|
@ -241,9 +250,9 @@ func (rc *reqCtx) process() (*EventRelationshipResponse, *util.JSONResponse) {
|
|||
)
|
||||
returnEvents = append(returnEvents, events...)
|
||||
}
|
||||
res.Events = make([]gomatrixserverlib.ClientEvent, len(returnEvents))
|
||||
res.Events = make([]*gomatrixserverlib.Event, len(returnEvents))
|
||||
for i, ev := range returnEvents {
|
||||
res.Events[i] = gomatrixserverlib.HeaderedToClientEvent(ev, gomatrixserverlib.FormatAll)
|
||||
res.Events[i] = ev.Unwrap()
|
||||
}
|
||||
res.Limited = remaining == 0 || walkLimited
|
||||
return &res, nil
|
||||
|
|
|
|||
|
|
@ -411,8 +411,12 @@ func postRelationships(t *testing.T, expectCode int, accessToken string, req *ms
|
|||
}
|
||||
if res.StatusCode == 200 {
|
||||
var result msc2836.EventRelationshipResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
|
||||
t.Fatalf("response 200 OK but failed to deserialise JSON : %s", err)
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("response 200 OK but failed to read response body: %s", err)
|
||||
}
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
t.Fatalf("response 200 OK but failed to deserialise JSON : %s\nbody: %s", err, string(body))
|
||||
}
|
||||
return &result
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue