hook

package
v0.64.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockListFetched hook runs when a user block list is fetched.
	BlockListFetched = "blocklist.items.fetched"

	// BlockListItemsBlocked hook runs when one or more JIDs are blocked.
	BlockListItemsBlocked = "blocklist.items.blocked"

	// BlockListItemsUnblocked hook runs when one or more JIDs are unblocked.
	BlockListItemsUnblocked = "blocklist.items.unblocked"
)
View Source
const (
	// C2SStreamConnected hook runs when a C2S connection is registered.
	C2SStreamConnected = "c2s.stream.connected"

	// C2SStreamBinded hook runs when C2S stream is bounded.
	C2SStreamBinded = "c2s.stream.binded"

	// C2SStreamDisconnected hook runs when a C2S connection is unregistered.
	C2SStreamDisconnected = "c2s.stream.disconnected"

	// C2SStreamTerminated hook runs when a C2S connection is terminated.
	C2SStreamTerminated = "c2s.stream.terminated"

	// C2SStreamElementReceived hook runs when a XMPP element is received over a C2S stream.
	C2SStreamElementReceived = "c2s.stream.element_received"

	// C2SStreamIQReceived hook runs when an iq stanza is received over a C2S stream.
	C2SStreamIQReceived = "c2s.stream.iq_received"

	// C2SStreamPresenceReceived hook runs when a presence stanza is received over a C2S stream.
	C2SStreamPresenceReceived = "c2s.stream.presence_received"

	// C2SStreamMessageReceived hook runs when a message stanza is received over a C2S stream.
	C2SStreamMessageReceived = "c2s.stream.message_received"

	// C2SStreamWillRouteElement hook runs when an XMPP element is about to be routed over a C2S stream.
	C2SStreamWillRouteElement = "c2s.stream.will_route_element"

	// C2SStreamIQRouted hook runs when an iq stanza is successfully routed to zero or more C2S streams.
	C2SStreamIQRouted = "c2s.stream.iq_routed"

	// C2SStreamPresenceRouted hook runs when a presence stanza is successfully routed to zero or more C2S streams.
	C2SStreamPresenceRouted = "c2s.stream.presence_routed"

	// C2SStreamMessageRouted hook runs when a message stanza is successfully routed to zero or more C2S streams.
	C2SStreamMessageRouted = "c2s.stream.message_routed"

	// C2SStreamElementSent hook runs when an XMPP element is sent over a C2S stream.
	C2SStreamElementSent = "c2s.stream.element_sent"
)
View Source
const (
	// ComponentsStarted hook runs after initializing all configured components.
	ComponentsStarted = "components.started"

	// ComponentsStopped hook runs after finishing all configured components.
	ComponentsStopped = "components.stopped"
)
View Source
const (
	// ExternalComponentRegistered hook runs when a external component connection is registered.
	ExternalComponentRegistered = "ext_component.stream.registered"

	// ExternalComponentUnregistered hook runs when a external component connection is unregistered.
	ExternalComponentUnregistered = "ext_component.stream.unregistered"

	// ExternalComponentElementReceived hook runs whenever an XMPP element is received over a external component stream.
	ExternalComponentElementReceived = "ext_component.stream.element_received"
)
View Source
const (
	// LowestPriority defines lowest hook execution priority.
	LowestPriority = Priority(math.MinInt32)

	// LowPriority defines low hook execution priority.
	LowPriority = Priority(math.MinInt32 + 1000)

	// DefaultPriority defines default hook execution priority.
	DefaultPriority = Priority(0)

	// HighPriority defines high hook execution priority.
	HighPriority = Priority(math.MaxInt32 - 1000)

	// HighestPriority defines highest hook execution priority.
	HighestPriority = Priority(math.MaxInt32)
)
View Source
const (
	// ArchiveMessageQueried hook runs whenever an archive is queried.
	ArchiveMessageQueried = "mam.message.queried"

	// ArchiveMessageArchived hook runs whenever a message is archived.
	ArchiveMessageArchived = "mam.message.archieved"
)
View Source
const (
	// ModulesStarted hook runs after initializing all configured modules.
	ModulesStarted = "modules.started"

	// ModulesStopped hook runs after finishing all configured modules.
	ModulesStopped = "modules.stopped"
)
View Source
const (
	// PrivateFetched hook runs when a user private XML is fetched.
	PrivateFetched = "private.fetched"

	// PrivateUpdated hook runs when a user private XML is updated.
	PrivateUpdated = "private.updated"
)
View Source
const (
	// RosterRequested hook runs whenever a user requests the roster.
	RosterRequested = "roster.requested"

	// RosterItemUpdated hook runs whenever a roster item subscription is updated.
	RosterItemUpdated = "roster.item.updated"
)
View Source
const (
	// S2SOutStreamConnected hook runs when an outgoing S2S connection is registered.
	S2SOutStreamConnected = "s2s.out.stream.connected"

	// S2SOutStreamDisconnected hook runs when an outgoing S2S connection is unregistered.
	S2SOutStreamDisconnected = "s2s.out.stream.disconnected"

	// S2SOutStreamElementSent hook runs whenever an XMPP element is sent over an outgoing S2S stream.
	S2SOutStreamElementSent = "s2s.out.stream.element_sent"

	// S2SInStreamRegistered hook runs when an incoming S2S connection is registered.
	S2SInStreamRegistered = "s2s.in.stream.registered"

	// S2SInStreamUnregistered hook runs when an incoming S2S connection is unregistered.
	S2SInStreamUnregistered = "s2s.in.stream.unregistered"

	// S2SInStreamElementReceived hook runs when an XMPP element is received over an incoming S2S stream.
	S2SInStreamElementReceived = "s2s.in.stream.stanza_received"

	// S2SInStreamIQReceived hook runs when an iq stanza is received over an incoming S2S stream.
	S2SInStreamIQReceived = "s2s.in.stream.iq_received"

	// S2SInStreamPresenceReceived hook runs when a presence stanza is received over an incoming S2S stream.
	S2SInStreamPresenceReceived = "s2s.in.stream.presence_received"

	// S2SInStreamMessageReceived hook runs when a message stanza is received over an incoming S2S stream.
	S2SInStreamMessageReceived = "s2s.in.stream.message_received"

	// S2SInStreamWillRouteElement hook runs when an XMPP element is about to be routed on an incoming S2S stream.
	S2SInStreamWillRouteElement = "s2s.in.stream.will_route_element"

	// S2SInStreamIQRouted hook runs when an iq stanza is successfully routed to zero or more C2S streams.
	S2SInStreamIQRouted = "s2s.in.stream.iq_routed"

	// S2SInStreamPresenceRouted hook runs when a presence stanza is successfully routed to zero or more C2S streams.
	S2SInStreamPresenceRouted = "s2s.in.stream.presence_routed"

	// S2SInStreamMessageRouted hook runs when a message stanza is successfully routed to zero or more C2S streams.
	S2SInStreamMessageRouted = "s2s.in.stream.message_routed"
)
View Source
const (
	// UserCreated hook runs whenever a new user is created.
	UserCreated = "user.created"

	// UserDeleted hook runs whenever a user is deleted.
	UserDeleted = "user.deleted"
)
View Source
const (
	// VCardFetched hook runs whenever a user vCard is fetched.
	VCardFetched = "vcard.fetched"

	// VCardUpdated hook runs whenever a user vCard is updated.
	VCardUpdated = "vcard.updated"
)
View Source
const (
	// DiscoProvidersStarted hook runs after all entity providers have been initialized.
	DiscoProvidersStarted = "disco.providers.started"
)
View Source
const (
	// LastActivityFetched hook runs when a user last activity is fetched.
	LastActivityFetched = "last.fetched"
)
View Source
const (
	// MemberListUpdated hook runs whenever cluster member list is updated.
	MemberListUpdated = "memberlist.updated"
)
View Source
const (
	// OfflineMessageArchived hook runs whenever an offline message is archived.
	OfflineMessageArchived = "offline.message.archieved"
)

Variables

View Source
var ErrStopped = errors.New("hook: execution stopped")

ErrStopped error is returned by a handler to halt hook execution.

Functions

This section is empty.

Types

type BlockListInfo

type BlockListInfo struct {
	// Username is the name of the user associated to this event.
	Username string

	// JIDs contains all JIDs associated to this event.
	JIDs []jid.JID
}

BlockListInfo contains all information associated to a blocklist event.

type C2SStreamInfo

type C2SStreamInfo struct {
	// ID is the event stream identifier.
	ID string

	// JID represents the event associated JID.
	JID *jid.JID

	// Presence is current C2S resource presence.
	Presence *stravaganza.Presence

	// Element is the event associated XMPP element.
	Element stravaganza.Element

	// Targets contains all JIDs to which event stanza was routed.
	Targets []jid.JID

	// DisconnectError contains the original error that caused stream disconnection.
	DisconnectError error
}

C2SStreamInfo contains all info associated to a C2S stream event.

type ComponentsInfo

type ComponentsInfo struct {
	Hosts []string
}

ComponentsInfo contains all information associated to a components event.

type ExecutionContext

type ExecutionContext struct {
	Info    interface{}
	Sender  interface{}
	Context context.Context
}

ExecutionContext defines a hook execution info context.

type ExternalComponentInfo

type ExternalComponentInfo struct {
	// ID is the event stream identifier.
	ID string

	// Host is the external component host domain.
	Host string

	// Element is the event associated XMPP element.
	Element stravaganza.Element
}

ExternalComponentInfo contains all info associated to an external component event.

type Handler

type Handler func(execCtx *ExecutionContext) error

Handler defines a generic hook handler function.

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

Hooks represents a set of module hook handlers.

func NewHooks

func NewHooks() *Hooks

NewHooks returns a new initialized Hooks instance.

func (*Hooks) AddHook

func (h *Hooks) AddHook(hook string, hnd Handler, priority Priority)

AddHook adds a new handler to a given hook providing an execution priority value. hnd priority may be any number (including negative). Handlers with a higher priority are executed first.

func (*Hooks) RemoveHook

func (h *Hooks) RemoveHook(hook string, hnd Handler)

RemoveHook removes a hook registered handler.

func (*Hooks) Run

func (h *Hooks) Run(hook string, execCtx *ExecutionContext) (halted bool, err error)

Run invokes all hook handlers in order. If halted return value is true no more handlers are invoked.

type LastActivityInfo

type LastActivityInfo struct {
	// Username is the name of the user associated to this event.
	Username string

	// JID represents the event associated JID.
	JID *jid.JID
}

LastActivityInfo contains all information associated to a last activity event.

type MamInfo added in v0.62.0

type MamInfo struct {
	// ArchiveID is the id of the mam archive associated to this event.
	ArchiveID string

	// Message is the message stanza associated to this event.
	Message *archivemodel.Message

	// Filters contains filters applied to the archive queried event.
	Filters *archivemodel.Filters
}

MamInfo contains all information associated to a mam (XEP-0313) event.

type MemberListInfo

type MemberListInfo struct {
	// Registered contains all new registered cluster members.
	Registered []clustermodel.Member

	// UnregisteredKeys contains unregistered cluster members keys.
	UnregisteredKeys []string
}

MemberListInfo contains all info associated to MemberListUpdated event.

type ModulesInfo

type ModulesInfo struct {
	ModuleNames []string
}

ModulesInfo contains all information associated to a modules event.

type OfflineInfo

type OfflineInfo struct {
	// Username is the name of the vCard user associated to this event.
	Username string

	// Message represents the event associated message.
	Message *stravaganza.Message
}

OfflineInfo contains all information associated to an offline event.

type Priority

type Priority int32

Priority defines hook execution priority.

type PrivateInfo

type PrivateInfo struct {
	// Username is the name of the user associated to this event.
	Username string

	// Private is the private XML element associated to this event.
	Private stravaganza.Element
}

PrivateInfo contains all information associated to a private event.

type RosterInfo

type RosterInfo struct {
	// Username is the name of the roster owner.
	Username string

	// JID is the event contact JID.
	JID string

	// Subscription is the roster event subscription value.
	Subscription string
}

RosterInfo contains all information associated to a roster event.

type S2SStreamInfo

type S2SStreamInfo struct {
	// ID is the event stream identifier.
	ID string

	// Sender is the S2S sender domain.
	Sender string

	// Target is the S2S target domain.
	Target string

	// Targets contains all JIDs to which event stanza was routed.
	Targets []jid.JID

	// Element is the event associated XMPP element.
	Element stravaganza.Element
}

S2SStreamInfo contains all info associated to a S2S event.

type UserInfo

type UserInfo struct {
	// Username is the name of the user associated to this event.
	Username string
}

UserInfo contains all information associated to a user event.

type VCardInfo

type VCardInfo struct {
	// Username is the name of the vCard user associated to this event.
	Username string

	// VCard is the vCard element associated to this event.
	VCard stravaganza.Element
}

VCardInfo contains all information associated to a vCard event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL