2017-04-11 19:06:45 +02:00
|
|
|
package sender
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/drone/drone/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
type builtin struct {
|
|
|
|
store model.SenderStore
|
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new local gating service.
|
|
|
|
func New(store model.SenderStore) model.SenderService {
|
|
|
|
return &builtin{store}
|
|
|
|
}
|
|
|
|
|
2017-05-05 19:13:40 +02:00
|
|
|
func (b *builtin) SenderAllowed(user *model.User, repo *model.Repo, build *model.Build, conf *model.Config) (bool, error) {
|
|
|
|
if !conf.Approved {
|
2017-04-11 19:06:45 +02:00
|
|
|
sender, err := b.store.SenderFind(repo, build.Sender)
|
|
|
|
if err != nil || sender.Block {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SenderCreate(repo *model.Repo, sender *model.Sender) error {
|
|
|
|
return b.store.SenderCreate(sender)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SenderUpdate(repo *model.Repo, sender *model.Sender) error {
|
|
|
|
return b.store.SenderUpdate(sender)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SenderDelete(repo *model.Repo, login string) error {
|
|
|
|
sender, err := b.store.SenderFind(repo, login)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return b.store.SenderDelete(sender)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SenderList(repo *model.Repo) ([]*model.Sender, error) {
|
|
|
|
return b.store.SenderList(repo)
|
|
|
|
}
|