admin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PairingCode      = "code"
	PairingQR        = "qr"
	PairingConnected = "connected"
	PairingFailed    = "failed"
)

Variables

This section is empty.

Functions

func Handler

func Handler(deps Deps) http.Handler

Types

type AccessView

type AccessView struct {
	Name      string   `json:"name"`
	Kind      string   `json:"kind"`
	ReadOnly  bool     `json:"read_only"`
	Approval  string   `json:"approval"`
	Accounts  []string `json:"accounts"`
	CreatedAt string   `json:"created_at"`
}

type AccountStatus

type AccountStatus struct {
	AccountView
	Messages   int64 `json:"messages"`
	MediaBytes int64 `json:"media_bytes"`
}

type AccountView

type AccountView struct {
	Name        string `json:"name"`
	Phone       string `json:"phone"`
	ProfileName string `json:"profile_name"`
	Description string `json:"description"`
	State       string `json:"state"`

	RetentionMonths  int  `json:"retention_months"`
	RetentionDefault bool `json:"retention_default"`
}

type AddAccountRequest

type AddAccountRequest struct {
	Name        string `json:"name"`
	Phone       string `json:"phone"`
	Description string `json:"description"`
	QR          bool   `json:"qr"`
}

type AddWebhookRequest added in v0.2.0

type AddWebhookRequest struct {
	Name string `json:"name"`
	WebhookOptions
}

type Client

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

func Dial

func Dial(socketPath string) *Client

func (*Client) Access

func (c *Client) Access(ctx context.Context) ([]AccessView, error)

func (*Client) Account

func (c *Client) Account(ctx context.Context, name string) (AccountView, error)

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context) ([]AccountView, error)

func (*Client) AddAccount

func (c *Client) AddAccount(ctx context.Context, req AddAccountRequest, progress func(PairingEvent)) (AccountView, error)

func (*Client) AddWebhook added in v0.2.0

func (c *Client) AddWebhook(ctx context.Context, req AddWebhookRequest) (CreatedWebhook, error)

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, req CreateTokenRequest) (CreatedToken, error)

func (*Client) DescribeAccount

func (c *Client) DescribeAccount(ctx context.Context, name, description string) (AccountView, error)

func (*Client) EnableWebhook added in v0.2.0

func (c *Client) EnableWebhook(ctx context.Context, name string) (EnabledWebhook, error)

func (*Client) Password

func (c *Client) Password(ctx context.Context) (string, error)

func (*Client) RedeliverWebhook added in v0.2.0

func (c *Client) RedeliverWebhook(ctx context.Context, name string, req RedeliverRequest) (RedeliveredWebhook, error)

func (*Client) RemoveAccount

func (c *Client) RemoveAccount(ctx context.Context, name string) (RemovedAccount, error)

func (*Client) RemoveWebhook added in v0.2.0

func (c *Client) RemoveWebhook(ctx context.Context, name string) (RemovedWebhook, error)

func (*Client) RevokeAccess

func (c *Client) RevokeAccess(ctx context.Context, name string) (AccessView, error)

func (*Client) RotateWebhookSecret added in v0.2.0

func (c *Client) RotateWebhookSecret(ctx context.Context, name string) (RotatedWebhookSecret, error)

func (*Client) SetAccess

func (c *Client) SetAccess(ctx context.Context, name string, req SetAccessRequest) (AccessView, error)

func (*Client) SetRetention

func (c *Client) SetRetention(ctx context.Context, name string, months int) (AccountView, error)

func (*Client) SetWebhook added in v0.2.0

func (c *Client) SetWebhook(ctx context.Context, name string, req WebhookOptions) (WebhookView, error)

func (*Client) Status

func (c *Client) Status(ctx context.Context) (StatusView, error)

func (*Client) TestWebhook added in v0.2.0

func (c *Client) TestWebhook(ctx context.Context, name string) (WebhookTest, error)

func (*Client) Webhooks added in v0.2.0

func (c *Client) Webhooks(ctx context.Context) ([]WebhookView, error)

type CreateTokenRequest

type CreateTokenRequest struct {
	Name                string   `json:"name"`
	Accounts            []string `json:"accounts"`
	AllExistingAccounts bool     `json:"all_existing_accounts"`
	ReadOnly            bool     `json:"read_only"`
	Approval            string   `json:"approval,omitempty"`
}

type CreatedToken

type CreatedToken struct {
	Access AccessView `json:"access"`
	Token  string     `json:"token"`
}

type CreatedWebhook added in v0.2.0

type CreatedWebhook struct {
	Webhook WebhookView `json:"webhook"`
	Secret  string      `json:"secret"`
}

type DeliveryError added in v0.2.0

type DeliveryError struct {
	Status int    `json:"status,omitempty"`
	Error  string `json:"error,omitempty"`
}

type Deps

type Deps struct {
	Store                  *store.Store
	Accounts               *accounts.Manager
	Clock                  clock.Clock
	Grants                 GrantEvents
	Audit                  *audit.Logger
	OwnerPassword          string
	Media                  DiskUsage
	Retention              RetentionPasses
	Webhooks               *webhooks.Registry
	DefaultRetentionMonths int
}

type DescribeAccountRequest

type DescribeAccountRequest struct {
	Description string `json:"description"`
}

type DiskUsage

type DiskUsage interface {
	AccountBytes(accountID int64) (int64, error)
}

type EnabledWebhook added in v0.2.0

type EnabledWebhook struct {
	Name string `json:"name"`
}

type Error

type Error struct {
	Status  int
	Message string
}

func (*Error) Error

func (e *Error) Error() string

type GrantEvents

type GrantEvents interface {
	GrantChanged(ctx context.Context, grantID int64)
	GrantRevoked(grantID int64)
}

type PairingEvent

type PairingEvent struct {
	Event   string       `json:"event"`
	Code    string       `json:"code,omitempty"`
	QR      string       `json:"qr,omitempty"`
	Account *AccountView `json:"account,omitempty"`
	Error   string       `json:"error,omitempty"`
}

type RedeliverRequest added in v0.2.0

type RedeliverRequest struct {
	Since string `json:"since,omitempty"`
}

type RedeliveredWebhook added in v0.2.0

type RedeliveredWebhook struct {
	Name       string `json:"name"`
	Deliveries int    `json:"deliveries"`
}

type RemovedAccount

type RemovedAccount struct {
	Account AccountView `json:"account"`
	Warning string      `json:"warning,omitempty"`
}

type RemovedWebhook added in v0.2.0

type RemovedWebhook struct {
	Name string `json:"name"`
}

type RetentionPasses

type RetentionPasses interface {
	LastPass() retention.Pass
}

type RetentionView

type RetentionView struct {
	Running         bool   `json:"running"`
	StartedAt       string `json:"started_at,omitempty"`
	FinishedAt      string `json:"finished_at,omitempty"`
	DeletedMessages int    `json:"deleted_messages"`
	DeletedFiles    int    `json:"deleted_files"`
}

type RotatedWebhookSecret added in v0.2.0

type RotatedWebhookSecret struct {
	Name                string `json:"name"`
	Secret              string `json:"secret"`
	PreviousSecretUntil string `json:"previous_secret_until"`
}

type SetAccessRequest

type SetAccessRequest struct {
	Accounts            []string `json:"accounts"`
	AllExistingAccounts bool     `json:"all_existing_accounts"`
	Approval            string   `json:"approval,omitempty"`
}

type SetRetentionRequest

type SetRetentionRequest struct {
	Months int `json:"months"`
}

type StatusView

type StatusView struct {
	Accounts  []AccountStatus `json:"accounts"`
	Retention RetentionView   `json:"retention"`
}

type WebhookOptions added in v0.2.0

type WebhookOptions struct {
	URL                 string   `json:"url,omitempty"`
	Accounts            []string `json:"accounts"`
	AllExistingAccounts bool     `json:"all_existing_accounts,omitempty"`
	Chats               string   `json:"chats,omitempty"`
	Events              []string `json:"events"`
	Content             string   `json:"content,omitempty"`
	Format              string   `json:"format,omitempty"`
	Headers             []string `json:"headers"`
	Quiet               string   `json:"quiet,omitempty"`
	MaxWait             string   `json:"max_wait,omitempty"`
}

type WebhookTest added in v0.2.0

type WebhookTest struct {
	Name   string `json:"name"`
	Status int    `json:"status,omitempty"`
	Error  string `json:"error,omitempty"`
}

type WebhookView added in v0.2.0

type WebhookView struct {
	Name        string   `json:"name"`
	URL         string   `json:"url"`
	Accounts    []string `json:"accounts"`
	Events      []string `json:"events"`
	Chats       string   `json:"chats"`
	ListedChats []string `json:"listed_chats,omitempty"`
	Content     string   `json:"content"`
	Format      string   `json:"format"`
	HeaderNames []string `json:"header_names,omitempty"`
	State       string   `json:"state"`
	CreatedAt   string   `json:"created_at"`

	Pending     int            `json:"pending"`
	Failed      int            `json:"failed"`
	LastSuccess string         `json:"last_success,omitempty"`
	LastError   *DeliveryError `json:"last_error,omitempty"`
}

Jump to

Keyboard shortcuts

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