add(messaging): import webhook type
This commit is contained in:
@@ -30,7 +30,7 @@ func Init() error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := http.New(&config.HTTPClient{
|
||||
_, err = http.New(&config.HTTPClient{
|
||||
Timeout: 10,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package types
|
||||
|
||||
// Hello! This file is auto-generated.
|
||||
|
||||
type (
|
||||
|
||||
// WebhookSet slice of Webhook
|
||||
//
|
||||
// This type is auto-generated.
|
||||
WebhookSet []*Webhook
|
||||
)
|
||||
|
||||
// Walk iterates through every slice item and calls w(Webhook) err
|
||||
//
|
||||
// This function is auto-generated.
|
||||
func (set WebhookSet) Walk(w func(*Webhook) error) (err error) {
|
||||
for i := range set {
|
||||
if err = w(set[i]); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Filter iterates through every slice item, calls f(Webhook) (bool, err) and return filtered slice
|
||||
//
|
||||
// This function is auto-generated.
|
||||
func (set WebhookSet) Filter(f func(*Webhook) (bool, error)) (out WebhookSet, err error) {
|
||||
var ok bool
|
||||
out = WebhookSet{}
|
||||
for i := range set {
|
||||
if ok, err = f(set[i]); err != nil {
|
||||
return
|
||||
} else if ok {
|
||||
out = append(out, set[i])
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FindByID finds items from slice by its ID property
|
||||
//
|
||||
// This function is auto-generated.
|
||||
func (set WebhookSet) FindByID(ID uint64) *Webhook {
|
||||
for i := range set {
|
||||
if set[i].ID == ID {
|
||||
return set[i]
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IDs returns a slice of uint64s from all items in the set
|
||||
//
|
||||
// This function is auto-generated.
|
||||
func (set WebhookSet) IDs() (IDs []uint64) {
|
||||
IDs = make([]uint64, len(set))
|
||||
|
||||
for i := range set {
|
||||
IDs[i] = set[i].ID
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"mime/multipart"
|
||||
|
||||
"github.com/crusttech/crust/internal/rules"
|
||||
)
|
||||
|
||||
type (
|
||||
Webhook struct {
|
||||
ID uint64 `json:"id" db:"id"`
|
||||
|
||||
Kind WebhookKind `json:"kind" db:"webhook_kind"`
|
||||
AuthToken string `json:"-" db:"webhook_token"`
|
||||
|
||||
OwnerUserID uint64 `json:"userId" db:"rel_owner"`
|
||||
|
||||
// Created bot User ID
|
||||
UserID uint64 `json:"userId" db:"rel_user"`
|
||||
ChannelID uint64 `json:"channelId" db:"rel_channel"`
|
||||
|
||||
// Outgoing webhook details
|
||||
OutgoingTrigger string `json:"trigger" db:"outgoing_trigger"`
|
||||
OutgoingURL string `json:"url" db:"outgoing_url"`
|
||||
|
||||
CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"`
|
||||
UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"`
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"`
|
||||
}
|
||||
|
||||
WebhookRequest struct {
|
||||
Username string
|
||||
|
||||
Avatar *multipart.FileHeader
|
||||
AvatarURL string
|
||||
|
||||
OutgoingTrigger string
|
||||
OutgoingURL string
|
||||
}
|
||||
|
||||
WebhookFilter struct {
|
||||
ChannelID uint64
|
||||
OwnerUserID uint64
|
||||
OutgoingTrigger string
|
||||
}
|
||||
|
||||
WebhookBody struct {
|
||||
Text string `json:"text"`
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
WebhookKind string
|
||||
)
|
||||
|
||||
const (
|
||||
IncomingWebhook WebhookKind = "incoming"
|
||||
OutgoingWebhook = "outgoing"
|
||||
)
|
||||
|
||||
// Resource returns a system resource ID for this type
|
||||
func (wh Webhook) PermissionResource() rules.Resource {
|
||||
return WebhookPermissionResource.AppendID(wh.ID)
|
||||
}
|
||||
Reference in New Issue
Block a user