aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/httputil/parse.go2
-rw-r--r--clientapi/routing/device.go15
-rw-r--r--clientapi/routing/directory.go5
-rw-r--r--clientapi/routing/logout.go13
-rw-r--r--clientapi/routing/membership.go23
-rw-r--r--clientapi/routing/password.go11
-rw-r--r--clientapi/routing/redaction.go5
-rw-r--r--clientapi/routing/register_secret.go8
-rw-r--r--clientapi/threepid/threepid.go4
-rw-r--r--clientapi/userutil/userutil.go4
10 files changed, 42 insertions, 48 deletions
diff --git a/clientapi/httputil/parse.go b/clientapi/httputil/parse.go
index ee603341..c8358334 100644
--- a/clientapi/httputil/parse.go
+++ b/clientapi/httputil/parse.go
@@ -32,7 +32,7 @@ func ParseTSParam(req *http.Request) (time.Time, error) {
// The parameter exists, parse into a Time object
ts, err := strconv.ParseInt(tsStr, 10, 64)
if err != nil {
- return time.Time{}, fmt.Errorf("Param 'ts' is no valid int (%s)", err.Error())
+ return time.Time{}, fmt.Errorf("param 'ts' is no valid int (%s)", err.Error())
}
return time.Unix(ts/1000, 0), nil
diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go
index 6adaa769..9f54a625 100644
--- a/clientapi/routing/device.go
+++ b/clientapi/routing/device.go
@@ -23,7 +23,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/userapi/api"
- userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
)
@@ -50,18 +49,18 @@ type devicesDeleteJSON struct {
// GetDeviceByID handles /devices/{deviceID}
func GetDeviceByID(
- req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
deviceID string,
) util.JSONResponse {
- var queryRes userapi.QueryDevicesResponse
- err := userAPI.QueryDevices(req.Context(), &userapi.QueryDevicesRequest{
+ var queryRes api.QueryDevicesResponse
+ err := userAPI.QueryDevices(req.Context(), &api.QueryDevicesRequest{
UserID: device.UserID,
}, &queryRes)
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("QueryDevices failed")
return jsonerror.InternalServerError()
}
- var targetDevice *userapi.Device
+ var targetDevice *api.Device
for _, device := range queryRes.Devices {
if device.ID == deviceID {
targetDevice = &device
@@ -88,10 +87,10 @@ func GetDeviceByID(
// GetDevicesByLocalpart handles /devices
func GetDevicesByLocalpart(
- req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
) util.JSONResponse {
- var queryRes userapi.QueryDevicesResponse
- err := userAPI.QueryDevices(req.Context(), &userapi.QueryDevicesRequest{
+ var queryRes api.QueryDevicesResponse
+ err := userAPI.QueryDevices(req.Context(), &api.QueryDevicesRequest{
UserID: device.UserID,
}, &queryRes)
if err != nil {
diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go
index ae466065..96cb0262 100644
--- a/clientapi/routing/directory.go
+++ b/clientapi/routing/directory.go
@@ -23,7 +23,6 @@ import (
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
- "github.com/matrix-org/dendrite/userapi/api"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -115,7 +114,7 @@ func DirectoryRoom(
// SetLocalAlias implements PUT /directory/room/{roomAlias}
func SetLocalAlias(
req *http.Request,
- device *api.Device,
+ device *userapi.Device,
alias string,
cfg *config.ClientAPI,
rsAPI roomserverAPI.RoomserverInternalAPI,
@@ -192,7 +191,7 @@ func SetLocalAlias(
// RemoveLocalAlias implements DELETE /directory/room/{roomAlias}
func RemoveLocalAlias(
req *http.Request,
- device *api.Device,
+ device *userapi.Device,
alias string,
rsAPI roomserverAPI.RoomserverInternalAPI,
) util.JSONResponse {
diff --git a/clientapi/routing/logout.go b/clientapi/routing/logout.go
index cb300e9f..cfbb6f9f 100644
--- a/clientapi/routing/logout.go
+++ b/clientapi/routing/logout.go
@@ -19,16 +19,15 @@ import (
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/userapi/api"
- userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/util"
)
// Logout handles POST /logout
func Logout(
- req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
) util.JSONResponse {
- var performRes userapi.PerformDeviceDeletionResponse
- err := userAPI.PerformDeviceDeletion(req.Context(), &userapi.PerformDeviceDeletionRequest{
+ var performRes api.PerformDeviceDeletionResponse
+ err := userAPI.PerformDeviceDeletion(req.Context(), &api.PerformDeviceDeletionRequest{
UserID: device.UserID,
DeviceIDs: []string{device.ID},
}, &performRes)
@@ -45,10 +44,10 @@ func Logout(
// LogoutAll handles POST /logout/all
func LogoutAll(
- req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
) util.JSONResponse {
- var performRes userapi.PerformDeviceDeletionResponse
- err := userAPI.PerformDeviceDeletion(req.Context(), &userapi.PerformDeviceDeletionRequest{
+ var performRes api.PerformDeviceDeletionResponse
+ err := userAPI.PerformDeviceDeletion(req.Context(), &api.PerformDeviceDeletionRequest{
UserID: device.UserID,
DeviceIDs: nil,
}, &performRes)
diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go
index b85cfde0..33fb3883 100644
--- a/clientapi/routing/membership.go
+++ b/clientapi/routing/membership.go
@@ -26,7 +26,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/threepid"
"github.com/matrix-org/dendrite/internal/eventutil"
- "github.com/matrix-org/dendrite/roomserver/api"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
@@ -107,7 +106,7 @@ func sendMembership(ctx context.Context, accountDB accounts.Database, device *us
if err = roomserverAPI.SendEvents(
ctx, rsAPI,
- api.KindNew,
+ roomserverAPI.KindNew,
[]*gomatrixserverlib.HeaderedEvent{event.Event.Headered(roomVer)},
cfg.Matrix.ServerName,
nil,
@@ -328,11 +327,11 @@ func loadProfile(
return profile, err
}
-func extractRequestData(req *http.Request, roomID string, rsAPI api.RoomserverInternalAPI) (
+func extractRequestData(req *http.Request, roomID string, rsAPI roomserverAPI.RoomserverInternalAPI) (
body *threepid.MembershipRequest, evTime time.Time, roomVer gomatrixserverlib.RoomVersion, resErr *util.JSONResponse,
) {
- verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
- verRes := api.QueryRoomVersionForRoomResponse{}
+ verReq := roomserverAPI.QueryRoomVersionForRoomRequest{RoomID: roomID}
+ verRes := roomserverAPI.QueryRoomVersionForRoomResponse{}
if err := rsAPI.QueryRoomVersionForRoom(req.Context(), &verReq, &verRes); err != nil {
resErr = &util.JSONResponse{
Code: http.StatusBadRequest,
@@ -402,13 +401,13 @@ func checkAndProcessThreepid(
return
}
-func checkMemberInRoom(ctx context.Context, rsAPI api.RoomserverInternalAPI, userID, roomID string) *util.JSONResponse {
+func checkMemberInRoom(ctx context.Context, rsAPI roomserverAPI.RoomserverInternalAPI, userID, roomID string) *util.JSONResponse {
tuple := gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomMember,
StateKey: userID,
}
- var membershipRes api.QueryCurrentStateResponse
- err := rsAPI.QueryCurrentState(ctx, &api.QueryCurrentStateRequest{
+ var membershipRes roomserverAPI.QueryCurrentStateResponse
+ err := rsAPI.QueryCurrentState(ctx, &roomserverAPI.QueryCurrentStateRequest{
RoomID: roomID,
StateTuples: []gomatrixserverlib.StateKeyTuple{tuple},
}, &membershipRes)
@@ -445,8 +444,8 @@ func SendForget(
) util.JSONResponse {
ctx := req.Context()
logger := util.GetLogger(ctx).WithField("roomID", roomID).WithField("userID", device.UserID)
- var membershipRes api.QueryMembershipForUserResponse
- membershipReq := api.QueryMembershipForUserRequest{
+ var membershipRes roomserverAPI.QueryMembershipForUserResponse
+ membershipReq := roomserverAPI.QueryMembershipForUserRequest{
RoomID: roomID,
UserID: device.UserID,
}
@@ -468,11 +467,11 @@ func SendForget(
}
}
- request := api.PerformForgetRequest{
+ request := roomserverAPI.PerformForgetRequest{
RoomID: roomID,
UserID: device.UserID,
}
- response := api.PerformForgetResponse{}
+ response := roomserverAPI.PerformForgetResponse{}
if err := rsAPI.PerformForget(ctx, &request, &response); err != nil {
logger.WithError(err).Error("PerformForget: unable to forget room")
return jsonerror.InternalServerError()
diff --git a/clientapi/routing/password.go b/clientapi/routing/password.go
index 87d5f8ff..b2442443 100644
--- a/clientapi/routing/password.go
+++ b/clientapi/routing/password.go
@@ -9,7 +9,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/userapi/api"
- userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/dendrite/userapi/storage/accounts"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -29,7 +28,7 @@ type newPasswordAuth struct {
func Password(
req *http.Request,
- userAPI userapi.UserInternalAPI,
+ userAPI api.UserInternalAPI,
accountDB accounts.Database,
device *api.Device,
cfg *config.ClientAPI,
@@ -90,11 +89,11 @@ func Password(
}
// Ask the user API to perform the password change.
- passwordReq := &userapi.PerformPasswordUpdateRequest{
+ passwordReq := &api.PerformPasswordUpdateRequest{
Localpart: localpart,
Password: r.NewPassword,
}
- passwordRes := &userapi.PerformPasswordUpdateResponse{}
+ passwordRes := &api.PerformPasswordUpdateResponse{}
if err := userAPI.PerformPasswordUpdate(req.Context(), passwordReq, passwordRes); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("PerformPasswordUpdate failed")
return jsonerror.InternalServerError()
@@ -107,12 +106,12 @@ func Password(
// If the request asks us to log out all other devices then
// ask the user API to do that.
if r.LogoutDevices {
- logoutReq := &userapi.PerformDeviceDeletionRequest{
+ logoutReq := &api.PerformDeviceDeletionRequest{
UserID: device.UserID,
DeviceIDs: nil,
ExceptDeviceID: device.ID,
}
- logoutRes := &userapi.PerformDeviceDeletionResponse{}
+ logoutRes := &api.PerformDeviceDeletionResponse{}
if err := userAPI.PerformDeviceDeletion(req.Context(), logoutReq, logoutRes); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("PerformDeviceDeletion failed")
return jsonerror.InternalServerError()
diff --git a/clientapi/routing/redaction.go b/clientapi/routing/redaction.go
index 92375974..c25ca4ef 100644
--- a/clientapi/routing/redaction.go
+++ b/clientapi/routing/redaction.go
@@ -22,7 +22,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/internal/eventutil"
- "github.com/matrix-org/dendrite/roomserver/api"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
@@ -113,7 +112,7 @@ func SendRedaction(
return jsonerror.InternalServerError()
}
- var queryRes api.QueryLatestEventsAndStateResponse
+ var queryRes roomserverAPI.QueryLatestEventsAndStateResponse
e, err := eventutil.QueryAndBuildEvent(req.Context(), &builder, cfg.Matrix, time.Now(), rsAPI, &queryRes)
if err == eventutil.ErrRoomNoExists {
return util.JSONResponse{
@@ -121,7 +120,7 @@ func SendRedaction(
JSON: jsonerror.NotFound("Room does not exist"),
}
}
- if err = roomserverAPI.SendEvents(context.Background(), rsAPI, api.KindNew, []*gomatrixserverlib.HeaderedEvent{e}, cfg.Matrix.ServerName, nil); err != nil {
+ if err = roomserverAPI.SendEvents(context.Background(), rsAPI, roomserverAPI.KindNew, []*gomatrixserverlib.HeaderedEvent{e}, cfg.Matrix.ServerName, nil); err != nil {
util.GetLogger(req.Context()).WithError(err).Errorf("failed to SendEvents")
return jsonerror.InternalServerError()
}
diff --git a/clientapi/routing/register_secret.go b/clientapi/routing/register_secret.go
index f0436e32..1a974b77 100644
--- a/clientapi/routing/register_secret.go
+++ b/clientapi/routing/register_secret.go
@@ -68,18 +68,18 @@ func (r *SharedSecretRegistration) IsValidMacLogin(
) (bool, error) {
// Check that shared secret registration isn't disabled.
if r.sharedSecret == "" {
- return false, errors.New("Shared secret registration is disabled")
+ return false, errors.New("shared secret registration is disabled")
}
if !r.validNonce(nonce) {
- return false, fmt.Errorf("Incorrect or expired nonce: %s", nonce)
+ return false, fmt.Errorf("incorrect or expired nonce: %s", nonce)
}
// Check that username/password don't contain the HMAC delimiters.
if strings.Contains(username, "\x00") {
- return false, errors.New("Username contains invalid character")
+ return false, errors.New("username contains invalid character")
}
if strings.Contains(password, "\x00") {
- return false, errors.New("Password contains invalid character")
+ return false, errors.New("password contains invalid character")
}
adminString := "notadmin"
diff --git a/clientapi/threepid/threepid.go b/clientapi/threepid/threepid.go
index 2f817ef4..1e64e303 100644
--- a/clientapi/threepid/threepid.go
+++ b/clientapi/threepid/threepid.go
@@ -81,7 +81,7 @@ func CreateSession(
// Error if the status isn't OK
if resp.StatusCode != http.StatusOK {
- return "", fmt.Errorf("Could not create a session on the server %s", req.IDServer)
+ return "", fmt.Errorf("could not create a session on the server %s", req.IDServer)
}
// Extract the SID from the response and return it
@@ -168,7 +168,7 @@ func PublishAssociation(creds Credentials, userID string, cfg *config.ClientAPI)
// Error if the status isn't OK
if resp.StatusCode != http.StatusOK {
- return fmt.Errorf("Could not publish the association on the server %s", creds.IDServer)
+ return fmt.Errorf("could not publish the association on the server %s", creds.IDServer)
}
return nil
diff --git a/clientapi/userutil/userutil.go b/clientapi/userutil/userutil.go
index 4cea3c18..7e909ffa 100644
--- a/clientapi/userutil/userutil.go
+++ b/clientapi/userutil/userutil.go
@@ -31,11 +31,11 @@ func ParseUsernameParam(usernameParam string, expectedServerName *gomatrixserver
lp, domain, err := gomatrixserverlib.SplitID('@', usernameParam)
if err != nil {
- return "", errors.New("Invalid username")
+ return "", errors.New("invalid username")
}
if expectedServerName != nil && domain != *expectedServerName {
- return "", errors.New("User ID does not belong to this server")
+ return "", errors.New("user ID does not belong to this server")
}
localpart = lp