MCPcopy Create free account
hub / github.com/gogs/gogs / NewIssue

Function NewIssue

internal/database/issue.go:756–803  ·  view source on GitHub ↗

NewIssue creates new issue with labels and attachments for repository.

(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)

Source from the content-addressed store, hash-verified

754
755// NewIssue creates new issue with labels and attachments for repository.
756func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) {
757 sess := x.NewSession()
758 defer sess.Close()
759 if err = sess.Begin(); err != nil {
760 return err
761 }
762
763 if err = newIssue(sess, NewIssueOptions{
764 Repo: repo,
765 Issue: issue,
766 LableIDs: labelIDs,
767 Attachments: uuids,
768 }); err != nil {
769 return errors.Newf("new issue: %v", err)
770 }
771
772 if err = sess.Commit(); err != nil {
773 return errors.Newf("commit: %v", err)
774 }
775
776 if err = NotifyWatchers(&Action{
777 ActUserID: issue.Poster.ID,
778 ActUserName: issue.Poster.Name,
779 OpType: ActionCreateIssue,
780 Content: fmt.Sprintf("%d|%s", issue.Index, issue.Title),
781 RepoID: repo.ID,
782 RepoUserName: repo.Owner.Name,
783 RepoName: repo.Name,
784 IsPrivate: repo.IsPrivate,
785 }); err != nil {
786 log.Error("NotifyWatchers: %v", err)
787 }
788 if err = issue.MailParticipants(); err != nil {
789 log.Error("MailParticipants: %v", err)
790 }
791
792 if err = PrepareWebhooks(repo, HookEventTypeIssues, &api.IssuesPayload{
793 Action: api.HOOK_ISSUE_OPENED,
794 Index: issue.Index,
795 Issue: issue.APIFormat(),
796 Repository: repo.APIFormatLegacy(nil),
797 Sender: issue.Poster.APIFormat(),
798 }); err != nil {
799 log.Error("PrepareWebhooks: %v", err)
800 }
801
802 return nil
803}
804
805var _ errutil.NotFound = (*ErrIssueNotExist)(nil)
806

Callers 2

NewIssuePostFunction · 0.92
CreateIssueFunction · 0.92

Calls 7

newIssueFunction · 0.85
NotifyWatchersFunction · 0.85
PrepareWebhooksFunction · 0.85
MailParticipantsMethod · 0.80
APIFormatLegacyMethod · 0.80
ErrorMethod · 0.45
APIFormatMethod · 0.45

Tested by

no test coverage detected