Просмотр исходного кода

fix(webclient): share fail when expire is 0

Closes: #88
lejianwen 1 год назад
Родитель
Сommit
1dd920d192
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      http/controller/api/webClient.go

+ 8 - 5
http/controller/api/webClient.go

@@ -64,12 +64,15 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
64
 		response.Fail(c, 101, "share not found")
64
 		response.Fail(c, 101, "share not found")
65
 		return
65
 		return
66
 	}
66
 	}
67
-	//判断是否过期,created_at + expire > now
68
-	ca := time.Time(sr.CreatedAt)
69
-	if ca.Add(time.Second * time.Duration(sr.Expire)).Before(time.Now()) {
70
-		response.Fail(c, 101, "share expired")
71
-		return
67
+	if sr.Expire != 0 {
68
+		//判断是否过期,created_at + expire > now
69
+		ca := time.Time(sr.CreatedAt)
70
+		if ca.Add(time.Second * time.Duration(sr.Expire)).Before(time.Now()) {
71
+			response.Fail(c, 101, "share expired")
72
+			return
73
+		}
72
 	}
74
 	}
75
+
73
 	ab := service.AllService.AddressBookService.InfoByUserIdAndId(sr.UserId, sr.PeerId)
76
 	ab := service.AllService.AddressBookService.InfoByUserIdAndId(sr.UserId, sr.PeerId)
74
 	if ab.RowId == 0 {
77
 	if ab.RowId == 0 {
75
 		response.Fail(c, 101, "peer not found")
78
 		response.Fail(c, 101, "peer not found")