2020-06-15 03:54:11 -05:00
|
|
|
// Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package inthttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/matrix-org/dendrite/internal/httputil"
|
|
|
|
"github.com/matrix-org/dendrite/userapi/api"
|
|
|
|
"github.com/matrix-org/util"
|
|
|
|
)
|
|
|
|
|
2020-07-22 11:04:57 -05:00
|
|
|
// nolint: gocyclo
|
2020-06-15 03:54:11 -05:00
|
|
|
func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
|
2022-02-10 04:27:26 -06:00
|
|
|
addRoutesLoginToken(internalAPIMux, s)
|
|
|
|
|
2022-08-08 09:36:14 -05:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformAccountCreationPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformAccountCreation", s.PerformAccountCreation),
|
2020-06-16 11:39:56 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPasswordUpdatePath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformPasswordUpdate", s.PerformPasswordUpdate),
|
2020-09-04 09:16:13 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceCreationPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformDeviceCreation", s.PerformDeviceCreation),
|
2020-07-31 08:40:45 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformLastSeenUpdatePath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformLastSeenUpdate", s.PerformLastSeenUpdate),
|
2020-11-20 05:29:02 -06:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceUpdatePath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformDeviceUpdate", s.PerformDeviceUpdate),
|
2020-06-16 11:39:56 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceDeletionPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformDeviceDeletion", s.PerformDeviceDeletion),
|
2020-07-30 12:00:56 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformAccountDeactivationPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformAccountDeactivation", s.PerformAccountDeactivation),
|
2020-10-02 11:18:20 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformOpenIDTokenCreationPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformOpenIDTokenCreation", s.PerformOpenIDTokenCreation),
|
2021-04-07 07:26:20 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryProfilePath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryProfile", s.QueryProfile),
|
2020-06-15 03:54:11 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccessTokenPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryAccessToken", s.QueryAccessToken),
|
2020-06-16 08:10:55 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccessTokenPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryAccessToken", s.QueryAccessToken),
|
2020-06-16 08:53:19 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryDevicesPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryDevices", s.QueryDevices),
|
2020-06-16 11:05:38 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountDataPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryAccountData", s.QueryAccountData),
|
2020-07-22 11:04:57 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryDeviceInfosPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryDeviceInfos", s.QueryDeviceInfos),
|
2020-07-28 04:53:17 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QuerySearchProfilesPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QuerySearchProfiles", s.QuerySearchProfiles),
|
2021-04-07 07:26:20 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryOpenIDTokenPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryOpenIDToken", s.QueryOpenIDToken),
|
2020-10-19 03:38:10 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
InputAccountDataPath,
|
|
|
|
httputil.MakeInternalRPCAPI("InputAccountData", s.InputAccountData),
|
2021-12-03 11:18:35 -06:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryKeyBackupPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryKeyBackup", s.QueryKeyBackup),
|
2021-12-03 11:18:35 -06:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformKeyBackupPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformKeyBackup", s.PerformKeyBackup),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
2022-08-08 09:36:14 -05:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryNotificationsPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryNotifications", s.QueryNotifications),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPusherSetPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformPusherSet", s.PerformPusherSet),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
2022-08-08 09:36:14 -05:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPusherDeletionPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformPusherDeletion", s.PerformPusherDeletion),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
2022-08-08 09:36:14 -05:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryPushersPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryPushers", s.QueryPushers),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
2022-08-08 09:36:14 -05:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPushRulesPutPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformPushRulesPut", s.PerformPushRulesPut),
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryPushRulesPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryPushRules", s.QueryPushRules),
|
|
|
|
)
|
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSetAvatarURLPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformSetAvatarURL", s.SetAvatarURL),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
// TODO: Look at the shape of this
|
2022-03-24 16:45:44 -05:00
|
|
|
internalAPIMux.Handle(QueryNumericLocalpartPath,
|
|
|
|
httputil.MakeInternalAPI("queryNumericLocalpart", func(req *http.Request) util.JSONResponse {
|
|
|
|
response := api.QueryNumericLocalpartResponse{}
|
|
|
|
if err := s.QueryNumericLocalpart(req.Context(), &response); err != nil {
|
|
|
|
return util.ErrorResponse(err)
|
|
|
|
}
|
|
|
|
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
|
|
|
}),
|
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountAvailabilityPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryAccountAvailability", s.QueryAccountAvailability),
|
2022-04-08 04:18:27 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountByPasswordPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryAccountByPassword", s.QueryAccountByPassword),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSetDisplayNamePath,
|
|
|
|
httputil.MakeInternalRPCAPI("SetDisplayName", s.SetDisplayName),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryLocalpartForThreePIDPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryLocalpartForThreePID", s.QueryLocalpartForThreePID),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryThreePIDsForLocalpartPath,
|
|
|
|
httputil.MakeInternalRPCAPI("QueryThreePIDsForLocalpart", s.QueryThreePIDsForLocalpart),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformForgetThreePIDPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformForgetThreePID", s.PerformForgetThreePID),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2022-08-08 09:36:14 -05:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSaveThreePIDAssociationPath,
|
|
|
|
httputil.MakeInternalRPCAPI("PerformSaveThreePIDAssociation", s.PerformSaveThreePIDAssociation),
|
2022-03-24 16:45:44 -05:00
|
|
|
)
|
2020-06-15 03:54:11 -05:00
|
|
|
}
|