Documentation
¶
Overview ¶
Package blocklist implements blocking and unblocking of contacts.
Index ¶
- Constants
- func Add(ctx context.Context, s *xmpp.Session, j ...jid.JID) error
- func AddIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, j ...jid.JID) error
- func Handle(h Handler) mux.Option
- func Match(j1, j2 jid.JID) bool
- func Remove(ctx context.Context, s *xmpp.Session, j ...jid.JID) error
- func RemoveIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, j ...jid.JID) error
- func Report(ctx context.Context, s *xmpp.Session, i ...Item) error
- func ReportIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, i ...Item) error
- type Handler
- type Item
- type Iter
- type ReportReason
Constants ¶
const ( NS = `urn:xmpp:blocking` NSReporting = `urn:xmpp:reporting:1` )
Various namespaces used by this package, provided as a convenience.
Variables ¶
This section is empty.
Functions ¶
func AddIQ ¶
AddIQ is like Add except that it lets you customize the IQ. Changing the type of the provided IQ has no effect.
func Handle ¶
Handle returns an option that registers the given handler on the mux for the various blocking command payloads.
func Match ¶
Match checks j1 aginst a JID in the blocklist (j2) and returns true if they are a match.
The JID matches the blocklist JID if any of the following compare to the blocklist JID (falling back in this order):
- Full JID (user@domain/resource)
- Bare JID (user@domain)
- Full domain (domain/resource)
- Bare domain
func Remove ¶
Remove removes JIDs from the blocklist. If no JIDs are provided the entire blocklist is cleared.
func RemoveIQ ¶
RemoveIQ is like Remove except that it lets you customize the IQ. Changing the type of the provided IQ has no effect.
Types ¶
type Handler ¶
type Handler struct { Block func(Item) Unblock func(jid.JID) UnblockAll func() List func(chan<- jid.JID) }
Handler can be used to respond to incoming blocking command requests.
func (Handler) HandleIQ ¶
func (h Handler) HandleIQ(iq stanza.IQ, r xmlstream.TokenReadEncoder, start *xml.StartElement) error
HandleIQ implements mux.IQHandler.
type Item ¶ added in v0.21.4
Item is a block payload. It consists of a JID you want to block and optional report fields.
func (*Item) MarshalXML ¶ added in v0.21.4
MarshalXML satisfies the xml.Marshaler interface.
func (*Item) TokenReader ¶ added in v0.21.4
func (i *Item) TokenReader() xml.TokenReader
TokenReader satisfies the xmlstream.Marshaler interface.
func (*Item) UnmarshalXML ¶ added in v0.21.4
UnmarshalXML satisfies the xml.Unmarshaler interface.
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter is an iterator over blocklist JIDs.
func FetchIQ ¶
FetchIQ is like Fetch except that it lets you customize the IQ. Changing the type of the provided IQ has no effect.
func (*Iter) Close ¶
Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.
type ReportReason ¶ added in v0.21.4
type ReportReason string
ReportReason is a reason of a report.
const ( // ReasonSpam is used for reporting a JID that is sending unwanted messages. ReasonSpam ReportReason = "urn:xmpp:reporting:spam" // ReasonAbuse is used for reporting general abuse. ReasonAbuse ReportReason = "urn:xmpp:reporting:abuse" )
The available report reasons are listed below.