mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-15 13:42:26 +03:00
linter fixes
This commit is contained in:
parent
7311d3e1de
commit
0990676466
6 changed files with 23 additions and 24 deletions
|
@ -539,7 +539,7 @@ func AdminUserDeviceRetrieveCreate(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, _ := vars["userID"]
|
userID := vars["userID"]
|
||||||
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
@ -567,7 +567,7 @@ func AdminUserDeviceRetrieveCreate(
|
||||||
userDeviceExists := false
|
userDeviceExists := false
|
||||||
{
|
{
|
||||||
var rs api.QueryDevicesResponse
|
var rs api.QueryDevicesResponse
|
||||||
if err := userAPI.QueryDevices(req.Context(), &api.QueryDevicesRequest{UserID: userID}, &rs); err != nil {
|
if err = userAPI.QueryDevices(req.Context(), &api.QueryDevicesRequest{UserID: userID}, &rs); err != nil {
|
||||||
logger.WithError(err).Error("QueryDevices")
|
logger.WithError(err).Error("QueryDevices")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
@ -590,7 +590,7 @@ func AdminUserDeviceRetrieveCreate(
|
||||||
|
|
||||||
if !userDeviceExists {
|
if !userDeviceExists {
|
||||||
var rs userapi.PerformDeviceCreationResponse
|
var rs userapi.PerformDeviceCreationResponse
|
||||||
if err := userAPI.PerformDeviceCreation(req.Context(), &userapi.PerformDeviceCreationRequest{
|
if err = userAPI.PerformDeviceCreation(req.Context(), &userapi.PerformDeviceCreationRequest{
|
||||||
Localpart: local,
|
Localpart: local,
|
||||||
ServerName: domain,
|
ServerName: domain,
|
||||||
DeviceID: &payload.DeviceID,
|
DeviceID: &payload.DeviceID,
|
||||||
|
@ -656,8 +656,8 @@ func AdminUserDeviceDelete(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, _ := vars["userID"]
|
userID := vars["userID"]
|
||||||
deviceID, _ := vars["deviceID"]
|
deviceID := vars["deviceID"]
|
||||||
logger := util.GetLogger(req.Context())
|
logger := util.GetLogger(req.Context())
|
||||||
|
|
||||||
// XXX: we probably have to delete session from the sessions dict
|
// XXX: we probably have to delete session from the sessions dict
|
||||||
|
@ -718,13 +718,13 @@ func AdminUserDevicesDelete(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, _ := vars["userID"]
|
userID := vars["userID"]
|
||||||
|
|
||||||
var payload struct {
|
var payload struct {
|
||||||
Devices []string `json:"devices"`
|
Devices []string `json:"devices"`
|
||||||
}
|
}
|
||||||
|
|
||||||
defer req.Body.Close()
|
defer req.Body.Close() // nolint: errcheck
|
||||||
if err = json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
if err = json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
||||||
logger.WithError(err).Error("unable to decode device deletion request")
|
logger.WithError(err).Error("unable to decode device deletion request")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
@ -765,7 +765,7 @@ func AdminDeactivateAccount(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, _ := vars["userID"]
|
userID := vars["userID"]
|
||||||
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
|
@ -836,11 +836,6 @@ func AdminAllowCrossSigningReplacementWithoutUIA(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type adminExternalID struct {
|
|
||||||
AuthProvider string `json:"auth_provider"`
|
|
||||||
ExternalID string `json:"external_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type adminCreateOrModifyAccountRequest struct {
|
type adminCreateOrModifyAccountRequest struct {
|
||||||
DisplayName string `json:"displayname"`
|
DisplayName string `json:"displayname"`
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
@ -848,10 +843,13 @@ type adminCreateOrModifyAccountRequest struct {
|
||||||
Medium string `json:"medium"`
|
Medium string `json:"medium"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
} `json:"threepids"`
|
} `json:"threepids"`
|
||||||
// TODO: the following fields are not used here, but they are used in Synapse.
|
// TODO: the following fields are not used by dendrite, but they are used in Synapse.
|
||||||
// Password string `json:"password"`
|
// Password string `json:"password"`
|
||||||
// LogoutDevices bool `json:"logout_devices"`
|
// LogoutDevices bool `json:"logout_devices"`
|
||||||
// ExternalIDs []adminExternalID `json:"external_ids"`
|
// ExternalIDs []struct{
|
||||||
|
// AuthProvider string `json:"auth_provider"`
|
||||||
|
// ExternalID string `json:"external_id"`
|
||||||
|
// } `json:"external_ids"`
|
||||||
// Admin bool `json:"admin"`
|
// Admin bool `json:"admin"`
|
||||||
// Deactivated bool `json:"deactivated"`
|
// Deactivated bool `json:"deactivated"`
|
||||||
// Locked bool `json:"locked"`
|
// Locked bool `json:"locked"`
|
||||||
|
@ -863,7 +861,7 @@ func AdminCreateOrModifyAccount(req *http.Request, userAPI userapi.ClientUserAPI
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, _ := vars["userID"]
|
userID := vars["userID"]
|
||||||
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
|
@ -204,7 +204,7 @@ func SetDisplayName(
|
||||||
// to the provider's pseudo-device and includes only the AccountTypeOIDCService flag. To continue,
|
// to the provider's pseudo-device and includes only the AccountTypeOIDCService flag. To continue,
|
||||||
// we need to replace the admin's device with the user's device
|
// we need to replace the admin's device with the user's device
|
||||||
var rs userapi.QueryDevicesResponse
|
var rs userapi.QueryDevicesResponse
|
||||||
err := userAPI.QueryDevices(req.Context(), &userapi.QueryDevicesRequest{UserID: userID}, &rs)
|
err = userAPI.QueryDevices(req.Context(), &userapi.QueryDevicesRequest{UserID: userID}, &rs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
|
|
@ -148,6 +148,7 @@ type requester struct {
|
||||||
IsGuest bool
|
IsGuest bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: gocyclo
|
||||||
func (m *MSC3861UserVerifier) getUserByAccessToken(ctx context.Context, token string) (*requester, error) {
|
func (m *MSC3861UserVerifier) getUserByAccessToken(ctx context.Context, token string) (*requester, error) {
|
||||||
var userID *spec.UserID
|
var userID *spec.UserID
|
||||||
logger := util.GetLogger(ctx)
|
logger := util.GetLogger(ctx)
|
||||||
|
@ -220,7 +221,7 @@ func (m *MSC3861UserVerifier) getUserByAccessToken(ctx context.Context, token st
|
||||||
var account *api.Account
|
var account *api.Account
|
||||||
{
|
{
|
||||||
var rs api.QueryAccountByLocalpartResponse
|
var rs api.QueryAccountByLocalpartResponse
|
||||||
err := m.userAPI.QueryAccountByLocalpart(ctx, &api.QueryAccountByLocalpartRequest{Localpart: userID.Local(), ServerName: userID.Domain()}, &rs)
|
err = m.userAPI.QueryAccountByLocalpart(ctx, &api.QueryAccountByLocalpartRequest{Localpart: userID.Local(), ServerName: userID.Domain()}, &rs)
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
logger.WithError(err).Error("QueryAccountByLocalpart")
|
logger.WithError(err).Error("QueryAccountByLocalpart")
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -241,7 +242,7 @@ func (m *MSC3861UserVerifier) getUserByAccessToken(ctx context.Context, token st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.userAPI.PerformLocalpartExternalUserIDCreation(ctx, &api.PerformLocalpartExternalUserIDCreationRequest{
|
if err = m.userAPI.PerformLocalpartExternalUserIDCreation(ctx, &api.PerformLocalpartExternalUserIDCreationRequest{
|
||||||
Localpart: userID.Local(),
|
Localpart: userID.Local(),
|
||||||
ExternalID: sub,
|
ExternalID: sub,
|
||||||
AuthProvider: externalAuthProvider,
|
AuthProvider: externalAuthProvider,
|
||||||
|
@ -348,7 +349,7 @@ func (m *MSC3861UserVerifier) introspectToken(ctx context.Context, token string)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := resp.Body
|
body := resp.Body
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close() // nolint: errcheck
|
||||||
|
|
||||||
if c := resp.StatusCode; c < 200 || c >= 300 {
|
if c := resp.StatusCode; c < 200 || c >= 300 {
|
||||||
return nil, errors.New(strings.Join([]string{"The introspection endpoint returned a '", resp.Status, "' response"}, ""))
|
return nil, errors.New(strings.Join([]string{"The introspection endpoint returned a '", resp.Status, "' response"}, ""))
|
||||||
|
@ -405,7 +406,7 @@ func fetchOpenIDConfiguration(httpClient *http.Client, authHostURL string) (*Ope
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close() // nolint: errcheck
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, &mscError{Code: codeOpenidConfigEndpointNon2xx, Msg: ".well-known/openid-configuration endpoint returned non-200 response"}
|
return nil, &mscError{Code: codeOpenidConfigEndpointNon2xx, Msg: ".well-known/openid-configuration endpoint returned non-200 response"}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ func (s *crossSigningKeysStatements) UpsertCrossSigningKeysForUser(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *crossSigningKeysStatements) UpdateMasterCrossSigningKeyAllowReplacementWithoutUIA(ctx context.Context, txn *sql.Tx, userID string, duration time.Duration) (int64, error) {
|
func (s *crossSigningKeysStatements) UpdateMasterCrossSigningKeyAllowReplacementWithoutUIA(ctx context.Context, txn *sql.Tx, userID string, duration time.Duration) (int64, error) {
|
||||||
keyTypeInt, _ := types.KeyTypePurposeToInt[fclient.CrossSigningKeyPurposeMaster]
|
keyTypeInt := types.KeyTypePurposeToInt[fclient.CrossSigningKeyPurposeMaster]
|
||||||
ts := time.Now().Add(duration).UnixMilli()
|
ts := time.Now().Add(duration).UnixMilli()
|
||||||
result, err := sqlutil.TxStmt(txn, s.updateMasterCrossSigningKeyAllowReplacementWithoutUiaStmt).ExecContext(ctx, ts, userID, keyTypeInt)
|
result, err := sqlutil.TxStmt(txn, s.updateMasterCrossSigningKeyAllowReplacementWithoutUiaStmt).ExecContext(ctx, ts, userID, keyTypeInt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -147,7 +147,7 @@ func (s *crossSigningKeysStatements) UpsertCrossSigningKeysForUser(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *crossSigningKeysStatements) UpdateMasterCrossSigningKeyAllowReplacementWithoutUIA(ctx context.Context, txn *sql.Tx, userID string, duration time.Duration) (int64, error) {
|
func (s *crossSigningKeysStatements) UpdateMasterCrossSigningKeyAllowReplacementWithoutUIA(ctx context.Context, txn *sql.Tx, userID string, duration time.Duration) (int64, error) {
|
||||||
keyTypeInt, _ := types.KeyTypePurposeToInt[fclient.CrossSigningKeyPurposeMaster]
|
keyTypeInt := types.KeyTypePurposeToInt[fclient.CrossSigningKeyPurposeMaster]
|
||||||
ts := time.Now().Add(duration).UnixMilli()
|
ts := time.Now().Add(duration).UnixMilli()
|
||||||
result, err := sqlutil.TxStmt(txn, s.updateMasterCrossSigningKeyAllowReplacementWithoutUiaStmt).ExecContext(ctx, ts, userID, keyTypeInt)
|
result, err := sqlutil.TxStmt(txn, s.updateMasterCrossSigningKeyAllowReplacementWithoutUiaStmt).ExecContext(ctx, ts, userID, keyTypeInt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue