keel/bot/hipchat/approvals.go

35 lines
1.1 KiB
Go
Raw Normal View History

package hipchat
import (
"fmt"
"github.com/keel-hq/keel/types"
)
2017-12-27 13:46:38 +00:00
func (b *Bot) RequestApproval(req *types.Approval) error {
msg := fmt.Sprintf(ApprovalRequiredTempl,
req.Message, req.Identifier, req.Identifier,
req.VotesReceived, req.VotesRequired, req.Delta(), req.Identifier,
req.Provider.String())
return b.postMessage(formatAsSnippet(msg))
}
2017-12-27 13:46:38 +00:00
func (b *Bot) ReplyToApproval(approval *types.Approval) error {
switch approval.Status() {
case types.ApprovalStatusPending:
msg := fmt.Sprintf(VoteReceivedTempl,
approval.VotesReceived, approval.VotesRequired, approval.Delta(), approval.Identifier)
b.postMessage(formatAsSnippet(msg))
case types.ApprovalStatusRejected:
msg := fmt.Sprintf(ChangeRejectedTempl,
approval.Status().String(), approval.VotesReceived, approval.VotesRequired,
approval.Delta(), approval.Identifier)
b.postMessage(formatAsSnippet(msg))
case types.ApprovalStatusApproved:
msg := fmt.Sprintf(UpdateApprovedTempl,
approval.VotesReceived, approval.VotesRequired, approval.Delta(), approval.Identifier)
b.postMessage(formatAsSnippet(msg))
}
return nil
}