mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 23:23:10 -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 {
|
||||
path = fmt.Sprintf("/_dendrite/admin/registrationTokens?valid=%v", tc.valid)
|
||||
} else {
|
||||
path = fmt.Sprintf("/_dendrite/admin/registrationTokens")
|
||||
path = "/_dendrite/admin/registrationTokens"
|
||||
}
|
||||
req := test.NewRequest(t, http.MethodGet, path)
|
||||
if tc.withHeader {
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ func AdminUpdateRegistrationToken(req *http.Request, cfg *config.ClientAPI, user
|
|||
usesAllowed, ok := request["uses_allowed"]
|
||||
if ok {
|
||||
// Only add usesAllowed to newAtrributes if it is present and valid
|
||||
if !(usesAllowed == nil || *usesAllowed >= 0) {
|
||||
if usesAllowed != nil && *usesAllowed < 0 {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
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"]
|
||||
if ok {
|
||||
// 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{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: spec.BadJSON("expiry_time must not be in the past"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue