aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-02-14 12:47:47 +0100
committerGitHub <noreply@github.com>2023-02-14 12:47:47 +0100
commit11d9b9db0e96c51c1430d451d23cf5ae9f36e4ee (patch)
treea0837bfa69051295b76140e3940a45fc61854cab /clientapi/routing
parentcc59879faa57cac043cf5f1585773b301994bebf (diff)
Remove polylith/API mode (#2967)
This removes most of the code used for polylith/API mode. This removes the `/api` internal endpoints entirely. Binary size change roughly 5%: ``` 51437560 Feb 13 10:15 dendrite-monolith-server # old 48759008 Feb 13 10:15 dendrite-monolith-server # new ```
Diffstat (limited to 'clientapi/routing')
-rw-r--r--clientapi/routing/auth_fallback_test.go4
-rw-r--r--clientapi/routing/leaveroom.go10
-rw-r--r--clientapi/routing/register.go12
-rw-r--r--clientapi/routing/register_test.go4
4 files changed, 4 insertions, 26 deletions
diff --git a/clientapi/routing/auth_fallback_test.go b/clientapi/routing/auth_fallback_test.go
index 0d77f9a0..534581bd 100644
--- a/clientapi/routing/auth_fallback_test.go
+++ b/clientapi/routing/auth_fallback_test.go
@@ -22,7 +22,7 @@ func Test_AuthFallback(t *testing.T) {
for _, wantErr := range []bool{false, true} {
t.Run(fmt.Sprintf("useHCaptcha(%v) - recaptchaEnabled(%v) - wantErr(%v)", useHCaptcha, recaptchaEnabled, wantErr), func(t *testing.T) {
// Set the defaults for each test
- base.Cfg.ClientAPI.Defaults(config.DefaultOpts{Generate: true, Monolithic: true})
+ base.Cfg.ClientAPI.Defaults(config.DefaultOpts{Generate: true, SingleDatabase: true})
base.Cfg.ClientAPI.RecaptchaEnabled = recaptchaEnabled
base.Cfg.ClientAPI.RecaptchaPublicKey = "pub"
base.Cfg.ClientAPI.RecaptchaPrivateKey = "priv"
@@ -33,7 +33,7 @@ func Test_AuthFallback(t *testing.T) {
base.Cfg.ClientAPI.RecaptchaSitekeyClass = "h-captcha"
}
cfgErrs := &config.ConfigErrors{}
- base.Cfg.ClientAPI.Verify(cfgErrs, true)
+ base.Cfg.ClientAPI.Verify(cfgErrs)
if len(*cfgErrs) > 0 {
t.Fatalf("(hCaptcha=%v) unexpected config errors: %s", useHCaptcha, cfgErrs.Error())
}
diff --git a/clientapi/routing/leaveroom.go b/clientapi/routing/leaveroom.go
index 86414afc..a7166185 100644
--- a/clientapi/routing/leaveroom.go
+++ b/clientapi/routing/leaveroom.go
@@ -18,7 +18,6 @@ import (
"net/http"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
- "github.com/matrix-org/dendrite/internal/httputil"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/util"
@@ -45,15 +44,6 @@ func LeaveRoomByID(
JSON: jsonerror.LeaveServerNoticeError(),
}
}
- switch e := err.(type) {
- case httputil.InternalAPIError:
- if e.Message == jsonerror.LeaveServerNoticeError().Error() {
- return util.JSONResponse{
- Code: http.StatusForbidden,
- JSON: jsonerror.LeaveServerNoticeError(),
- }
- }
- }
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.Unknown(err.Error()),
diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go
index be2b192b..ff6a0900 100644
--- a/clientapi/routing/register.go
+++ b/clientapi/routing/register.go
@@ -31,8 +31,6 @@ import (
"time"
"github.com/matrix-org/dendrite/internal"
- internalHTTPUtil "github.com/matrix-org/dendrite/internal/httputil"
- "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/tidwall/gjson"
"github.com/matrix-org/dendrite/internal/eventutil"
@@ -861,16 +859,6 @@ func completeRegistration(
JSON: jsonerror.UserInUse("Desired user ID is already taken."),
}
}
- switch e := err.(type) {
- case internalHTTPUtil.InternalAPIError:
- conflictErr := &userapi.ErrorConflict{Message: sqlutil.ErrUserExists.Error()}
- if e.Message == conflictErr.Error() {
- return util.JSONResponse{
- Code: http.StatusBadRequest,
- JSON: jsonerror.UserInUse("Desired user ID is already taken."),
- }
- }
- }
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.Unknown("failed to create account: " + err.Error()),
diff --git a/clientapi/routing/register_test.go b/clientapi/routing/register_test.go
index bccc1b79..670c392b 100644
--- a/clientapi/routing/register_test.go
+++ b/clientapi/routing/register_test.go
@@ -201,8 +201,8 @@ func TestValidationOfApplicationServices(t *testing.T) {
// Set up a config
fakeConfig := &config.Dendrite{}
fakeConfig.Defaults(config.DefaultOpts{
- Generate: true,
- Monolithic: true,
+ Generate: true,
+ SingleDatabase: true,
})
fakeConfig.Global.ServerName = "localhost"
fakeConfig.ClientAPI.Derived.ApplicationServices = []config.ApplicationService{fakeApplicationService}