ActivityList returns a list of pull request activities from the provided repository and pull request number.
( ctx context.Context, session *auth.Session, repoRef string, prNum int64, filter *types.PullReqActivityFilter, )
| 26 | // ActivityList returns a list of pull request activities |
| 27 | // from the provided repository and pull request number. |
| 28 | func (c *Controller) ActivityList( |
| 29 | ctx context.Context, |
| 30 | session *auth.Session, |
| 31 | repoRef string, |
| 32 | prNum int64, |
| 33 | filter *types.PullReqActivityFilter, |
| 34 | ) ([]*types.PullReqActivity, error) { |
| 35 | repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoView) |
| 36 | if err != nil { |
| 37 | return nil, fmt.Errorf("failed to acquire access to repo: %w", err) |
| 38 | } |
| 39 | |
| 40 | pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, prNum) |
| 41 | if err != nil { |
| 42 | return nil, fmt.Errorf("failed to find pull request by number: %w", err) |
| 43 | } |
| 44 | |
| 45 | list, err := c.activityStore.List(ctx, pr.ID, filter) |
| 46 | if err != nil { |
| 47 | return nil, fmt.Errorf("failed to list pull requests activities: %w", err) |
| 48 | } |
| 49 | |
| 50 | for _, act := range list { |
| 51 | if act.Metadata != nil && act.Metadata.Mentions != nil { |
| 52 | mentions, err := c.principalInfoCache.Map(ctx, act.Metadata.Mentions.IDs) |
| 53 | if err != nil { |
| 54 | return nil, fmt.Errorf("failed to fetch activity mentions from principalInfoView: %w", err) |
| 55 | } |
| 56 | act.Mentions = mentions |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | list = removeDeletedComments(list) |
| 61 | |
| 62 | return list, nil |
| 63 | } |
| 64 | |
| 65 | func allCommentsDeleted(comments []*types.PullReqActivity) bool { |
| 66 | for _, comment := range comments { |
no test coverage detected