(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder, cap *boolset.BooleanSet)
| 405 | } |
| 406 | |
| 407 | func BuildFileResponse(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder, cap *boolset.BooleanSet) *FileResponse { |
| 408 | var owner *ent.User |
| 409 | if f != nil { |
| 410 | owner = f.Owner() |
| 411 | } |
| 412 | |
| 413 | if cap == nil { |
| 414 | cap = f.Capabilities() |
| 415 | } |
| 416 | |
| 417 | res := &FileResponse{ |
| 418 | Type: int(f.Type()), |
| 419 | ID: hashid.EncodeFileID(hasher, f.ID()), |
| 420 | Name: f.DisplayName(), |
| 421 | CreatedAt: f.CreatedAt(), |
| 422 | UpdatedAt: f.UpdatedAt(), |
| 423 | Size: f.Size(), |
| 424 | Metadata: f.Metadata(), |
| 425 | Path: f.Uri(false).String(), |
| 426 | Shared: f.Shared(), |
| 427 | Capability: cap, |
| 428 | Owned: owner == nil || owner.ID == u.ID, |
| 429 | FolderSummary: f.FolderSummary(), |
| 430 | ExtendedInfo: BuildExtendedInfo(ctx, u, f, hasher), |
| 431 | PrimaryEntity: hashid.EncodeEntityID(hasher, f.PrimaryEntityID()), |
| 432 | } |
| 433 | return res |
| 434 | } |
| 435 | |
| 436 | func BuildExtendedInfo(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder) *ExtendedInfo { |
| 437 | extendedInfo := f.ExtendedInfo() |
no test coverage detected