Documentation ¶
Index ¶
- Constants
- func Routes(router *httprouter.Router, ds *store.InMemory)
- type Event
- func (*Event) Descriptor() ([]byte, []int)
- func (m *Event) GetCreationTime() *timestamp.Timestamp
- func (m *Event) GetData() string
- func (m *Event) GetId() string
- func (m *Event) GetSourceId() string
- func (m *Event) GetType() string
- func (e Event) Key() string
- func (e Event) MarshalJSON() ([]byte, error)
- func (*Event) ProtoMessage()
- func (m *Event) Reset()
- func (m *Event) String() string
- func (e *Event) UnmarshalJSON(data []byte) error
- func (m *Event) XXX_DiscardUnknown()
- func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Event) XXX_Merge(src proto.Message)
- func (m *Event) XXX_Size() int
- func (m *Event) XXX_Unmarshal(b []byte) error
- type Webhook
- func (*Webhook) Descriptor() ([]byte, []int)
- func (m *Webhook) GetCreationTime() *timestamp.Timestamp
- func (m *Webhook) GetEnabled() bool
- func (m *Webhook) GetEventTypes() []string
- func (m *Webhook) GetId() string
- func (m *Webhook) GetSecret() string
- func (m *Webhook) GetUpdatedTime() *timestamp.Timestamp
- func (m *Webhook) GetUri() string
- func (w Webhook) Key() string
- func (w Webhook) MarshalJSON() ([]byte, error)
- func (*Webhook) ProtoMessage()
- func (m *Webhook) Reset()
- func (w *Webhook) Run(t string, d []byte, n string) error
- func (m *Webhook) String() string
- func (w *Webhook) UnmarshalJSON(data []byte) error
- func (m *Webhook) XXX_DiscardUnknown()
- func (m *Webhook) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Webhook) XXX_Merge(src proto.Message)
- func (m *Webhook) XXX_Size() int
- func (m *Webhook) XXX_Unmarshal(b []byte) error
Constants ¶
const ( // EVENT_NEW_MESSAGE string = "chat:new_message" EventNewChat string = "chat:new" EventNewOperator string = "operator:new" // EVENT_NEW_OPERATOR_MESSAGE string = "operator:new_message" EventNewClient string = "client:new" EventNewClientMessage string = "client:message" )
Event Types
const ( DEBUG string = "DEBUG" INFO string = "INFO" WARNING string = "WARN" ERROR string = "ERROR" FATAL string = "FATAL" )
Log levels
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // JSON string of data Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` SourceId string `protobuf:"bytes,4,opt,name=source_id,proto3" json:"source_id,omitempty"` CreationTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=creation_time,proto3" json:"creation_time,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateEvent ¶
CreateEvent a new Event object based on a given Type (t) string
func (*Event) Descriptor ¶
func (*Event) GetCreationTime ¶
func (*Event) GetSourceId ¶
func (Event) Key ¶
Key implements the Keyer interface of the Store and returns a string used for storing the Webhook in memory.
func (Event) MarshalJSON ¶
MarshalJSON converts a Event object into a JSON string returned as a byte array.
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
func (*Event) UnmarshalJSON ¶
UnmarshalJSON converts a JSON string (as a byte array) into a Event object.
func (*Event) XXX_DiscardUnknown ¶
func (m *Event) XXX_DiscardUnknown()
func (*Event) XXX_Marshal ¶
func (*Event) XXX_Unmarshal ¶
type Webhook ¶
type Webhook struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` EventTypes []string `protobuf:"bytes,2,rep,name=event_types,proto3" json:"event_types,omitempty"` Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` Secret string `protobuf:"bytes,4,opt,name=secret,proto3" json:"secret,omitempty"` Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` CreationTime *timestamp.Timestamp `protobuf:"bytes,6,opt,name=creation_time,proto3" json:"creation_time,omitempty"` UpdatedTime *timestamp.Timestamp `protobuf:"bytes,7,opt,name=updated_time,json=update_time,proto3" json:"updated_time,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateWebhook ¶
CreateWebhook a new Webhook object based on the given event strings.
func GetByEventType ¶
GetByEventType returns one or more Webhooks that are for a specified event
func (*Webhook) Descriptor ¶
func (*Webhook) GetCreationTime ¶
func (*Webhook) GetEnabled ¶
func (*Webhook) GetEventTypes ¶
func (*Webhook) GetUpdatedTime ¶
func (Webhook) Key ¶
Key implements the Keyer interface of the Store and returns a string used for storing the Webhook in memory.
func (Webhook) MarshalJSON ¶
MarshalJSON converts a Webhook object into a JSON string returned as a byte array.
func (*Webhook) ProtoMessage ¶
func (*Webhook) ProtoMessage()
func (*Webhook) Run ¶
Run executes the Webhook sending an HTTP request with an Event to the defined URI. We generate a Mnml-Signature header that looks something along the lines of:
Mnml-Signature: t=1492774577,
v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Where t is the unix timestamp in seconds, and v1 is an HMAC signature using SHA-256. This can be used to validate that the signature is coming from the daemon service and not anywhere else.
To manually verify the signature, take t and concat it with the JSON payload received, separated by a '.' dot. Use the Webhook's secret to sign the concatenated timestamp.payload and it should equal v1.
func (*Webhook) UnmarshalJSON ¶
UnmarshalJSON converts a JSON string (as a byte array) into a Webhook object.
func (*Webhook) XXX_DiscardUnknown ¶
func (m *Webhook) XXX_DiscardUnknown()