|
|
@ -148,6 +148,25 @@ func getTelegramPullRequestPayload(p *api.PullRequestPayload) (*TelegramPayload, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getTelegramPullRequestApprovalPayload(p *api.PullRequestPayload, event models.HookEventType) (*TelegramPayload, error) { |
|
|
|
|
|
|
|
var text, attachmentText string |
|
|
|
|
|
|
|
switch p.Action { |
|
|
|
|
|
|
|
case api.HookIssueSynchronized: |
|
|
|
|
|
|
|
action, err := parseHookPullRequestEventType(event) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = fmt.Sprintf("[%s] Pull request review %s: #%d %s", p.Repository.FullName, action, p.Index, p.PullRequest.Title) |
|
|
|
|
|
|
|
attachmentText = p.Review.Content |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return &TelegramPayload{ |
|
|
|
|
|
|
|
Message: text + "\n" + attachmentText, |
|
|
|
|
|
|
|
}, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getTelegramRepositoryPayload(p *api.RepositoryPayload) (*TelegramPayload, error) { |
|
|
|
func getTelegramRepositoryPayload(p *api.RepositoryPayload) (*TelegramPayload, error) { |
|
|
|
var title string |
|
|
|
var title string |
|
|
|
switch p.Action { |
|
|
|
switch p.Action { |
|
|
@ -192,6 +211,8 @@ func GetTelegramPayload(p api.Payloader, event models.HookEventType, meta string |
|
|
|
return getTelegramPushPayload(p.(*api.PushPayload)) |
|
|
|
return getTelegramPushPayload(p.(*api.PushPayload)) |
|
|
|
case models.HookEventPullRequest: |
|
|
|
case models.HookEventPullRequest: |
|
|
|
return getTelegramPullRequestPayload(p.(*api.PullRequestPayload)) |
|
|
|
return getTelegramPullRequestPayload(p.(*api.PullRequestPayload)) |
|
|
|
|
|
|
|
case models.HookEventPullRequestRejected, models.HookEventPullRequestApproved, models.HookEventPullRequestComment: |
|
|
|
|
|
|
|
return getTelegramPullRequestApprovalPayload(p.(*api.PullRequestPayload), event) |
|
|
|
case models.HookEventRepository: |
|
|
|
case models.HookEventRepository: |
|
|
|
return getTelegramRepositoryPayload(p.(*api.RepositoryPayload)) |
|
|
|
return getTelegramRepositoryPayload(p.(*api.RepositoryPayload)) |
|
|
|
case models.HookEventRelease: |
|
|
|
case models.HookEventRelease: |
|
|
|