38 lines
751 B
Go
38 lines
751 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"src.opensuse.org/autogits/common"
|
|
)
|
|
|
|
type IssueProcessor struct {
|
|
bot *ReparentBot
|
|
}
|
|
|
|
func (s *IssueProcessor) ProcessFunc(req *common.Request) error {
|
|
var org, repo string
|
|
var index int64
|
|
|
|
switch data := req.Data.(type) {
|
|
case *common.IssueWebhookEvent:
|
|
org = data.Repository.Owner.Username
|
|
repo = data.Repository.Name
|
|
index = int64(data.Issue.Number)
|
|
case *common.IssueCommentWebhookEvent:
|
|
org = data.Repository.Owner.Username
|
|
repo = data.Repository.Name
|
|
index = int64(data.Issue.Number)
|
|
default:
|
|
return fmt.Errorf("Unhandled request type: %s", req.Type)
|
|
}
|
|
|
|
issue, err := s.bot.gitea.GetIssue(org, repo, index)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return s.bot.ProcessIssue(org, repo, issue)
|
|
}
|
|
|
|
|