package main

import "src.opensuse.org/autogits/common"

type PullRequestReviewed struct {
	gitea common.Gitea
}

func (o *PullRequestReviewed) Process(req *common.PullRequestWebhookEvent, git common.Git, config *common.AutogitConfig) error {
	prset, err := FetchPRSet(o.gitea, req.Repository.Owner.Username, req.Repository.Name, req.Number, config)
	if err != nil {
		return err
	}

	if prset.IsReviewed(o.gitea) {
		prset.Merge()
	}

	return nil
}
