(code string)
| 259 | } |
| 260 | |
| 261 | func (s *FileShareService) GetByCode(code string) (*response.FileShareInfo, error) { |
| 262 | item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code))) |
| 263 | if err != nil { |
| 264 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 265 | return nil, buserr.New("ErrFileShareInvalid") |
| 266 | } |
| 267 | return nil, err |
| 268 | } |
| 269 | if err := s.pruneInvalidShare(item); err != nil { |
| 270 | return nil, err |
| 271 | } |
| 272 | if item.ExpiresUnix > 0 && time.Now().Unix() > item.ExpiresUnix { |
| 273 | return nil, buserr.New("ErrFileShareExpired") |
| 274 | } |
| 275 | info := shareModelToInfo(item) |
| 276 | return &info, nil |
| 277 | } |
| 278 | |
| 279 | func (s *FileShareService) GetPublicByCode(code string) (*response.FileSharePublicInfo, error) { |
| 280 | item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code))) |
nothing calls this directly
no test coverage detected