fix(webclient): share fail when expire is 0

Closes: #88
This commit is contained in:
lejianwen
2024-12-25 15:01:03 +08:00
parent c41038d2d8
commit 1dd920d192
+8 -5
View File
@@ -64,12 +64,15 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
response.Fail(c, 101, "share not found") response.Fail(c, 101, "share not found")
return return
} }
//判断是否过期,created_at + expire > now if sr.Expire != 0 {
ca := time.Time(sr.CreatedAt) //判断是否过期,created_at + expire > now
if ca.Add(time.Second * time.Duration(sr.Expire)).Before(time.Now()) { ca := time.Time(sr.CreatedAt)
response.Fail(c, 101, "share expired") if ca.Add(time.Second * time.Duration(sr.Expire)).Before(time.Now()) {
return response.Fail(c, 101, "share expired")
return
}
} }
ab := service.AllService.AddressBookService.InfoByUserIdAndId(sr.UserId, sr.PeerId) ab := service.AllService.AddressBookService.InfoByUserIdAndId(sr.UserId, sr.PeerId)
if ab.RowId == 0 { if ab.RowId == 0 {
response.Fail(c, 101, "peer not found") response.Fail(c, 101, "peer not found")