2020-06-15 09:54:11 +01: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 (
|
|
|
|
"github.com/gorilla/mux"
|
2022-12-05 12:53:36 +00:00
|
|
|
|
2020-06-15 09:54:11 +01:00
|
|
|
"github.com/matrix-org/dendrite/internal/httputil"
|
|
|
|
"github.com/matrix-org/dendrite/userapi/api"
|
|
|
|
)
|
|
|
|
|
2020-07-22 17:04:57 +01:00
|
|
|
// nolint: gocyclo
|
2022-12-05 12:53:36 +00:00
|
|
|
func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI, enableMetrics bool) {
|
|
|
|
addRoutesLoginToken(internalAPIMux, s, enableMetrics)
|
2022-02-10 10:27:26 +00:00
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformAccountCreationPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformAccountCreation", enableMetrics, s.PerformAccountCreation),
|
2020-06-16 17:39:56 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPasswordUpdatePath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformPasswordUpdate", enableMetrics, s.PerformPasswordUpdate),
|
2020-09-04 15:16:13 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceCreationPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformDeviceCreation", enableMetrics, s.PerformDeviceCreation),
|
2020-07-31 14:40:45 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformLastSeenUpdatePath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformLastSeenUpdate", enableMetrics, s.PerformLastSeenUpdate),
|
2020-11-20 11:29:02 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceUpdatePath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformDeviceUpdate", enableMetrics, s.PerformDeviceUpdate),
|
2020-06-16 17:39:56 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformDeviceDeletionPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformDeviceDeletion", enableMetrics, s.PerformDeviceDeletion),
|
2020-07-30 18:00:56 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformAccountDeactivationPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformAccountDeactivation", enableMetrics, s.PerformAccountDeactivation),
|
2020-10-02 17:18:20 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformOpenIDTokenCreationPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformOpenIDTokenCreation", enableMetrics, s.PerformOpenIDTokenCreation),
|
2021-04-07 13:26:20 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryProfilePath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryProfile", enableMetrics, s.QueryProfile),
|
2020-06-15 09:54:11 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccessTokenPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryAccessToken", enableMetrics, s.QueryAccessToken),
|
2020-06-16 14:10:55 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryDevicesPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryDevices", enableMetrics, s.QueryDevices),
|
2020-06-16 14:53:19 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountDataPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryAccountData", enableMetrics, s.QueryAccountData),
|
2020-06-16 17:05:38 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryDeviceInfosPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryDeviceInfos", enableMetrics, s.QueryDeviceInfos),
|
2020-07-22 17:04:57 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QuerySearchProfilesPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQuerySearchProfiles", enableMetrics, s.QuerySearchProfiles),
|
2020-07-28 10:53:17 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryOpenIDTokenPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryOpenIDToken", enableMetrics, s.QueryOpenIDToken),
|
2021-04-07 13:26:20 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
InputAccountDataPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIInputAccountData", enableMetrics, s.InputAccountData),
|
2020-10-19 09:38:10 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryKeyBackupPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryKeyBackup", enableMetrics, s.QueryKeyBackup),
|
2021-12-03 17:18:35 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformKeyBackupPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformKeyBackup", enableMetrics, s.PerformKeyBackup),
|
2021-12-03 17:18:35 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryNotificationsPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryNotifications", enableMetrics, s.QueryNotifications),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPusherSetPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformPusherSet", enableMetrics, s.PerformPusherSet),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPusherDeletionPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformPusherDeletion", enableMetrics, s.PerformPusherDeletion),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryPushersPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryPushers", enableMetrics, s.QueryPushers),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformPushRulesPutPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformPushRulesPut", enableMetrics, s.PerformPushRulesPut),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
|
|
|
|
2022-08-11 15:29:33 +01:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryPushRulesPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryPushRules", enableMetrics, s.QueryPushRules),
|
2022-03-03 11:40:53 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSetAvatarURLPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformSetAvatarURL", enableMetrics, s.SetAvatarURL),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
2022-11-11 16:41:37 +00:00
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryNumericLocalpartPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryNumericLocalpart", enableMetrics, s.QueryNumericLocalpart),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountAvailabilityPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryAccountAvailability", enableMetrics, s.QueryAccountAvailability),
|
2022-04-08 10:18:27 +01:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountByPasswordPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryAccountByPassword", enableMetrics, s.QueryAccountByPassword),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSetDisplayNamePath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPISetDisplayName", enableMetrics, s.SetDisplayName),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryLocalpartForThreePIDPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryLocalpartForThreePID", enableMetrics, s.QueryLocalpartForThreePID),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryThreePIDsForLocalpartPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIQueryThreePIDsForLocalpart", enableMetrics, s.QueryThreePIDsForLocalpart),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformForgetThreePIDPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformForgetThreePID", enableMetrics, s.PerformForgetThreePID),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-08-11 15:29:33 +01:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
PerformSaveThreePIDAssociationPath,
|
2022-12-05 12:53:36 +00:00
|
|
|
httputil.MakeInternalRPCAPI("UserAPIPerformSaveThreePIDAssociation", enableMetrics, s.PerformSaveThreePIDAssociation),
|
2022-03-24 21:45:44 +00:00
|
|
|
)
|
2022-12-22 12:05:59 +00:00
|
|
|
|
|
|
|
internalAPIMux.Handle(
|
|
|
|
QueryAccountByLocalpartPath,
|
|
|
|
httputil.MakeInternalRPCAPI("AccountByLocalpart", enableMetrics, s.QueryAccountByLocalpart),
|
|
|
|
)
|
2020-06-15 09:54:11 +01:00
|
|
|
}
|