chat

package
v0.0.0-...-96bc9f9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SelfID           string
	DeviceID         string
	KeyID            string
	MessagingClient  messagingClient
	MessagingService messagingService
	Rest             restTransport
	PrivateKey       ed25519.PrivateKey
	FileInteractor   remoteFile
	Environment      string
}

Config stores all configuration needed by the chat service.

type ConnectionConfig

type ConnectionConfig struct {
	Expiry time.Duration
}

type Group

type Group struct {
	Payload map[string]interface{}
	GID     string
	Members []string
	Name    string
	Link    string
	Key     string
	Mime    string
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(service *Service, payload map[string]interface{}) *Group

NewGroup creates a chat group object.

func (*Group) Invite

func (m *Group) Invite(user string)

Invite sends an invitation request to the specified user.

func (*Group) Join

func (m *Group) Join()

Join sends a notification the user has joined the group.

func (*Group) Leave

func (m *Group) Leave()

Leave notify all group users the current user is leaving the group.

func (*Group) Message

func (m *Group) Message(body string, opts ...MessageOptions) (*Message, error)

Message sends a text message to the group members.

type InviteOptions

type InviteOptions struct {
	Data []byte
	Mime string
}

type Message

type Message struct {
	Body       string
	Recipients []string
	JTI        string
	GID        string
	ISS        string
	Payload    map[string]interface{}
	Objects    []*Object
	// contains filtered or unexported fields
}

Message represents a chat message.

func NewMessage

func NewMessage(chat *Service, recipients []string, payload map[string]interface{}) *Message

NewMessage creates a chat message object.

func (*Message) Delete

func (m *Message) Delete()

Sends deletes the current message.

func (*Message) Edit

func (m *Message) Edit(Body string)

Edit edit the current message.

func (*Message) MarkAsDelivered

func (m *Message) MarkAsDelivered()

MarkAsDelivered marks the current message as delivered.

func (*Message) MarkAsRead

func (m *Message) MarkAsRead()

MarkAsRead marks the current message as read.

func (*Message) Message

func (m *Message) Message(body string, opts ...MessageOptions) (*Message, error)

Message sends a message to the current conversation.

func (*Message) Respond

func (m *Message) Respond(body string) (*Message, error)

Respond sends a response to the current message.

type MessageObject

type MessageObject struct {
	Link string
	Name string
	Data []byte
	Mime string
}

type MessageOptions

type MessageOptions struct {
	GID     string
	AUD     string
	JTI     string
	RID     string
	Objects []MessageObject
}

type Object

type Object struct {
	Link       string
	Name       string
	Mime       string
	Expires    int64
	Key        string
	Nonce      string
	Ciphertext string
	// contains filtered or unexported fields
}

func NewObject

func NewObject(fi remoteFile) *Object

NewObject creates an object.

func (*Object) BuildFromData

func (o *Object) BuildFromData(data []byte, name, mime string) error

BuildFromData builds an object from data.

func (*Object) BuildFromObject

func (o *Object) BuildFromObject(obj map[string]interface{}) error

BuildFromObject builds an object from a message object payload.

func (*Object) GetContent

func (o *Object) GetContent() ([]byte, error)

GetContent gets the current object content.

func (*Object) ToPayload

func (o *Object) ToPayload() map[string]interface{}

ToPayload translates the current object to payload.

type OnMessageOptions

type OnMessageOptions struct {
	MarkAsDelivered bool
	MarkAsRead      bool
}

type Service

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

Service handles all chat interactions.

func NewService

func NewService(config Config) *Service

NewService creates a new client for interacting with facts.

func (*Service) Delete

func (s *Service) Delete(recipients []string, cids []string, gid string)

Delete deletes previous messages.

func (*Service) Delivered

func (s *Service) Delivered(recipients []string, cids []string, gid string)

Delivered sends a message to confirm a list of messages (identified by it's cids) have been delivered.

func (*Service) Edit

func (s *Service) Edit(recipients []string, cid string, body string, gid string)

Edit changes the body of a previous message.

func (s *Service) GenerateConnectionDeepLink(config ConnectionConfig) (string, error)

func (*Service) GenerateConnectionQR

func (s *Service) GenerateConnectionQR(config ConnectionConfig) ([]byte, error)

func (*Service) Invite

func (s *Service) Invite(gid string, name string, members []string, opts ...InviteOptions) error

Invite sends a group invitation to a list of members.

func (*Service) Join

func (s *Service) Join(gid string, members []string)

Join joins a group.

func (*Service) Leave

func (s *Service) Leave(gid string, members []string)

Leave leaves a group.

func (*Service) Message

func (s *Service) Message(recipients []string, body string, opts ...MessageOptions) (*Message, error)

Message sends a message to a list of recipients.

func (*Service) OnConnection

func (s *Service) OnConnection(callback func(iss, status string))

OnConnection subscribes to people connecting to your app.

func (*Service) OnInvite

func (s *Service) OnInvite(callback func(m *Group))

OnInvite subscribes to group invitations.

func (*Service) OnJoin

func (s *Service) OnJoin(callback func(iss, gid string))

OnJoin subscribes to people joining a group

func (*Service) OnLeave

func (s *Service) OnLeave(callback func(iss, gid string))

OnLeave subscribes to people leaving the specified group.

func (*Service) OnMessage

func (s *Service) OnMessage(callback func(cm *Message), opts ...OnMessageOptions)

OnMessage subscribes to an incoming chat message.

func (*Service) Read

func (s *Service) Read(recipients []string, cids []string, gid string)

Read sends a message to confirm a list of messages (identified by it's cids) have been read.

func (*Service) SelfID

func (s *Service) SelfID() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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