conversation

package
v2.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activities

type Activities struct {
	Items []interface{} `json:"items,omitempty"`
}

Activities represents the activities in a conversation

type Activity

type Activity struct {
	ID           string                 `json:"id,omitempty"`
	ObjectType   string                 `json:"objectType,omitempty"`
	URL          string                 `json:"url,omitempty"`
	Published    string                 `json:"published,omitempty"`
	Verb         string                 `json:"verb,omitempty"`
	Actor        *Actor                 `json:"actor,omitempty"`
	Object       map[string]interface{} `json:"object,omitempty"`
	Target       *Target                `json:"target,omitempty"`
	ClientTempID string                 `json:"clientTempId,omitempty"`

	// Additional fields that might be in the data
	EncryptionKeyURL string `json:"encryptionKeyUrl,omitempty"`

	// Parsed content after decryption (if applicable)
	Content         string      `json:"-"`
	DecryptedObject *Object     `json:"-"`
	MessageType     MessageType `json:"-"`

	// Raw data for debugging
	RawData map[string]interface{} `json:"-"`
}

Activity represents a conversation activity

type ActivityHandler

type ActivityHandler func(activity *Activity)

ActivityHandler is a function that handles conversation activities

type Actor

type Actor struct {
	ID           string `json:"id,omitempty"`
	ObjectType   string `json:"objectType,omitempty"`
	DisplayName  string `json:"displayName,omitempty"`
	OrgID        string `json:"orgId,omitempty"`
	EmailAddress string `json:"emailAddress,omitempty"`
	EntryUUID    string `json:"entryUUID,omitempty"`
	Type         string `json:"type,omitempty"`
}

Actor represents the person who performed the activity

type Client

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

Client is the Conversation API client

func New

func New(webexClient *webexsdk.Client, config *Config) *Client

New creates a new Conversation plugin

func (*Client) Connect

func (c *Client) Connect() error

Connect starts the Mercury WebSocket connection. This is a convenience method that delegates to the underlying Mercury client. Handlers should be registered with On() before calling Connect().

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect stops the Mercury WebSocket connection. This is a convenience method that delegates to the underlying Mercury client.

func (*Client) EncryptionClient

func (c *Client) EncryptionClient() *encryption.Client

EncryptionClient returns the encryption client for direct access.

func (*Client) GetMessageContent

func (c *Client) GetMessageContent(activity *Activity) (string, error)

GetMessageContent attempts to extract the message content from an activity. If the message is encrypted, it will be decrypted using the KMS encryption key.

func (*Client) InitializeFromMercuryEvent

func (c *Client) InitializeFromMercuryEvent(event *mercury.Event) (*Activity, error)

InitializeFromMercuryEvent initializes an activity from a Mercury event

func (*Client) Off

func (c *Client) Off(verb string, handler ActivityHandler)

Off removes a handler for a specific activity verb

func (*Client) On

func (c *Client) On(verb string, handler ActivityHandler)

On registers a handler for a specific activity verb

func (*Client) ProcessActivityEvent

func (c *Client) ProcessActivityEvent(event *mercury.Event) (*Activity, error)

ProcessActivityEvent processes a conversation activity event from Mercury. This method parses the activity but does NOT decrypt message content inline. Decryption happens in the dispatched goroutine (see dispatchActivity) so the Mercury event handler returns immediately and doesn't block on KMS.

func (*Client) SetEncryptionDeviceInfo

func (c *Client) SetEncryptionDeviceInfo(deviceURL, userID string)

SetEncryptionDeviceInfo passes device information to the encryption client so it can authenticate with the KMS service. Call this after device registration.

func (*Client) SetMercuryClient

func (c *Client) SetMercuryClient(mercuryClient *mercury.Client)

SetMercuryClient sets the Mercury client to use for WebSocket events

type Config

type Config struct {
}

Config holds the configuration for the Conversation plugin

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for the Conversation plugin

type MessageType

type MessageType string

MessageType represents the type of message

const (
	// MessageTypePost represents a post message
	MessageTypePost MessageType = "post"
	// MessageTypeShare represents a share message
	MessageTypeShare MessageType = "share"
	// MessageTypeAcknowledge represents an acknowledge message
	MessageTypeAcknowledge MessageType = "acknowledge"

	// WildcardHandler is used for handling all activity types
	WildcardHandler = "*"
)

type Object

type Object struct {
	ObjectType  string `json:"objectType,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	Content     string `json:"content,omitempty"`
	ContentType string `json:"contentType,omitempty"`

	// For reference to another activity (used in acknowledge)
	ID        string `json:"id,omitempty"`
	URL       string `json:"url,omitempty"`
	Published string `json:"published,omitempty"`
}

Object represents the content of a message

type Participants

type Participants struct {
	Items []interface{} `json:"items,omitempty"`
}

Participants represents the participants in a conversation

type Target

type Target struct {
	ID           string        `json:"id,omitempty"`
	ObjectType   string        `json:"objectType,omitempty"`
	URL          string        `json:"url,omitempty"`
	Published    string        `json:"published,omitempty"`
	Participants *Participants `json:"participants,omitempty"`
	Activities   *Activities   `json:"activities,omitempty"`
	Tags         []string      `json:"tags,omitempty"`
	GlobalID     string        `json:"globalId,omitempty"`
}

Target represents the conversation where the activity occurred

Jump to

Keyboard shortcuts

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