lint and refactor

This commit is contained in:
santhoshivan23 2023-06-22 21:40:11 +05:30
parent 5346ce735a
commit 04ca62aba1
2 changed files with 3 additions and 3 deletions

View file

@ -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 {

View file

@ -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"),