mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
refactor MakeJoin, make code consistent
This commit is contained in:
parent
c32703af04
commit
a6e1026527
|
|
@ -32,7 +32,6 @@ import (
|
||||||
|
|
||||||
// MakeJoin implements the /make_join API
|
// MakeJoin implements the /make_join API
|
||||||
func MakeJoin(
|
func MakeJoin(
|
||||||
ctx context.Context,
|
|
||||||
httpReq *http.Request,
|
httpReq *http.Request,
|
||||||
request *gomatrixserverlib.FederationRequest,
|
request *gomatrixserverlib.FederationRequest,
|
||||||
cfg config.Dendrite,
|
cfg config.Dendrite,
|
||||||
|
|
@ -66,7 +65,7 @@ func MakeJoin(
|
||||||
}
|
}
|
||||||
|
|
||||||
var queryRes api.QueryLatestEventsAndStateResponse
|
var queryRes api.QueryLatestEventsAndStateResponse
|
||||||
event, err := common.BuildEvent(ctx, &builder, cfg, time.Now(), query, &queryRes)
|
event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), query, &queryRes)
|
||||||
if err == common.ErrRoomNoExists {
|
if err == common.ErrRoomNoExists {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusNotFound,
|
Code: http.StatusNotFound,
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ func Setup(
|
||||||
roomID := vars["roomID"]
|
roomID := vars["roomID"]
|
||||||
userID := vars["userID"]
|
userID := vars["userID"]
|
||||||
return MakeJoin(
|
return MakeJoin(
|
||||||
httpReq.Context(), httpReq, request, cfg, query, roomID, userID,
|
httpReq, request, cfg, query, roomID, userID,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodGet)
|
)).Methods(http.MethodGet)
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,9 @@ func buildMembershipEvent(
|
||||||
builder.AuthEvents = refs
|
builder.AuthEvents = refs
|
||||||
|
|
||||||
eventID := fmt.Sprintf("$%s:%s", util.RandomString(16), cfg.Matrix.ServerName)
|
eventID := fmt.Sprintf("$%s:%s", util.RandomString(16), cfg.Matrix.ServerName)
|
||||||
now := time.Now()
|
event, err := builder.Build(
|
||||||
event, err := builder.Build(eventID, now, cfg.Matrix.ServerName, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey)
|
eventID, time.Now(), cfg.Matrix.ServerName, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
||||||
|
)
|
||||||
|
|
||||||
return &event, err
|
return &event, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue