(ctx context.Context, req *getFilesMetaRequest)
| 378 | } |
| 379 | |
| 380 | func (s *server) getFilesMeta(ctx context.Context, req *getFilesMetaRequest) (*getFilesMetaResponse, error) { |
| 381 | var fIDs []db.FileID |
| 382 | for _, f := range req.Files { |
| 383 | // TODO: Consider validating these, not sure how reliable the `e.<hex data>` is |
| 384 | // though, should dig into that a bit more. |
| 385 | fIDs = append(fIDs, db.FileID(f)) |
| 386 | } |
| 387 | |
| 388 | gID := db.GraphID(req.GraphUUID) |
| 389 | mds, err := s.db.BatchFileMeta(ctx, gID, fIDs) |
| 390 | if err != nil { |
| 391 | return nil, httperr.Internal("failed to load batch file meta: %w", err) |
| 392 | } |
| 393 | |
| 394 | userID, err := s.getUserID(ctx) |
| 395 | if err != nil { |
| 396 | return nil, httperr.Unauthorized("failed to load user ID: %w", err) |
| 397 | } |
| 398 | |
| 399 | out := []getFilesMetaResponseSingle{} |
| 400 | for id, md := range mds { |
| 401 | if md == nil { |
| 402 | // Means the requested ID wasn't found |
| 403 | out = append(out, getFilesMetaResponseSingle{ |
| 404 | FilePath: string(id), |
| 405 | Error: fmt.Sprintf("not found %s/%s/%s", userID, gID, id), |
| 406 | }) |
| 407 | continue |
| 408 | } |
| 409 | |
| 410 | out = append(out, getFilesMetaResponseSingle{ |
| 411 | FilePath: string(md.ID), |
| 412 | Checksum: string(md.Checksum), |
| 413 | LastModified: md.LastModifiedAt.UnixMilli(), |
| 414 | Size: md.Size, |
| 415 | Txid: int64(md.LastModifiedTX), |
| 416 | }) |
| 417 | } |
| 418 | |
| 419 | // This is a wonky thing to do, but the alternative is not using the handy-dandy |
| 420 | // toHandleFunc helper |
| 421 | resp := getFilesMetaResponse(out) |
| 422 | return &resp, nil |
| 423 | } |
| 424 | |
| 425 | type userInfoRequest struct{} |
| 426 | type userInfoResponse struct { |
nothing calls this directly
no test coverage detected