forward

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package forward implements forwarding messages.

Index

Constants

View Source
const (
	NS = "urn:xmpp:forward:0"
)

Namespaces used by this package, provided as a convenience.

Variables

View Source
var (
	Feature = info.Feature{Var: NS}
)

A list of service discovery features that are supported by this package.

Functions

func Unwrap added in v0.21.0

func Unwrap(del *delay.Delay, r xml.TokenReader) (xml.TokenReader, error)

Unwrap returns the contents of the forwarded data as a new token stream. If a delay element is encountered it is unmarshaled into the provided delay and not returned as part of the token stream. If a nil delay is provided the delay will be skipped if present. In case there are multiple delay elements at the top level, only the first one is considered and the others will be included in the returned stream (i.e. only the first encountered delay is unmarshalled/skipped).

func Wrap

func Wrap(msg stanza.Message, body string, received time.Time, r xml.TokenReader) xml.TokenReader

Wrap forwards the provided token stream by wrapping it in a new message stanza and recording the original delivery time of the stanza. The body is in addition to the forwarded stanza and is not meant as a fallback in case the forwarded message cannot be displayed.

The token stream is expected to be a stanza, but this is not enforced.

Types

type Forwarded

type Forwarded struct {
	XMLName xml.Name    `xml:"urn:xmpp:forward:0 forwarded"`
	Delay   delay.Delay `xml:"urn:xmpp:delay delay"`
}

Forwarded can be embedded into another struct along with a stanza to wrap the stanza for forwarding.

func (Forwarded) TokenReader

func (f Forwarded) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (Forwarded) Wrap

Wrap wraps the provided token reader (which should be a stanza, but this is not enforced) to prepare it for forwarding.

func (Forwarded) WriteXML

func (f Forwarded) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

Jump to

Keyboard shortcuts

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