Documentation ¶
Index ¶
Constants ¶
const BoltDBFile = "webhooks.db"
BoltDBFile is the filename to store the boltdb database
Variables ¶
var EventLabels = map[string]EventEnum{ "all": EventAll, "localdelivery": EventLocalDelivery, "faileddelivery": EventFailedDelivery, "remotedelivery": EventRemoteDelivery, "apikeycreated": EventAPIKeyCreated, "apikeydeleted": EventAPIKeyDeleted, "apikeyupdated": EventAPIKeyUpdated, "authkeycreated": EventAuthKeyCreated, "authkeydeleted": EventAuthKeyDeleted, "authkeyupdated": EventAuthKeyUpdated, "webhookcreated": EventWebhookCreated, "webhookdeleted": EventWebhookDeleted, "webhookupdated": EventWebhookUpdated, "invitecreated": EventInviteCreated, "accountcreated": EventAccountCreated, "test": EventTest, }
EventLabels is the mapping of an event to a string or string to event
Functions ¶
This section is empty.
Types ¶
type ConfigSlack ¶
type ConfigSlack struct { WebhookURL string Channel string Username string IconEmoji string IconURL string Template string }
ConfigSlack Configuration for TypeSlack (not yet implemented)
type EventEnum ¶
type EventEnum int
EventEnum is the event on which the webhook responds
const ( EventLocalDelivery EventEnum = iota + 1 // A local delivery has been made (incoming) EventFailedDelivery // A message is received but not considered correct EventRemoteDelivery // A message has been send to a remote server (outgoing) EventAPIKeyCreated // Api Key created EventAPIKeyDeleted // Api key deleted EventAPIKeyUpdated // Api key updated EventAuthKeyCreated // Auth key created EventAuthKeyDeleted // Auth key deleted EventAuthKeyUpdated // Auth key updated EventWebhookCreated // webhook created EventWebhookDeleted // webhook deleted EventWebhookUpdated // webhook updated EventInviteCreated // invite created EventAccountCreated // account created EventTest EventEnum = 998 // Test event EventAll EventEnum = 999 // All events )
Webhook event types. Everything that a webhook can trigger on
func NewEventFromString ¶
NewEventFromString will create a new event based on the string
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is a repository to fetch and store webhooks
func NewBoltRepository ¶
func NewBoltRepository(dbPath string) *Repository
NewBoltRepository initializes a new BoltDb repository
func NewMockRepository ¶
func NewMockRepository() *Repository
NewMockRepository initializes a new mock repository
func NewRedisRepository ¶
func NewRedisRepository(opts *redis.Options) *Repository
NewRedisRepository initializes a new Redis repository
func (Repository) Fetch ¶
func (r Repository) Fetch(ID string) (*Type, error)
Fetch will get a single API key
func (Repository) FetchByHash ¶
func (r Repository) FetchByHash(h hash.Hash) ([]Type, error)
FetchByHash will fetch all api keys for the given address hash
func (Repository) Remove ¶
func (r Repository) Remove(w Type) error
Remove will remove a single webhook
type Storage ¶
type Storage interface { FetchByHash(h hash.Hash) ([]Type, error) Fetch(ID string) (*Type, error) Store(w Type) error Remove(w Type) error }
Storage is the main interface for fetching and storing webhook data
type Type ¶
type Type struct { ID string // Id of the webhook (uuidv4) Account hash.Hash // account to which this webhook belongs to Type TypeEnum // type of webhook Event EventEnum // event when this webhook is triggered Enabled bool // true when the webhook is enabled Config string // config for the given target, json encoded }
Type is the webhook structure