mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-10 15:43:09 -06:00
lint and refactor
This commit is contained in:
parent
5346ce735a
commit
04ca62aba1
|
|
@ -281,7 +281,7 @@ func TestAdminListRegistrationTokens(t *testing.T) {
|
||||||
if tc.isValidSpecified {
|
if tc.isValidSpecified {
|
||||||
path = fmt.Sprintf("/_dendrite/admin/registrationTokens?valid=%v", tc.valid)
|
path = fmt.Sprintf("/_dendrite/admin/registrationTokens?valid=%v", tc.valid)
|
||||||
} else {
|
} else {
|
||||||
path = fmt.Sprintf("/_dendrite/admin/registrationTokens")
|
path = "/_dendrite/admin/registrationTokens"
|
||||||
}
|
}
|
||||||
req := test.NewRequest(t, http.MethodGet, path)
|
req := test.NewRequest(t, http.MethodGet, path)
|
||||||
if tc.withHeader {
|
if tc.withHeader {
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ func AdminUpdateRegistrationToken(req *http.Request, cfg *config.ClientAPI, user
|
||||||
usesAllowed, ok := request["uses_allowed"]
|
usesAllowed, ok := request["uses_allowed"]
|
||||||
if ok {
|
if ok {
|
||||||
// Only add usesAllowed to newAtrributes if it is present and valid
|
// Only add usesAllowed to newAtrributes if it is present and valid
|
||||||
if !(usesAllowed == nil || *usesAllowed >= 0) {
|
if usesAllowed != nil && *usesAllowed < 0 {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
JSON: spec.BadJSON("uses_allowed must be a non-negative integer or null"),
|
JSON: spec.BadJSON("uses_allowed must be a non-negative integer or null"),
|
||||||
|
|
@ -241,7 +241,7 @@ func AdminUpdateRegistrationToken(req *http.Request, cfg *config.ClientAPI, user
|
||||||
expiryTime, ok := request["expiry_time"]
|
expiryTime, ok := request["expiry_time"]
|
||||||
if ok {
|
if ok {
|
||||||
// Only add expiryTime to newAtrributes if it is present and valid
|
// Only add expiryTime to newAtrributes if it is present and valid
|
||||||
if !(expiryTime == nil || *expiryTime > time.Now().UnixNano()/int64(time.Millisecond)) {
|
if expiryTime != nil && spec.Timestamp(*expiryTime).Time().Before(time.Now()) {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
JSON: spec.BadJSON("expiry_time must not be in the past"),
|
JSON: spec.BadJSON("expiry_time must not be in the past"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue