We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1e1dfa commit 4f9891dCopy full SHA for 4f9891d
services/stat.go
@@ -1,6 +1,7 @@
1
package services
2
3
import (
4
+ "fmt"
5
"net/http"
6
"strconv"
7
"time"
@@ -39,10 +40,14 @@ func EndpointStat(ng *gin.Engine) {
39
40
err := db.Transaction(func(tx *gorm.DB) error {
41
for _, v := range form {
42
for _, t := range v.At {
43
+ timeParsed := time.Unix(t, 0)
44
+ if timeParsed.After(time.Now().Add(time.Hour)) {
45
+ return fmt.Errorf("play time is significantly larger than current time: %v", timeParsed)
46
+ }
47
record := model.PlayRecord{
48
UserID: user.ID,
49
Track: v.Track,
- At: time.Unix(t, 0),
50
+ At: timeParsed,
51
}
52
if err := tx.Save(&record).Error; err != nil {
53
return err
0 commit comments