mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Improvements to make_join send_join dance
This commit is contained in:
parent
8b85fa6fd2
commit
a8c23426e7
|
|
@ -95,8 +95,23 @@ func AddPrevEventsToEvent(
|
|||
return ErrRoomNoExists
|
||||
}
|
||||
|
||||
eventFormat, err := queryRes.RoomVersion.EventFormat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
builder.Depth = queryRes.Depth
|
||||
builder.PrevEvents = queryRes.LatestEvents
|
||||
|
||||
switch eventFormat {
|
||||
case gomatrixserverlib.EventFormatV1:
|
||||
builder.PrevEvents = queryRes.LatestEvents
|
||||
case gomatrixserverlib.EventFormatV2:
|
||||
v2Refs := []string{}
|
||||
for _, ref := range queryRes.LatestEvents {
|
||||
v2Refs = append(v2Refs, ref.EventID)
|
||||
}
|
||||
builder.PrevEvents = v2Refs
|
||||
}
|
||||
|
||||
authEvents := gomatrixserverlib.NewAuthEvents(nil)
|
||||
|
||||
|
|
@ -111,7 +126,16 @@ func AddPrevEventsToEvent(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
builder.AuthEvents = refs
|
||||
switch eventFormat {
|
||||
case gomatrixserverlib.EventFormatV1:
|
||||
builder.AuthEvents = refs
|
||||
case gomatrixserverlib.EventFormatV2:
|
||||
v2Refs := []string{}
|
||||
for _, ref := range refs {
|
||||
v2Refs = append(v2Refs, ref.EventID)
|
||||
}
|
||||
builder.AuthEvents = v2Refs
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -35,6 +37,15 @@ func MakeJoin(
|
|||
query api.RoomserverQueryAPI,
|
||||
roomID, userID string,
|
||||
) util.JSONResponse {
|
||||
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
|
||||
verRes := api.QueryRoomVersionForRoomResponse{}
|
||||
if err := query.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.InternalServerError(),
|
||||
}
|
||||
}
|
||||
|
||||
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
|
|
@ -62,7 +73,9 @@ func MakeJoin(
|
|||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
var queryRes api.QueryLatestEventsAndStateResponse
|
||||
queryRes := api.QueryLatestEventsAndStateResponse{
|
||||
RoomVersion: verRes.RoomVersion,
|
||||
}
|
||||
event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), query, &queryRes)
|
||||
if err == common.ErrRoomNoExists {
|
||||
return util.JSONResponse{
|
||||
|
|
@ -88,7 +101,13 @@ func MakeJoin(
|
|||
}
|
||||
}
|
||||
|
||||
resultMap := map[string]interface{}{"event": builder}
|
||||
resultMap := map[string]interface{}{
|
||||
"event": builder,
|
||||
"room_version": verRes.RoomVersion,
|
||||
}
|
||||
|
||||
j, _ := json.MarshalIndent(resultMap, "", " ")
|
||||
fmt.Println("Response to make join:", string(j))
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200318135427-31631a9ef51f
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200304164012-aa524245b658
|
||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200323160828-b738416a2b5e
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324123255-52c9992f89e0
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1
|
||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7
|
||||
github.com/mattn/go-sqlite3 v2.0.2+incompatible
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -140,6 +140,14 @@ github.com/matrix-org/gomatrixserverlib v0.0.0-20200323155135-fd2e0821d1e0 h1:wV
|
|||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200323155135-fd2e0821d1e0/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200323160828-b738416a2b5e h1:ftQ7/kwP5SQDmL2P4heKaxKwlI/S0++WqPClAHuPwdI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200323160828-b738416a2b5e/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324100959-fe9d2e3d62ad h1:jmNvcmlTNgtNhjy2dsFA6zTZVjRP+3gudY6EEJDVr1s=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324100959-fe9d2e3d62ad/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324101436-adfad2a3229b h1:ApGwqHjiiqvSB8bbA2WJkcmGX2NTyoadaVQloAu3egk=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324101436-adfad2a3229b/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324103128-0e0e658437bf h1:eO2W70kcUgpej3WP4p9Rim5gHkCN7wL6DPhtucDAngI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324103128-0e0e658437bf/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324123255-52c9992f89e0 h1:Up8Vp8fHOnmlrZO1nJwG9UPz6WHFfLzbiDP+viRjpTY=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200324123255-52c9992f89e0/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 h1:osLoFdOy+ChQqVUn2PeTDETFftVkl4w9t/OW18g3lnk=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1/go.mod h1:cXoYQIENbdWIQHt1SyCo6Bl3C3raHwJ0wgVrXHSqf+A=
|
||||
github.com/matrix-org/util v0.0.0-20171127121716-2e2df66af2f5 h1:W7l5CP4V7wPyPb4tYE11dbmeAOwtFQBTW0rf4OonOS8=
|
||||
|
|
|
|||
Loading…
Reference in a new issue