blocklist

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package blocklist implements blocking and unblocking of contacts.

Index

Constants

View Source
const NS = `urn:xmpp:blocklist`

NS is the namespace used by this package, provided as a convenience.

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, s *xmpp.Session, j ...jid.JID) error

Add adds JIDs to the blocklist.

func AddIQ

func AddIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, j ...jid.JID) error

AddIQ is like Add except that it lets you customize the IQ. Changing the type of the provided IQ has no effect.

func Handle

func Handle(h Handler) mux.Option

Handle returns an option that registers the given handler on the mux for the various blocking command payloads.

func Match

func Match(j1, j2 jid.JID) bool

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

func Remove(ctx context.Context, s *xmpp.Session, j ...jid.JID) error

Remove removes JIDs from the blocklist. If no JIDs are provided the entire blocklist is cleared.

func RemoveIQ

func RemoveIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, j ...jid.JID) error

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(jid.JID)
	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 Iter

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

Iter is an iterator over blocklist JIDs.

func Fetch

func Fetch(ctx context.Context, s *xmpp.Session) *Iter

Fetch sends a request to the JID asking for the blocklist.

func FetchIQ

func FetchIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session) *Iter

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

func (i *Iter) Close() error

Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.

func (*Iter) Err

func (i *Iter) Err() error

Err returns the last error encountered by the iterator (if any).

func (*Iter) JID

func (i *Iter) JID() jid.JID

JID returns the last blocked JID parsed by the iterator.

func (*Iter) Next

func (i *Iter) Next() bool

Next returns true if there are more items to decode.

Jump to

Keyboard shortcuts

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