webui

package
v0.11.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package webui provides the Web-UI implementation of the communication interface.

Index

Constants

View Source
const CommunicationType = "webui"

CommunicationType defines a workspace type.

View Source
const (
	VerificationSignatureKey = "Verification-Signature"
)

Verification constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assistant

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

Assistant provides a service for interaction with a communication channel.

func NewAssistant

func NewAssistant(cfg *config.Credentials, appCfg *config.Config, handlerPrefix string, pack *features.Pack,
	platformClient *platform.Client, sessionStorage storage.SessionStorage) *Assistant

NewAssistant returns a new assistant service.

func (*Assistant) AddChannel

func (a *Assistant) AddChannel(channelID string, dbLabInstance *dblab.Instance)

AddChannel sets a message processor for a specific channel.

func (*Assistant) CheckIdleSessions

func (a *Assistant) CheckIdleSessions(ctx context.Context)

CheckIdleSessions check the running user sessions for idleness.

func (*Assistant) Deregister

func (a *Assistant) Deregister(ctx context.Context) error

Deregister deregisters the assistant from the Platform.

func (*Assistant) DumpSessions

func (a *Assistant) DumpSessions()

DumpSessions collects user's data from every message processor to sessionStorage.

func (*Assistant) Init

func (a *Assistant) Init() error

Init registers assistant handlers.

func (*Assistant) Register

func (a *Assistant) Register(ctx context.Context) error

Register registers the assistant on the Platform.

func (*Assistant) RestoreSessions

func (a *Assistant) RestoreSessions(ctx context.Context) error

RestoreSessions checks sessions after restart and establishes DB connection.

type Message

type Message struct {
	SessionID string `json:"session_id"`
	CommandID string `json:"command_id"`
	Text      string `json:"text"`
	ChannelID string `json:"channel_id"`
	UserID    string `json:"user_id"`
	Timestamp string `json:"timestamp"`
}

Message represents commands coming from Platform.

func (*Message) ToIncomingMessage

func (m *Message) ToIncomingMessage() models.IncomingMessage

ToIncomingMessage converts a WebUI message event to the standard incoming message.

type MessageValidator

type MessageValidator struct {
}

MessageValidator validates incoming messages.

func (MessageValidator) Validate

func (m MessageValidator) Validate(incomingMessage *models.IncomingMessage) error

Validate validates an incoming message.

type Messenger

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

Messenger provides a communication via Platform API.

func NewMessenger

func NewMessenger(api *platform.Client) *Messenger

NewMessenger creates a new Platform messenger service.

func (Messenger) AddArtifact

func (m Messenger) AddArtifact(title, content, _, messageID string) (artifactLink string, err error)

AddArtifact uploads artifacts to a channel.

func (Messenger) DownloadArtifact

func (m Messenger) DownloadArtifact(_ string) (response []byte, err error)

DownloadArtifact downloads snippets from a communication channel.

func (Messenger) Fail

func (m Messenger) Fail(message *models.Message, text string) error

Fail finishes the communication and marks message as failed.

func (Messenger) OK

func (m Messenger) OK(message *models.Message) error

OK finishes the communication and marks message as succeeding.

func (Messenger) Publish

func (m Messenger) Publish(message *models.Message) error

Publish posts messages.

func (Messenger) UpdateStatus

func (m Messenger) UpdateStatus(message *models.Message, status models.MessageStatus) error

UpdateStatus updates message status.

func (Messenger) UpdateText

func (m Messenger) UpdateText(message *models.Message) error

UpdateText updates a message text.

type UserInformer

type UserInformer struct {
}

UserInformer provides a service for getting user info.

func NewUserInformer

func NewUserInformer() UserInformer

NewUserInformer creates a new UserInformer service.

func (UserInformer) GetUserInfo

func (m UserInformer) GetUserInfo(userID string) (models.UserInfo, error)

GetUserInfo returns user info by ID.

type Verifier

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

Verifier provides a Platform requests verifier.

func NewVerifier

func NewVerifier(secret []byte) *Verifier

NewVerifier provides a new verifier.

func (*Verifier) Handler

func (a *Verifier) Handler(h http.HandlerFunc) http.HandlerFunc

Handler provides a middleware to verify incoming requests.

Jump to

Keyboard shortcuts

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