Help us shape the future of Go! Take the 2026 Go Developer Survey

dto

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package dto declares every response body the API can send, so nothing else can reach a caller.

Index

Constants

View Source
const (
	MediaFetching = "fetching"
	MediaReady    = "ready"
)

Variables

This section is empty.

Functions

func DeliveryHeaders added in v1.2.0

func DeliveryHeaders() []string

func Encode

func Encode(r Response) (contentType string, body []byte, err error)

func Size added in v0.3.0

func Size[T Chat | Message](item T) (int, error)

Types

type Accepted added in v0.2.0

type Accepted struct {
	Status string `json:"status"`
}

type AdminChat added in v0.3.0

type AdminChat struct {
	ID   string  `json:"id"`
	Kind string  `json:"kind"`
	Ref  string  `json:"ref"`
	Name *string `json:"name"`
}

type AdminChats added in v0.3.0

type AdminChats struct {
	Chats     []AdminChat `json:"chats"`
	Truncated bool        `json:"truncated"`
}

type Attachment added in v1.2.0

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

func NewAttachment added in v1.2.0

func NewAttachment(kind, variant, servedType string, size int64, tag [16]byte, body io.ReaderAt, expires time.Time,
	finished func(sent int64, complete bool)) (Attachment, error)

func (Attachment) Expires added in v1.2.0

func (a Attachment) Expires() time.Time

func (Attachment) Finished added in v1.2.0

func (a Attachment) Finished(sent int64, complete bool)

func (Attachment) Plan added in v1.2.0

func (a Attachment) Plan(rangeHeader, ifRange string) (Delivery, error)

type AttachmentInfo added in v1.2.0

type AttachmentInfo struct {
	Kind              string  `json:"kind"`
	Variant           string  `json:"variant"`
	State             string  `json:"state"`
	ServedType        string  `json:"served_type"`
	Format            string  `json:"format"`
	Normalised        bool    `json:"normalised"`
	Bytes             int64   `json:"bytes"`
	SizeDeclared      int64   `json:"size_declared"`
	Delivery          string  `json:"delivery"`
	Reason            *string `json:"reason"`
	Parts             int     `json:"parts"`
	Offset            int64   `json:"offset"`
	Length            int64   `json:"length"`
	RestRoute         string  `json:"rest_route"`
	ExpiresAt         *string `json:"expires_at"`
	RetryAfterSeconds *int    `json:"retry_after_seconds,omitempty"`
	Untrusted         bool    `json:"untrusted"`
	Notice            string  `json:"notice"`
}

type BackfillRequested added in v1.0.0

type BackfillRequested struct {
	RequestID string `json:"request_id"`
}

func (BackfillRequested) Status added in v1.0.0

func (BackfillRequested) Status() int

type ChangePage added in v0.3.0

type ChangePage struct {
	Messages  []Message `json:"messages"`
	Next      *string   `json:"next"`
	More      bool      `json:"more"`
	Truncated bool      `json:"truncated"`
	Session   Session   `json:"session"`
}

type Chat added in v0.3.0

type Chat struct {
	ID            string  `json:"id"`
	Kind          string  `json:"kind"`
	Name          *string `json:"name"`
	NameSource    *string `json:"name_source"`
	LastMessageAt *string `json:"last_message_at"`
}

type ChatPage added in v0.3.0

type ChatPage struct {
	Chats     []Chat  `json:"chats"`
	Next      *string `json:"next"`
	Truncated bool    `json:"truncated"`
	Session   Session `json:"session"`
}

type ChatResult added in v0.3.0

type ChatResult struct {
	Chat    *Chat   `json:"chat"`
	Session Session `json:"session"`
}

type Client added in v0.3.0

type Client struct {
	ID                string       `json:"id"`
	Name              string       `json:"name"`
	State             string       `json:"state"`
	CreatedAt         string       `json:"created_at"`
	ExpiresAt         string       `json:"expires_at"`
	RevokedAt         *string      `json:"revoked_at"`
	AllChats          bool         `json:"all_chats"`
	AllowFirstContact bool         `json:"allow_first_contact"`
	AllowMedia        bool         `json:"allow_media"`
	ReadChats         []ClientChat `json:"read_chats"`
	WriteChats        []ClientChat `json:"write_chats"`
}

type ClientChat added in v0.3.0

type ClientChat struct {
	ID    string  `json:"id"`
	Kind  string  `json:"kind"`
	Known bool    `json:"known"`
	Name  *string `json:"name"`
}

type ClientCreated added in v0.3.0

type ClientCreated struct {
	Client     Client `json:"client"`
	Credential string `json:"credential"`
}

type ClientList added in v0.3.0

type ClientList struct {
	Clients []ClientSummary `json:"clients"`
}

type ClientSummary added in v0.3.0

type ClientSummary struct {
	ID                string  `json:"id"`
	Name              string  `json:"name"`
	State             string  `json:"state"`
	CreatedAt         string  `json:"created_at"`
	ExpiresAt         string  `json:"expires_at"`
	RevokedAt         *string `json:"revoked_at"`
	AllChats          bool    `json:"all_chats"`
	AllowFirstContact bool    `json:"allow_first_contact"`
	AllowMedia        bool    `json:"allow_media"`
	ReadChatCount     int64   `json:"read_chat_count"`
	WriteChatCount    int64   `json:"write_chat_count"`
}

type Delivery added in v1.2.0

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

func (Delivery) Body added in v1.2.0

func (d Delivery) Body() *io.SectionReader

func (Delivery) Code added in v1.2.0

func (d Delivery) Code() int

func (Delivery) Header added in v1.2.0

func (d Delivery) Header() iter.Seq2[string, string]

func (Delivery) Length added in v1.2.0

func (d Delivery) Length() int64

func (Delivery) Offset added in v1.2.0

func (d Delivery) Offset() int64

func (Delivery) Whole added in v1.2.0

func (d Delivery) Whole() bool

type Error

type Error struct {
	Code string `json:"error"`
}

type Health

type Health struct {
	Status string `json:"status"`
}

type Me added in v0.3.0

type Me struct {
	Client  MeClient `json:"client"`
	Session Session  `json:"session"`
}

type MeClient added in v0.3.0

type MeClient struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	ExpiresAt string     `json:"expires_at"`
	Read      ReadScope  `json:"read"`
	Write     WriteScope `json:"write"`
}

type MediaPause added in v1.2.0

type MediaPause struct {
	Paused bool `json:"paused"`
}

type MediaStatus added in v1.2.0

type MediaStatus struct {
	AttachmentInfo
}

func (MediaStatus) RetryAfter added in v1.2.0

func (m MediaStatus) RetryAfter() time.Duration

func (MediaStatus) Status added in v1.2.0

func (m MediaStatus) Status() int

type Message added in v0.3.0

type Message struct {
	Ref           string  `json:"mref"`
	Chat          string  `json:"chat"`
	Sender        Sender  `json:"sender"`
	FromMe        bool    `json:"from_me"`
	TS            string  `json:"ts"`
	Kind          string  `json:"kind"`
	Text          *string `json:"text"`
	TextDisplay   *string `json:"text_display"`
	TextTruncated bool    `json:"text_truncated"`
	MediaType     *string `json:"media_type"`
	ReplyTo       *string `json:"reply_to"`
	QuoteVerified bool    `json:"quote_verified"`
	EditedAt      *string `json:"edited_at"`
	Revoked       bool    `json:"revoked"`
	Origin        string  `json:"origin"`
	Untrusted     bool    `json:"untrusted"`
}

type MessagePage added in v0.3.0

type MessagePage struct {
	Messages  []Message `json:"messages"`
	Next      *string   `json:"next"`
	Truncated bool      `json:"truncated"`
	Session   Session   `json:"session"`
}

type Pairing added in v0.2.0

type Pairing struct {
	Code string `json:"code"`
}

type Prometheus

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

func Metrics

func Metrics(reg *metrics.Registry) Prometheus

type ReadScope added in v0.3.0

type ReadScope struct {
	All   bool        `json:"all"`
	Chats []ScopeChat `json:"chats"`
}

type Response

type Response interface {
	// contains filtered or unexported methods
}

type ScopeChat added in v0.3.0

type ScopeChat struct {
	ID   string `json:"id"`
	Kind string `json:"kind"`
}

type SearchPage added in v0.3.0

type SearchPage struct {
	Messages  []Message `json:"messages"`
	Next      *string   `json:"next"`
	More      bool      `json:"more"`
	Truncated bool      `json:"truncated"`
	Session   Session   `json:"session"`
}

type SendResult added in v1.0.0

type SendResult struct {
	Message           *Message `json:"message"`
	Replayed          bool     `json:"replayed"`
	Session           Session  `json:"session"`
	RetryAfterSeconds *int     `json:"retry_after_seconds,omitempty"`
}

func (SendResult) Status added in v1.0.0

func (SendResult) Status() int

type Sender added in v0.3.0

type Sender struct {
	ID   string  `json:"id"`
	Name *string `json:"name"`
}

type Session added in v0.3.0

type Session struct {
	State string `json:"state"`
}

type Status added in v0.2.0

type Status struct {
	State        string        `json:"state"`
	Reason       string        `json:"reason"`
	Paired       bool          `json:"paired"`
	Counts       StatusCounts  `json:"counts"`
	Clients      StatusClients `json:"clients"`
	Warnings     []string      `json:"warnings"`
	Downloads    string        `json:"downloads"`
	LastIngestAt *string       `json:"last_ingest_at"`
	Version      string        `json:"version"`
}

type StatusClients added in v0.3.0

type StatusClients struct {
	Active         int64 `json:"active"`
	Expired        int64 `json:"expired"`
	Revoked        int64 `json:"revoked"`
	AllChatsActive int64 `json:"all_chats_active"`
}

type StatusCounts added in v0.2.0

type StatusCounts struct {
	Chats            int64 `json:"chats"`
	Messages         int64 `json:"messages"`
	BlobsPending     int64 `json:"history_blobs_pending"`
	BlobsQuarantined int64 `json:"history_blobs_quarantined"`
	InboxBacklog     int64 `json:"inbox_backlog"`
	InboxQuarantined int64 `json:"inbox_quarantined"`
	BackfillsToday   int64 `json:"backfills_today"`
	MediaRefsLive    int64 `json:"media_refs_live"`
	MediaRefsExpired int64 `json:"media_refs_expired"`
	RevokeTombstones int64 `json:"revoke_tombstones"`
}

type WriteScope added in v0.3.0

type WriteScope struct {
	Chats []ScopeChat `json:"chats"`
}

Jump to

Keyboard shortcuts

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