channels

package
v1.801.477 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package channels is one inbox for the chat apps you connect — Discord, Slack, Teams, Telegram.

The /v1/channels routes carry a portable chat envelope, per-org access policy (pairing / allowlist / open), a durable inbox, and outbound send across every connected transport. Identity and token custody stay in apps/integrations — channels consumes its ingress seam (integrations.RegisterIngress) and its send doors, so the dependency points one way: channels → integrations, never back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(app cloud.Router, deps cloud.Deps) error

Mount wires /v1/channels/* onto app and registers the ingress consumer.

func Shutdown

func Shutdown(_ context.Context) error

Shutdown unpublishes the service, then closes the store. Idempotent. The context is unused; the signature matches integrations.Shutdown so apps.go wires it directly. Unpublish-first stops new ingest events from adopting a store that is about to close.

Types

type Action

type Action struct {
	Kind     ActionKind     `json:"kind"`
	Label    string         `json:"label,omitempty"`
	Command  string         `json:"command,omitempty"`
	URL      string         `json:"url,omitempty"`
	Options  []SelectOption `json:"options,omitempty"`
	Approval *Approval      `json:"approval,omitempty"`
}

Action is the kind-tagged closed union (command | url | select | approval); exactly the fields of its Kind are set — validate enforces per-kind exclusivity so a channel never has to guess from string shape.

type ActionKind

type ActionKind string

ActionKind tags the closed Action union.

const (
	ActionCommand  ActionKind = "command"
	ActionURL      ActionKind = "url"
	ActionSelect   ActionKind = "select"
	ActionApproval ActionKind = "approval"
)

type Approval

type Approval struct {
	ID string `json:"id"`
}

Approval names the approval request an approval action refers to.

type Attachment

type Attachment struct {
	Kind AttachmentKind `json:"kind"`
	URL  string         `json:"url"`
	MIME string         `json:"mime,omitempty"`
}

Attachment is a URL-addressed media item.

type AttachmentKind

type AttachmentKind string

AttachmentKind is the closed attachment media class.

const (
	AttachmentImage AttachmentKind = "image"
	AttachmentAudio AttachmentKind = "audio"
	AttachmentVideo AttachmentKind = "video"
	AttachmentFile  AttachmentKind = "file"
)

type DMPolicy

type DMPolicy string

DMPolicy governs direct messages on a channel.

const (
	DMPairing   DMPolicy = "pairing"
	DMAllowlist DMPolicy = "allowlist"
	DMOpen      DMPolicy = "open"
)

type Delivery

type Delivery struct {
	MessageID string `json:"messageId"`
	Timestamp int64  `json:"timestamp"`
}

Delivery is a transport's send receipt. Timestamp is Unix seconds.

type GroupPolicy

type GroupPolicy string

GroupPolicy governs group (and thread) surfaces on a channel.

const (
	GroupOpen      GroupPolicy = "open"
	GroupAllowlist GroupPolicy = "allowlist"
	GroupDisabled  GroupPolicy = "disabled"
)

type Message

type Message struct {
	Channel     string       `json:"channel"`
	Account     string       `json:"account,omitempty"`
	Sender      Sender       `json:"sender"`
	Room        Room         `json:"room"`
	Text        string       `json:"text,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	Actions     []Action     `json:"actions,omitempty"`
	ReplyTo     string       `json:"replyTo,omitempty"`
	Idempotency string       `json:"idempotency,omitempty"`
}

Message is the normalized envelope. Account is informational — the lowercased external id of the org's connected platform account; the policy key is (org, channel) only.

type Room

type Room struct {
	ID   string   `json:"id"`
	Kind RoomKind `json:"kind,omitempty"`
}

Room is the conversation a message lives in.

type RoomKind

type RoomKind string

RoomKind classifies where a message lives.

const (
	RoomDM     RoomKind = "dm"
	RoomGroup  RoomKind = "group"
	RoomThread RoomKind = "thread"
)

type SelectOption

type SelectOption struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

SelectOption is one choice of a select action.

type SendRequest

type SendRequest struct {
	Room        Room         `json:"room"`
	Text        string       `json:"text,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	Actions     []Action     `json:"actions,omitempty"`
	ReplyTo     string       `json:"replyTo,omitempty"`
	Idempotency string       `json:"idempotency,omitempty"`
}

SendRequest is the narrow body of POST /v1/channels/:channel/send — the envelope's outbound projection. Identity fields (Sender, Account, Channel) are not decodable here: the route path names the channel and the caller's authenticated org supplies the tenant.

type Sender

type Sender struct {
	ExternalID string `json:"externalId"`
	Display    string `json:"display,omitempty"`
	UserID     string `json:"userId,omitempty"`
	Org        string `json:"org,omitempty"`
}

Sender identifies who sent an inbound message. UserID is the bound Hanzo subject (integrations.LinkedSubject) and may be empty when the platform user has not linked. Org is filled on ingress and ignored on egress.

Jump to

Keyboard shortcuts

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