diff options
author | Behouba Manassé <behouba@gmail.com> | 2020-02-11 14:18:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 11:18:12 +0000 |
commit | 9937c05beae7d76e351eae35ad6f441b1c177303 (patch) | |
tree | c8558c2cc386352bcd6bacd810465a18f0e42599 /federationapi | |
parent | b72d7eb0cfdb6cead864c6e7cc0ccec77efa5805 (diff) |
Pass cfg by reference around the codebase (#819)
* Pass cfg by reference around the codebase
* Merge branch 'master' into pass-cfg-by-ref
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'federationapi')
-rw-r--r-- | federationapi/federationapi.go | 6 | ||||
-rw-r--r-- | federationapi/routing/backfill.go | 2 | ||||
-rw-r--r-- | federationapi/routing/invite.go | 2 | ||||
-rw-r--r-- | federationapi/routing/join.go | 4 | ||||
-rw-r--r-- | federationapi/routing/keys.go | 4 | ||||
-rw-r--r-- | federationapi/routing/leave.go | 4 | ||||
-rw-r--r-- | federationapi/routing/profile.go | 2 | ||||
-rw-r--r-- | federationapi/routing/query.go | 2 | ||||
-rw-r--r-- | federationapi/routing/routing.go | 2 | ||||
-rw-r--r-- | federationapi/routing/send.go | 2 | ||||
-rw-r--r-- | federationapi/routing/threepid.go | 10 |
11 files changed, 20 insertions, 20 deletions
diff --git a/federationapi/federationapi.go b/federationapi/federationapi.go index c2aef06c..53851bc5 100644 --- a/federationapi/federationapi.go +++ b/federationapi/federationapi.go @@ -45,8 +45,8 @@ func SetupFederationAPIComponent( roomserverProducer := producers.NewRoomserverProducer(inputAPI) routing.Setup( - base.APIMux, *base.Cfg, queryAPI, aliasAPI, asAPI, - roomserverProducer, federationSenderAPI, *keyRing, federation, accountsDB, - deviceDB, + base.APIMux, base.Cfg, queryAPI, aliasAPI, asAPI, + roomserverProducer, federationSenderAPI, *keyRing, + federation, accountsDB, deviceDB, ) } diff --git a/federationapi/routing/backfill.go b/federationapi/routing/backfill.go index 5c6b0087..cb388f50 100644 --- a/federationapi/routing/backfill.go +++ b/federationapi/routing/backfill.go @@ -34,7 +34,7 @@ func Backfill( request *gomatrixserverlib.FederationRequest, query api.RoomserverQueryAPI, roomID string, - cfg config.Dendrite, + cfg *config.Dendrite, ) util.JSONResponse { var res api.QueryBackfillResponse var eIDs []string diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go index 01a1bed2..9a04a088 100644 --- a/federationapi/routing/invite.go +++ b/federationapi/routing/invite.go @@ -32,7 +32,7 @@ func Invite( request *gomatrixserverlib.FederationRequest, roomID string, eventID string, - cfg config.Dendrite, + cfg *config.Dendrite, producer *producers.RoomserverProducer, keys gomatrixserverlib.KeyRing, ) util.JSONResponse { diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index e2885dd9..325b9937 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -33,7 +33,7 @@ import ( func MakeJoin( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, - cfg config.Dendrite, + cfg *config.Dendrite, query api.RoomserverQueryAPI, roomID, userID string, ) util.JSONResponse { @@ -97,7 +97,7 @@ func MakeJoin( func SendJoin( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, - cfg config.Dendrite, + cfg *config.Dendrite, query api.RoomserverQueryAPI, producer *producers.RoomserverProducer, keys gomatrixserverlib.KeyRing, diff --git a/federationapi/routing/keys.go b/federationapi/routing/keys.go index 9c53d177..3eb88567 100644 --- a/federationapi/routing/keys.go +++ b/federationapi/routing/keys.go @@ -27,7 +27,7 @@ import ( // LocalKeys returns the local keys for the server. // See https://matrix.org/docs/spec/server_server/unstable.html#publishing-keys -func LocalKeys(cfg config.Dendrite) util.JSONResponse { +func LocalKeys(cfg *config.Dendrite) util.JSONResponse { keys, err := localKeys(cfg, time.Now().Add(cfg.Matrix.KeyValidityPeriod)) if err != nil { return util.ErrorResponse(err) @@ -35,7 +35,7 @@ func LocalKeys(cfg config.Dendrite) util.JSONResponse { return util.JSONResponse{Code: http.StatusOK, JSON: keys} } -func localKeys(cfg config.Dendrite, validUntil time.Time) (*gomatrixserverlib.ServerKeys, error) { +func localKeys(cfg *config.Dendrite, validUntil time.Time) (*gomatrixserverlib.ServerKeys, error) { var keys gomatrixserverlib.ServerKeys keys.ServerName = cfg.Matrix.ServerName diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go index a982b87f..95815808 100644 --- a/federationapi/routing/leave.go +++ b/federationapi/routing/leave.go @@ -31,7 +31,7 @@ import ( func MakeLeave( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, - cfg config.Dendrite, + cfg *config.Dendrite, query api.RoomserverQueryAPI, roomID, userID string, ) util.JSONResponse { @@ -95,7 +95,7 @@ func MakeLeave( func SendLeave( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, - cfg config.Dendrite, + cfg *config.Dendrite, producer *producers.RoomserverProducer, keys gomatrixserverlib.KeyRing, roomID, eventID string, diff --git a/federationapi/routing/profile.go b/federationapi/routing/profile.go index 2b478cfb..3be729c2 100644 --- a/federationapi/routing/profile.go +++ b/federationapi/routing/profile.go @@ -31,7 +31,7 @@ import ( func GetProfile( httpReq *http.Request, accountDB *accounts.Database, - cfg config.Dendrite, + cfg *config.Dendrite, asAPI appserviceAPI.AppServiceQueryAPI, ) util.JSONResponse { userID, field := httpReq.FormValue("user_id"), httpReq.FormValue("field") diff --git a/federationapi/routing/query.go b/federationapi/routing/query.go index ed2d8b74..5277f0ac 100644 --- a/federationapi/routing/query.go +++ b/federationapi/routing/query.go @@ -32,7 +32,7 @@ import ( func RoomAliasToID( httpReq *http.Request, federation *gomatrixserverlib.FederationClient, - cfg config.Dendrite, + cfg *config.Dendrite, aliasAPI roomserverAPI.RoomserverAliasAPI, senderAPI federationSenderAPI.FederationSenderQueryAPI, ) util.JSONResponse { diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go index 302f7ed0..13ed24f3 100644 --- a/federationapi/routing/routing.go +++ b/federationapi/routing/routing.go @@ -43,7 +43,7 @@ const ( // nolint: gocyclo func Setup( apiMux *mux.Router, - cfg config.Dendrite, + cfg *config.Dendrite, query roomserverAPI.RoomserverQueryAPI, aliasAPI roomserverAPI.RoomserverAliasAPI, asAPI appserviceAPI.AppServiceQueryAPI, diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index eab24874..5513a088 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -34,7 +34,7 @@ func Send( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, txnID gomatrixserverlib.TransactionID, - cfg config.Dendrite, + cfg *config.Dendrite, query api.RoomserverQueryAPI, producer *producers.RoomserverProducer, keys gomatrixserverlib.KeyRing, diff --git a/federationapi/routing/threepid.go b/federationapi/routing/threepid.go index 7fa02be9..06e00eea 100644 --- a/federationapi/routing/threepid.go +++ b/federationapi/routing/threepid.go @@ -59,7 +59,7 @@ var ( // CreateInvitesFrom3PIDInvites implements POST /_matrix/federation/v1/3pid/onbind func CreateInvitesFrom3PIDInvites( req *http.Request, queryAPI roomserverAPI.RoomserverQueryAPI, - asAPI appserviceAPI.AppServiceQueryAPI, cfg config.Dendrite, + asAPI appserviceAPI.AppServiceQueryAPI, cfg *config.Dendrite, producer *producers.RoomserverProducer, federation *gomatrixserverlib.FederationClient, accountDB *accounts.Database, ) util.JSONResponse { @@ -98,7 +98,7 @@ func ExchangeThirdPartyInvite( request *gomatrixserverlib.FederationRequest, roomID string, queryAPI roomserverAPI.RoomserverQueryAPI, - cfg config.Dendrite, + cfg *config.Dendrite, federation *gomatrixserverlib.FederationClient, producer *producers.RoomserverProducer, ) util.JSONResponse { @@ -172,7 +172,7 @@ func ExchangeThirdPartyInvite( // necessary data to do so. func createInviteFrom3PIDInvite( ctx context.Context, queryAPI roomserverAPI.RoomserverQueryAPI, - asAPI appserviceAPI.AppServiceQueryAPI, cfg config.Dendrite, + asAPI appserviceAPI.AppServiceQueryAPI, cfg *config.Dendrite, inv invite, federation *gomatrixserverlib.FederationClient, accountDB *accounts.Database, ) (*gomatrixserverlib.Event, error) { @@ -230,7 +230,7 @@ func createInviteFrom3PIDInvite( func buildMembershipEvent( ctx context.Context, builder *gomatrixserverlib.EventBuilder, queryAPI roomserverAPI.RoomserverQueryAPI, - cfg config.Dendrite, + cfg *config.Dendrite, ) (*gomatrixserverlib.Event, error) { eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder) if err != nil { @@ -290,7 +290,7 @@ func buildMembershipEvent( // them responded with an error. func sendToRemoteServer( ctx context.Context, inv invite, - federation *gomatrixserverlib.FederationClient, _ config.Dendrite, + federation *gomatrixserverlib.FederationClient, _ *config.Dendrite, builder gomatrixserverlib.EventBuilder, ) (err error) { remoteServers := make([]gomatrixserverlib.ServerName, 2) |