FileViewDelete removes a file from being marked as viewed.
( ctx context.Context, session *auth.Session, repoRef string, prNum int64, filePath string, )
| 25 | |
| 26 | // FileViewDelete removes a file from being marked as viewed. |
| 27 | func (c *Controller) FileViewDelete( |
| 28 | ctx context.Context, |
| 29 | session *auth.Session, |
| 30 | repoRef string, |
| 31 | prNum int64, |
| 32 | filePath string, |
| 33 | ) error { |
| 34 | repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoReview) |
| 35 | if err != nil { |
| 36 | return fmt.Errorf("failed to acquire access to repo: %w", err) |
| 37 | } |
| 38 | |
| 39 | pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, prNum) |
| 40 | if err != nil { |
| 41 | return fmt.Errorf("failed to find pull request by number: %w", err) |
| 42 | } |
| 43 | |
| 44 | if filePath == "" { |
| 45 | return usererror.BadRequest("file path can't be empty") |
| 46 | } |
| 47 | |
| 48 | err = c.fileViewStore.DeleteByFileForPrincipal(ctx, pr.ID, session.Principal.ID, filePath) |
| 49 | if err != nil { |
| 50 | return fmt.Errorf("failed to delete file view entry in db: %w", err) |
| 51 | } |
| 52 | |
| 53 | return nil |
| 54 | } |
no test coverage detected