mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Remove BaseDendrite
(#3023)
Removes `BaseDendrite` to, hopefully, make testing and composing of components easier in the future.
This commit is contained in:
parent
ec6879e5ae
commit
5e85a00cb3
68 changed files with 1186 additions and 1002 deletions
|
@ -45,13 +45,12 @@ type configResponse struct {
|
|||
// nolint: gocyclo
|
||||
func Setup(
|
||||
publicAPIMux *mux.Router,
|
||||
cfg *config.MediaAPI,
|
||||
rateLimit *config.RateLimiting,
|
||||
cfg *config.Dendrite,
|
||||
db storage.Database,
|
||||
userAPI userapi.MediaUserAPI,
|
||||
client *gomatrixserverlib.Client,
|
||||
) {
|
||||
rateLimits := httputil.NewRateLimits(rateLimit)
|
||||
rateLimits := httputil.NewRateLimits(&cfg.ClientAPI.RateLimiting)
|
||||
|
||||
v3mux := publicAPIMux.PathPrefix("/{apiversion:(?:r0|v1|v3)}/").Subrouter()
|
||||
|
||||
|
@ -65,7 +64,7 @@ func Setup(
|
|||
if r := rateLimits.Limit(req, dev); r != nil {
|
||||
return *r
|
||||
}
|
||||
return Upload(req, cfg, dev, db, activeThumbnailGeneration)
|
||||
return Upload(req, &cfg.MediaAPI, dev, db, activeThumbnailGeneration)
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -73,8 +72,8 @@ func Setup(
|
|||
if r := rateLimits.Limit(req, device); r != nil {
|
||||
return *r
|
||||
}
|
||||
respondSize := &cfg.MaxFileSizeBytes
|
||||
if cfg.MaxFileSizeBytes == 0 {
|
||||
respondSize := &cfg.MediaAPI.MaxFileSizeBytes
|
||||
if cfg.MediaAPI.MaxFileSizeBytes == 0 {
|
||||
respondSize = nil
|
||||
}
|
||||
return util.JSONResponse{
|
||||
|
@ -90,12 +89,12 @@ func Setup(
|
|||
MXCToResult: map[string]*types.RemoteRequestResult{},
|
||||
}
|
||||
|
||||
downloadHandler := makeDownloadAPI("download", cfg, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration)
|
||||
downloadHandler := makeDownloadAPI("download", &cfg.MediaAPI, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration)
|
||||
v3mux.Handle("/download/{serverName}/{mediaId}", downloadHandler).Methods(http.MethodGet, http.MethodOptions)
|
||||
v3mux.Handle("/download/{serverName}/{mediaId}/{downloadName}", downloadHandler).Methods(http.MethodGet, http.MethodOptions)
|
||||
|
||||
v3mux.Handle("/thumbnail/{serverName}/{mediaId}",
|
||||
makeDownloadAPI("thumbnail", cfg, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration),
|
||||
makeDownloadAPI("thumbnail", &cfg.MediaAPI, rateLimits, db, client, activeRemoteRequests, activeThumbnailGeneration),
|
||||
).Methods(http.MethodGet, http.MethodOptions)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ func Test_uploadRequest_doUpload(t *testing.T) {
|
|||
// create testdata folder and remove when done
|
||||
_ = os.Mkdir(testdataPath, os.ModePerm)
|
||||
defer fileutils.RemoveDir(types.Path(testdataPath), nil)
|
||||
cm := sqlutil.NewConnectionManager()
|
||||
cm := sqlutil.NewConnectionManager(nil, config.DatabaseOptions{})
|
||||
db, err := storage.NewMediaAPIDatasource(cm, &config.DatabaseOptions{
|
||||
ConnectionString: "file::memory:?cache=shared",
|
||||
MaxOpenConnections: 100,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue