writeReplyActivity updates the parent activity's reply sequence number (using the optimistic locking mechanism), sets the correct Order and SubOrder values and writes the activity to the database. Even if the writing fails, the updating of the sequence number can succeed.
(ctx context.Context, parent, act *types.PullReqActivity)
| 297 | // sets the correct Order and SubOrder values and writes the activity to the database. |
| 298 | // Even if the writing fails, the updating of the sequence number can succeed. |
| 299 | func (c *Controller) writeReplyActivity(ctx context.Context, parent, act *types.PullReqActivity) error { |
| 300 | parentUpd, err := c.activityStore.UpdateOptLock(ctx, parent, func(act *types.PullReqActivity) error { |
| 301 | act.ReplySeq++ |
| 302 | return nil |
| 303 | }) |
| 304 | if err != nil { |
| 305 | return fmt.Errorf("failed to get pull request activity number: %w", err) |
| 306 | } |
| 307 | |
| 308 | *parent = *parentUpd // update the parent pull request activity object |
| 309 | |
| 310 | act.Order = parentUpd.Order |
| 311 | act.SubOrder = parentUpd.ReplySeq |
| 312 | |
| 313 | err = c.activityStore.Create(ctx, act) |
| 314 | if err != nil { |
| 315 | return fmt.Errorf("failed to create pull request activity: %w", err) |
| 316 | } |
| 317 | |
| 318 | return nil |
| 319 | } |
| 320 | |
| 321 | func getCommentActivity( |
| 322 | session *auth.Session, |
no test coverage detected