Browse Source

fix(webclient): share fail when expire is 0

Closes: #88
lejianwen 1 year ago
parent
commit
0dbab182e9
1 changed files with 8 additions and 5 deletions
  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 64
 		response.Fail(c, 101, "share not found")
65 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 76
 	ab := service.AllService.AddressBookService.InfoByUserIdAndId(sr.UserId, sr.PeerId)
74 77
 	if ab.RowId == 0 {
75 78
 		response.Fail(c, 101, "peer not found")