Documentation
¶
Overview ¶
Package protocol holds the wire types of the bubbles REST API. It is the single source of truth shared by the server handlers and the Go SDK and depends on the standard library only. The REST contract is docs/openapi.yaml.
Index ¶
- Constants
- Variables
- func AvatarURL(fileID string) string
- func FileThumbURL(id, name string) string
- func FileURL(id, name string) string
- func FormatTime(unixMilli int64) string
- type AcceptInviteRequest
- type AddMemberRequest
- type AdminChannelList
- type AdminCreateUserRequest
- type AdminInvite
- type AdminInviteList
- type AdminOverview
- type AdminSettings
- type AdminTLS
- type AdminTailscale
- type AdminUserList
- type Alert
- type AlertField
- type AlertInput
- type AlertPage
- type AlertUpdatedEvent
- type App
- type AppList
- type AppSelf
- type AppToken
- type ApprovePairingRequest
- type AuditEntry
- type AuditPage
- type AuthResponse
- type Author
- type BackupRequest
- type Bootstrap
- type ChangePasswordRequest
- type Channel
- type ChannelEvent
- type ChannelList
- type ClientFrame
- type Command
- type CommandInput
- type CommandInvoked
- type CommandInvoker
- type CommandList
- type CommandResponse
- type ContentCleared
- type CreateAppRequest
- type CreateAppTokenRequest
- type CreateChannelRequest
- type CreateInviteRequest
- type CreateMessageRequest
- type CreateWebhookRequest
- type CreatedInvite
- type CreatedWebhook
- type Device
- type DeviceList
- type DeviceLoginRequest
- type DeviceLoginResponse
- type DeviceRegisterRequest
- type EditMessageRequest
- type EphemeralMessage
- type Error
- type ErrorBody
- type Event
- type FactoryReset
- type File
- type HandoffCodeResponse
- type Hello
- type InviteInfo
- type InvokeCommandRequest
- type InvokedCommand
- type IssuedAppToken
- type LoginRequest
- type MarkReadRequest
- type Me
- type Member
- type MemberJoinedEvent
- type MemberLeftEvent
- type MemberList
- type Membership
- type Mentions
- type Message
- type MessageDeleted
- type MessagePage
- type NewMessage
- type PairingApproval
- type PairingChannel
- type PairingCreated
- type PairingReplaces
- type PairingRequest
- type PairingRequestInput
- type PairingStatus
- type PasswordResetLink
- type Patch
- type PendingPairing
- type PendingPairingList
- type Pin
- type PinEvent
- type PinList
- type Pong
- type PostedAlert
- type PresenceEvent
- type PushKeys
- type PushPayload
- type PushSubscribeRequest
- type PushUnsubscribeRequest
- type PushVapidKey
- type Reaction
- type ReactionEvent
- type ReactionList
- type ReadEvent
- type RegisterRequest
- type RegistrationActionRequest
- type ResetPasswordRequest
- type ResetPreview
- type ResetRequest
- type ResolveAlertByKeyRequest
- type ResolveAlertRequest
- type RespondCommandRequest
- type RespondedCommand
- type SearchPage
- type SearchResult
- type ServerStatus
- type Session
- type SessionList
- type SessionRevokedEvent
- type SettingsPublic
- type SettingsUpdatedEvent
- type StartDMRequest
- type Thread
- type TypingEvent
- type Unread
- type UpdateAdminChannelRequest
- type UpdateAdminUserRequest
- type UpdateAppRequest
- type UpdateChannelRequest
- type UpdateMeRequest
- type UpdateMembershipRequest
- type User
- type UserList
- type Webhook
- type WebhookList
Constants ¶
const ( RegistrationReopen = "reopen" RegistrationClose = "close" )
Registration actions of POST /admin/registration.
const ( MaxAlertTitle = 200 MaxAlertText = 4000 MaxAlertFields = 20 MaxAlertFieldName = 64 MaxAlertFieldValue = 512 MaxAlertDedupeKey = 200 MaxAlertLink = 2048 )
Limits of an AlertInput.
const ( ScopeMessagesRead = "messages:read" ScopeMessagesWrite = "messages:write" ScopeAlertsWrite = "alerts:write" ScopeFilesWrite = "files:write" ScopeChannelsRead = "channels:read" ScopeEventsRead = "events:read" ScopeCommands = "commands" ScopeDMWrite = "dm:write" ScopeMCP = "mcp" )
App token scopes. A token carries a subset of these; every endpoint an app calls checks the scope it needs.
const ( ChannelPublic = "public" ChannelPrivate = "private" ChannelDM = "dm" ChannelGroupDM = "group_dm" )
Channel kinds.
const ( MemberOwner = "owner" MemberMember = "member" )
Membership roles.
const ( NotifyAll = "all" NotifyMentions = "mentions" NotifyNone = "none" )
Notification levels of a membership.
const ( SeverityInfo = "info" SeverityWarning = "warning" SeverityCritical = "critical" )
Alert severities.
const ( MaxCommandsPerApp = 50 MaxCommandNameChars = 32 MaxCommandTextChars = 200 // description and usage MaxCommandArgsChars = 4000 // args of an invocation MaxCommandRespondChars = 4000 // text of a response )
Limits of the command registry and of an invocation.
const ( CommandTopic = "topic" CommandInvite = "invite" CommandLeave = "leave" CommandMute = "mute" CommandMe = "me" CommandHelp = "help" )
Built-in command names. An app cannot register one of these.
const ( CodeBadRequest = "bad_request" CodeForbidden = "forbidden" CodeNotFound = "not_found" CodeConflict = "conflict" CodeTooLarge = "too_large" CodeUnsupportedMedia = "unsupported_media" CodeRateLimited = "rate_limited" CodeInsufficientStorage = "insufficient_storage" CodeInternal = "internal" )
Error codes of the REST error model (see docs/openapi.yaml).
const ( AlertTransitionCreated = "created" AlertTransitionEscalated = "escalated" AlertTransitionRenotifyDue = "renotify_due" AlertTransitionUpdatedOther = "updated_other" AlertTransitionAcked = "acked" AlertTransitionResolved = "resolved" )
Alert transitions: what an alert event did to its alert. They are the values of AlertUpdatedEvent.Transition; a new alert message (message.created, kind alert) is implicitly TransitionCreated. Only created, escalated and renotify_due can notify (pkg/notifyrules); the others are informational.
const ( FileImage = "image" FileVideo = "video" FileAudio = "audio" FileOther = "file" )
File categories.
const ( MessageText = "text" MessageAlert = "alert" MessageSystem = "system" )
Message kinds.
const ( AlertOpen = "open" AlertAcked = "acked" AlertResolved = "resolved" )
Alert states.
const ( PairingPending = "pending" PairingApproved = "approved" PairingDenied = "denied" PairingExpired = "expired" PairingClaimed = "claimed" // PairingCancelled is a request the app withdrew (DELETE // /pairing/requests/{id}) before it claimed a token. PairingCancelled = "cancelled" )
Pairing request states.
const ( // ResetContent deletes every message, file, alert and event and bumps // the instance epoch; accounts, channels, apps and settings stay. ResetContent = "content" // ResetFactory wipes everything and returns the server to a first // start (new admin account and password) under a new instance id. ResetFactory = "factory" )
Reset modes of POST /admin/reset.
const ( RoleAdmin = "admin" RoleMember = "member" RoleGuest = "guest" )
User roles.
const ( KindHuman = "human" KindApp = "app" )
User kinds.
const ( // QueryResume is the last seq the client applied (bootstrap seq_head or // the last event frame); the server replays retained events after it. QueryResume = "resume" // QueryInstance is the instance_id the client's state belongs to. QueryInstance = "instance" // QueryEpoch is the epoch the client's state belongs to. QueryEpoch = "epoch" )
WebSocket query parameters.
const ( FrameHello = "hello" FramePong = "pong" )
Server frame types that are not events.
const ( // ResumeOK: the client's state is current; replayed events (if any) // follow, then live events. ResumeOK = "ok" // ResumeResyncRequired: the resume point is gone (retention, epoch // change); drop cached messages and drafts and re-fetch /bootstrap. ResumeResyncRequired = "resync_required" // ResumeInstanceChanged: the server was factory-reset or replaced; wipe // all local state. ResumeInstanceChanged = "instance_changed" )
Hello.Resume outcomes.
const ( ClientTyping = "typing" ClientPresence = "presence" ClientFocus = "focus" ClientPing = "ping" )
Client frame types.
const ( PresenceActive = "active" PresenceIdle = "idle" )
Client presence reports (ClientFrame.State).
const ( PresenceOnline = "online" PresenceOffline = "offline" )
Aggregated presence states (PresenceEvent.State). Idle doubles as the client report value.
const ( CloseSlowConsumer = 4008 CloseSessionRevoked = 4009 CloseServerReset = 4010 CloseContentCleared = 4011 )
WebSocket close codes (besides the standard 1000-1011).
const AppTokenPrefix = "bub_"
AppTokenPrefix starts every app token.
const AvatarFileName = "avatar"
AvatarFileName is the name segment of an avatar URL; the server looks files up by id only, so the name is cosmetic.
const DetailsFields = "fields"
DetailsFields is the key of Error.Details that maps a request field name to the reason it was rejected (validation errors).
const MaxClientFrameBytes = 4096
MaxClientFrameBytes bounds one client frame.
const MaxPrefsBytes = 4096
MaxPrefsBytes is the largest prefs object PATCH /me accepts.
const PairingHeader = "X-Poll-Secret"
PairingHeader carries the poll secret on GET and DELETE /pairing/requests/{id}.
const ScopeNotify = "notify"
ScopeNotify lets a tray device show notifications for the user.
const TimeLayout = "2006-01-02T15:04:05.000Z"
TimeLayout is the wire format of every timestamp: RFC 3339, UTC, with milliseconds.
const WSPath = "/api/v1/ws"
WSPath is the WebSocket endpoint. Query parameters: QueryResume, QueryInstance, QueryEpoch.
const WebhookTokenPrefix = "bwh_"
WebhookTokenPrefix starts the secret path token of every incoming webhook.
Variables ¶
var AppScopes = []string{ ScopeMessagesRead, ScopeMessagesWrite, ScopeAlertsWrite, ScopeFilesWrite, ScopeChannelsRead, ScopeEventsRead, ScopeCommands, ScopeDMWrite, ScopeMCP, }
AppScopes lists every scope a token can carry.
var DeviceScopes = []string{ScopeEventsRead, ScopeMessagesRead, ScopeNotify}
DeviceScopes are the only scopes a device token carries.
Functions ¶
func FileThumbURL ¶
FileThumbURL is the URL path of a file's thumbnail.
func FormatTime ¶
FormatTime renders unix milliseconds in TimeLayout.
Types ¶
type AcceptInviteRequest ¶
type AcceptInviteRequest struct {
// Name is the person's display name; the @handle is derived from it.
Name string `json:"name,omitempty"`
Username string `json:"username"`
Password string `json:"password"`
DisplayName string `json:"display_name"`
}
AcceptInviteRequest is the body of POST /invites/{code}/accept.
type AddMemberRequest ¶
type AddMemberRequest struct {
Role string `json:"role,omitempty"`
}
AddMemberRequest is the optional body of PUT /channels/{id}/members/{user_id}.
type AdminChannelList ¶
type AdminChannelList struct {
Items []Channel `json:"items"`
}
AdminChannelList is the body of GET /admin/channels: public and private channels with names and member counts, never their content.
type AdminCreateUserRequest ¶ added in v0.2.0
type AdminCreateUserRequest struct {
Name string `json:"name"`
Password string `json:"password"`
// Role is admin, member or guest; empty means member.
Role string `json:"role,omitempty"`
}
AdminCreateUserRequest is the body of POST /admin/users ("Add person").
type AdminInvite ¶
type AdminInvite struct {
ID string `json:"id"`
Role string `json:"role"`
Note string `json:"note"`
CreatedBy *string `json:"created_by"`
CreatedAt string `json:"created_at"`
ExpiresAt string `json:"expires_at"`
MaxUses int `json:"max_uses"`
UseCount int `json:"use_count"`
RevokedAt *string `json:"revoked_at"`
}
AdminInvite is one invite; the code is never part of it.
type AdminInviteList ¶
type AdminInviteList struct {
Items []AdminInvite `json:"items"`
}
AdminInviteList is the body of GET /admin/invites.
type AdminOverview ¶
type AdminOverview struct {
InstanceName string `json:"instance_name"`
Version string `json:"version"`
StartedAt string `json:"started_at"`
UptimeSeconds int64 `json:"uptime_seconds"`
Users int `json:"users"`
Connections int `json:"connections"`
StorageBytes int64 `json:"storage_used_bytes"`
DiskFreeBytes *int64 `json:"disk_free_bytes"`
TLSMode string `json:"tls_mode"`
CAFingerprint string `json:"ca_fingerprint"`
CertNotAfter string `json:"cert_not_after"`
HTTPSURLs []string `json:"https_urls"`
OnboardingURLs []string `json:"onboarding_urls"`
// ClientIsolationHint is true while no device other than the server
// itself has signed in; Wi-Fi client isolation is a likely cause.
ClientIsolationHint bool `json:"client_isolation_hint"`
}
AdminOverview is the body of GET /admin/overview.
type AdminSettings ¶
type AdminSettings struct {
InstanceName string `json:"instance_name"`
OpenRegistration bool `json:"open_registration"`
RegistrationWindowH int `json:"registration_window_hours"`
// OpenRegistrationUntil is the sign-up deadline; null for none. Set it
// with POST /admin/registration, not PATCH.
OpenRegistrationUntil *string `json:"open_registration_until"`
// RegistrationOpen is computed: switched on and inside the window.
RegistrationOpen bool `json:"registration_open"`
UploadMaxBytes int64 `json:"upload_max_bytes"`
UserQuotaBytes int64 `json:"user_quota_bytes"`
DiskReserveBytes int64 `json:"disk_reserve_bytes"`
DefaultRetentionDays *int `json:"default_retention_days"`
WebPushEnabled bool `json:"web_push_enabled"`
PushPayload string `json:"push_payload"`
AllowedCIDRs []string `json:"allowed_cidrs"`
SessionIdleDays int `json:"session_idle_days"`
AlertRenotifyS int `json:"alert_renotify_s"`
MDNSEnabled bool `json:"mdns_enabled"`
WebResetEnabled bool `json:"web_reset_enabled"`
}
AdminSettings is the body of GET /admin/settings and the answer of PATCH: every setting with defaults applied.
type AdminTLS ¶
type AdminTLS struct {
Mode string `json:"mode"`
CAFingerprint string `json:"ca_fingerprint"`
LeafFingerprint string `json:"leaf_fingerprint"`
LeafNotAfter string `json:"leaf_not_after"`
SANs []string `json:"sans"`
// Tailscale is this machine on its tailnet; omitted when the server
// is not on a tailnet and --tailscale-cert is off.
Tailscale *AdminTailscale `json:"tailscale,omitempty"`
}
AdminTLS is the body of GET /admin/tls.
type AdminTailscale ¶ added in v0.4.0
type AdminTailscale struct {
// Running is true when Tailscale is up on the server machine.
Running bool `json:"running"`
// DNSName is the MagicDNS name ("" when MagicDNS is off) and URL the
// HTTPS address on it.
DNSName string `json:"dns_name"`
URL string `json:"url"`
// IPs are the Tailscale addresses (100.x.y.z, fd7a:...).
IPs []string `json:"ips"`
// CertEnabled is --tailscale-cert; CertActive says the Tailscale
// certificate is served for DNSName, until CertNotAfter. CertError says
// why not when enabled but inactive.
CertEnabled bool `json:"cert_enabled"`
CertActive bool `json:"cert_active"`
CertNotAfter string `json:"cert_not_after,omitempty"`
CertError string `json:"cert_error,omitempty"`
// CACoversName is true when the local CA may sign DNSName, so the name
// also works for devices that installed the CA.
CACoversName bool `json:"ca_covers_name"`
}
AdminTailscale is the Tailscale part of AdminTLS.
type AdminUserList ¶
type AdminUserList struct {
Items []User `json:"items"`
}
AdminUserList is the body of GET /admin/users (human accounts).
type Alert ¶
type Alert struct {
Severity string `json:"severity"`
State string `json:"state"`
Title string `json:"title"`
Fields []AlertField `json:"fields"`
Link *string `json:"link"`
DedupeKey string `json:"dedupe_key"`
Occurrences int `json:"occurrences"`
FirstSeenAt string `json:"first_seen_at"`
LastSeenAt string `json:"last_seen_at"`
AckedBy *string `json:"acked_by"`
AckedAt *string `json:"acked_at"`
ResolvedBy *string `json:"resolved_by"`
ResolvedAt *string `json:"resolved_at"`
}
Alert is the alert state of a kind=alert message.
type AlertField ¶
type AlertField struct {
Name string `json:"name"`
Value string `json:"value"`
Short bool `json:"short"`
}
AlertField is one name/value pair of an alert.
type AlertInput ¶
type AlertInput struct {
Channel string `json:"channel"`
Severity string `json:"severity"`
Title string `json:"title"`
Text string `json:"text,omitempty"`
Fields []AlertField `json:"fields,omitempty"`
Link *string `json:"link,omitempty"`
DedupeKey string `json:"dedupe_key"`
RenotifyAfterS *int `json:"renotify_after_s,omitempty"`
OccurredAt *string `json:"occurred_at,omitempty"`
}
AlertInput is the body of POST /alerts. Channel is a channel name (with or without a leading #) or id. DedupeKey identifies the condition: a repeat with the same key updates the open alert instead of creating a new one. RenotifyAfterS defaults to the instance setting alert_renotify_s; 0 turns renotification off. OccurredAt (RFC 3339) is when the condition was seen; the server never records a time in the future.
type AlertPage ¶
AlertPage is the body of GET /alerts: alert messages, newest first. NextCursor is null on the last page.
type AlertUpdatedEvent ¶
type AlertUpdatedEvent struct {
Message Message `json:"message"`
Transition string `json:"transition"`
}
AlertUpdatedEvent is the payload of alert.updated: the alert's message as it stands after the update and the transition that caused the event. The notification dispatcher and the clients decide notifications from Transition and Message.Alert.Severity.
type App ¶
type App struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Username string `json:"username"`
Name string `json:"name"`
Description string `json:"description"`
OwnerUserID *string `json:"owner_user_id"`
CreatedAt string `json:"created_at"`
DisabledAt *string `json:"disabled_at"`
Tokens []AppToken `json:"tokens"`
}
App is an integration: a bot account plus its tokens. Tokens lists every token of the app, revoked ones included, in the admin API and is empty in GET /apps/self.
type AppList ¶
type AppList struct {
Items []App `json:"items"`
}
AppList is the body of GET /admin/apps.
type AppToken ¶
type AppToken struct {
ID string `json:"id"`
AppID string `json:"app_id"`
Prefix string `json:"prefix"`
Scopes []string `json:"scopes"`
ChannelIDs []string `json:"channel_ids"`
CreatedAt string `json:"created_at"`
ExpiresAt *string `json:"expires_at"`
LastUsedAt *string `json:"last_used_at"`
RevokedAt *string `json:"revoked_at"`
}
AppToken is the public view of an app token. The secret itself is shown once, when the token is issued; afterwards only Prefix identifies it. ChannelIDs null means the channels the app's bot is a member of; a list restricts the token to those channels.
type ApprovePairingRequest ¶
type ApprovePairingRequest struct {
Scopes []string `json:"scopes,omitempty"`
ChannelIDs []string `json:"channel_ids,omitempty"`
CreateChannel bool `json:"create_channel,omitempty"`
ReplaceApp bool `json:"replace_app,omitempty"`
}
ApprovePairingRequest is the body of POST /admin/pairing-requests/{id}/approve: the scopes to grant, the channels to add the bot to, and whether to add it to a public "<username>-alerts" channel (created unless a public one with that name exists). Empty Scopes grants the scopes the app requested. ReplaceApp reconnects the existing app the request names (PendingPairing.Replaces) instead of creating a new one: it keeps its id, bot and channels, and its other tokens are revoked when the app claims the new one (a disabled app's tokens already at the approval, which enables it again).
type AuditEntry ¶
type AuditEntry struct {
ID string `json:"id"`
At string `json:"at"`
ActorID *string `json:"actor_id"`
ActorKind string `json:"actor_kind"`
ActorIP string `json:"actor_ip"`
Action string `json:"action"`
TargetType string `json:"target_type"`
TargetID string `json:"target_id"`
Detail json.RawMessage `json:"detail"`
}
AuditEntry is one audit log row.
type AuditPage ¶
type AuditPage struct {
Items []AuditEntry `json:"items"`
NextCursor *string `json:"next_cursor"`
}
AuditPage is the body of GET /admin/audit; NextCursor is null at the end.
type AuthResponse ¶
type AuthResponse struct {
User Me `json:"user"`
}
AuthResponse answers every request that starts a session (login, invite accept, register). The session itself travels in the cookie.
type Author ¶
type Author struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
Kind string `json:"kind"`
AvatarURL *string `json:"avatar_url"`
}
Author is the sender of a message. Accounts are deactivated, never deleted, so the author is always present.
type BackupRequest ¶
type BackupRequest struct {
Passphrase string `json:"passphrase"`
}
BackupRequest is the body of POST /admin/backup. The archive is encrypted with Passphrase (age, scrypt).
type Bootstrap ¶
type Bootstrap struct {
InstanceID string `json:"instance_id"`
Epoch int64 `json:"epoch"`
Me Me `json:"me"`
Users []User `json:"users"`
Channels []Channel `json:"channels"`
Memberships []Membership `json:"memberships"`
Unread []Unread `json:"unread"`
SettingsPublic SettingsPublic `json:"settings_public"`
SeqHead int64 `json:"seq_head"`
}
Bootstrap is the body of GET /bootstrap. Everything in it is a consistent snapshot taken at SeqHead: a client replays events with seq > SeqHead.
type ChangePasswordRequest ¶
ChangePasswordRequest is the body of POST /me/password.
type Channel ¶
type Channel struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name *string `json:"name"`
Topic string `json:"topic"`
Description string `json:"description"`
IsDefault bool `json:"is_default"`
RetentionDays *int `json:"retention_days"`
CreatedBy *string `json:"created_by"`
CreatedAt string `json:"created_at"`
ArchivedAt *string `json:"archived_at"`
MemberCount int `json:"member_count"`
ParticipantIDs []string `json:"participant_ids,omitempty"`
}
Channel is the wire view of a channel row. Name is null for direct messages; ParticipantIDs is set for dm and group_dm only (a note-to-self has exactly one participant).
type ChannelEvent ¶
type ChannelEvent struct {
Channel Channel `json:"channel"`
Memberships []Membership `json:"memberships,omitempty"`
}
ChannelEvent is the payload of channel.created, channel.updated, channel.archived and channel.unarchived. Memberships lists the initial members on channel.created only.
type ChannelList ¶
type ChannelList struct {
Items []Channel `json:"items"`
}
ChannelList is the body of GET /channels.
type ClientFrame ¶
type ClientFrame struct {
Type string `json:"type"`
ChannelID *string `json:"channel_id,omitempty"`
State string `json:"state,omitempty"`
Visible *bool `json:"visible,omitempty"`
TS string `json:"ts,omitempty"`
}
ClientFrame is a client-to-server signal. Fields by type:
typing channel_id (required) presence state: "active" | "idle" focus visible (required), channel_id (string or null), ts (optional RFC 3339) ping (none)
type Command ¶
type Command struct {
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
AppName string `json:"app_name"`
Builtin bool `json:"builtin"`
}
Command is one entry of GET /commands. AppName is empty for a built-in.
type CommandInput ¶
type CommandInput struct {
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
}
CommandInput is one command of the body of PUT /apps/self/commands.
type CommandInvoked ¶
type CommandInvoked struct {
InvocationID string `json:"invocation_id"`
Command string `json:"command"`
Args string `json:"args"`
ChannelID string `json:"channel_id"`
ThreadRootID *string `json:"thread_root_id"`
User CommandInvoker `json:"user"`
}
CommandInvoked is the data of a command.invoked event. It is sent only to the connections of the app that owns the command, with seq 0, and is not stored.
type CommandInvoker ¶
type CommandInvoker struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
}
CommandInvoker names the person who ran a command.
type CommandList ¶
type CommandList struct {
Items []Command `json:"items"`
}
CommandList is the body of GET /commands and of the response to PUT /apps/self/commands.
type CommandResponse ¶
type CommandResponse = RespondCommandRequest
CommandResponse is the body of POST /api/v1/commands/invocations/{id}/respond.
type ContentCleared ¶
type ContentCleared struct {
Epoch int64 `json:"epoch"`
}
ContentCleared answers POST /admin/reset with mode "content": the new instance epoch. Sessions stay valid; clients resync to empty channels.
type CreateAppRequest ¶
type CreateAppRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Username string `json:"username,omitempty"`
}
CreateAppRequest is the body of POST /admin/apps. Username is optional; without it the bot's username is derived from the name.
type CreateAppTokenRequest ¶
type CreateAppTokenRequest struct {
Scopes []string `json:"scopes"`
ChannelIDs []string `json:"channel_ids,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
}
CreateAppTokenRequest is the body of POST /admin/apps/{id}/tokens. ChannelIDs absent or null leaves the token unrestricted by an allowlist.
type CreateChannelRequest ¶
type CreateChannelRequest struct {
Name string `json:"name"`
Kind string `json:"kind"`
Topic string `json:"topic,omitempty"`
MemberIDs []string `json:"member_ids,omitempty"`
}
CreateChannelRequest is the body of POST /channels.
type CreateInviteRequest ¶
type CreateInviteRequest struct {
Role string `json:"role,omitempty"`
Note string `json:"note,omitempty"`
ExpiresInSeconds int `json:"expires_in_seconds,omitempty"`
MaxUses int `json:"max_uses,omitempty"`
}
CreateInviteRequest is the body of POST /admin/invites. Zero fields take the defaults (member, 72 hours, one use).
type CreateMessageRequest ¶
type CreateMessageRequest struct {
Body string `json:"body"`
ThreadRootID *string `json:"thread_root_id,omitempty"`
FileIDs []string `json:"file_ids,omitempty"`
Nonce string `json:"nonce,omitempty"`
}
CreateMessageRequest is the body of POST /channels/{id}/messages. A repeated nonce returns the message it created first.
type CreateWebhookRequest ¶
CreateWebhookRequest is the body of POST /admin/webhooks. Name becomes the name of the webhook's pseudo-app and of its bot account.
type CreatedInvite ¶
type CreatedInvite struct {
AdminInvite
URL string `json:"url"`
}
CreatedInvite answers POST /admin/invites. URL holds the secret code and is in this answer only.
type CreatedWebhook ¶
CreatedWebhook is the answer of POST /admin/webhooks: the webhook and the URL to post to. The URL carries the secret and is not shown again.
type Device ¶
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Scopes []string `json:"scopes"`
Current bool `json:"current"`
CreatedAt string `json:"created_at"`
LastUsedAt *string `json:"last_used_at"`
}
Device is the public view of a device token.
type DeviceList ¶
type DeviceList struct {
Items []Device `json:"items"`
}
DeviceList is the body of GET /me/devices.
type DeviceLoginRequest ¶
type DeviceLoginRequest struct {
Username string `json:"username"`
Password string `json:"password"`
DeviceName string `json:"device_name"`
}
DeviceLoginRequest is the body of POST /auth/device-login.
type DeviceLoginResponse ¶
type DeviceLoginResponse struct {
DeviceToken string `json:"device_token"`
DeviceID string `json:"device_id"`
HandoffCode string `json:"handoff_code"`
}
DeviceLoginResponse carries the new device token (shown once) and the one-time handoff code that opens the web app without a second sign-in.
type DeviceRegisterRequest ¶ added in v0.2.0
type DeviceRegisterRequest struct {
Name string `json:"name"`
Password string `json:"password"`
DeviceName string `json:"device_name"`
}
DeviceRegisterRequest is the body of POST /auth/device-register: sign up and register the tray device in one step.
type EditMessageRequest ¶
type EditMessageRequest struct {
Body string `json:"body"`
}
EditMessageRequest is the body of PATCH /messages/{id}.
type EphemeralMessage ¶
type EphemeralMessage struct {
InvocationID string `json:"invocation_id"`
ChannelID string `json:"channel_id"`
ThreadRootID *string `json:"thread_root_id"`
Author *Author `json:"author"`
Body string `json:"body"`
}
EphemeralMessage is the data of an ephemeral.message event: a notice or an app's private answer shown only to the person it is for, in the channel (and thread) the command ran in. It has seq 0 and is not stored. Author is the app's bot for an app's answer and null for a notice from the server itself. InvocationID is empty when no app invocation is behind the notice.
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
Error is the inner object of the error envelope.
func (*Error) FieldErrors ¶
FieldErrors returns details.fields of a validation error, or nil.
type ErrorBody ¶
type ErrorBody struct {
Error Error `json:"error"`
}
ErrorBody is the JSON error envelope: {"error":{"code","message","details"}}.
type Event ¶
type Event struct {
Seq int64 `json:"seq"`
Type string `json:"type"`
ChannelID string `json:"channel_id,omitempty"`
TS string `json:"ts"`
Data json.RawMessage `json:"data"`
}
Event is the envelope of one realtime event (WebSocket frame and replay). Persisted events carry their global Seq; ephemeral frames use seq 0.
Data holds one of the payload types below, selected by Type:
message.created, message.updated Message message.deleted MessageDeleted reaction.added, reaction.removed ReactionEvent pin.added, pin.removed PinEvent channel.created, .updated, channel.archived, .unarchived ChannelEvent channel.member_joined MemberJoinedEvent channel.member_left MemberLeftEvent membership.updated Membership (user-scoped) read.updated ReadEvent (user-scoped) alert.updated AlertUpdatedEvent
Channel-scoped events carry ChannelID and are delivered to the channel's members (public channel lifecycle events to every non-guest); user-scoped events carry no ChannelID and go to the one user named in the payload.
type FactoryReset ¶
type FactoryReset struct {
AdminUsername string `json:"admin_username"`
AdminPassword string `json:"admin_password"`
SignInURL string `json:"sign_in_url"`
CARotated bool `json:"ca_rotated"`
CAFingerprint string `json:"ca_fingerprint"`
}
FactoryReset answers POST /admin/reset with mode "factory": the new new admin account, its generated password, where to sign in and the CA devices must trust (CARotated says whether it changed).
type File ¶
type File struct {
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
Mime string `json:"mime"`
Category string `json:"category"`
Width *int `json:"width"`
Height *int `json:"height"`
HasThumb bool `json:"has_thumb"`
MetaStripped bool `json:"meta_stripped"`
URL string `json:"url"`
ThumbURL *string `json:"thumb_url"`
}
File is an uploaded file. It is the answer of POST /files and the element of Message.Files. Name is the sanitized original file name. MetaStripped is false for files whose metadata could not be removed (HEIC, video, audio, documents and images that were not processed).
type HandoffCodeResponse ¶
type HandoffCodeResponse struct {
HandoffCode string `json:"handoff_code"`
}
HandoffCodeResponse is the body of POST /auth/handoff-code.
type Hello ¶
type Hello struct {
Type string `json:"type"` // FrameHello
InstanceID string `json:"instance_id"`
Epoch int64 `json:"epoch"`
SeqHead int64 `json:"seq_head"`
UserID string `json:"user_id"`
ServerVersion string `json:"server_version"`
Resume string `json:"resume"`
}
Hello is the first frame on every connection.
type InviteInfo ¶
type InviteInfo struct {
Valid bool `json:"valid"`
Role string `json:"role,omitempty"`
InstanceName string `json:"instance_name"`
}
InviteInfo is the body of GET /invites/{code}. Role is empty and Valid false when the code is unknown, expired, revoked or used up.
type InvokeCommandRequest ¶
type InvokeCommandRequest struct {
ChannelID string `json:"channel_id"`
Command string `json:"command"`
Args string `json:"args"`
ThreadRootID *string `json:"thread_root_id,omitempty"`
}
InvokeCommandRequest is the body of POST /commands/invoke.
type InvokedCommand ¶
type InvokedCommand struct {
InvocationID string `json:"invocation_id,omitempty"`
Builtin bool `json:"builtin"`
}
InvokedCommand is the response to POST /commands/invoke. InvocationID is set for an app command (202: the app was told); it is empty for a built-in, which the server has already run (200).
type IssuedAppToken ¶
type IssuedAppToken struct {
Token string `json:"token"`
ConnectionString string `json:"connection_string"`
Info AppToken `json:"info"`
}
IssuedAppToken is the answer of POST /admin/apps/{id}/tokens: the only time the token secret is shown. ConnectionString is the same token in the bubbles:// form the SDK and the netdiag setup accept.
type LoginRequest ¶
LoginRequest is the body of POST /auth/login.
type MarkReadRequest ¶
type MarkReadRequest struct {
MessageID string `json:"message_id"`
}
MarkReadRequest is the body of POST /channels/{id}/read.
type Me ¶
type Me struct {
User
Prefs json.RawMessage `json:"prefs"`
MustChange bool `json:"must_change_pw"`
}
Me is the signed-in user's own view: the public fields plus private ones.
type Member ¶
type Member struct {
UserID string `json:"user_id"`
Role string `json:"role"`
JoinedAt string `json:"joined_at"`
}
Member is the public view of a channel member (GET /channels/{id}/members).
type MemberJoinedEvent ¶
type MemberJoinedEvent struct {
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
ActorID string `json:"actor_id"`
Channel Channel `json:"channel"`
Membership Membership `json:"membership"`
}
MemberJoinedEvent is the payload of channel.member_joined. Channel and Membership let the new member's client add the channel without a refetch.
type MemberLeftEvent ¶
type MemberLeftEvent struct {
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
ActorID string `json:"actor_id"`
}
MemberLeftEvent is the payload of channel.member_left. ActorID differs from UserID when the member was removed. The departing user must still receive the event although they are no longer a member.
type MemberList ¶
type MemberList struct {
Items []Member `json:"items"`
}
MemberList is the body of GET /channels/{id}/members.
type Membership ¶
type Membership struct {
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
Role string `json:"role"`
JoinedAt string `json:"joined_at"`
LastReadID *string `json:"last_read_id"`
NotifyLevel string `json:"notify_level"`
AlertMinSeverity string `json:"alert_min_severity"`
MutedUntil *string `json:"muted_until"`
}
Membership is one user's own relation to a channel, including private preferences. LastReadID and MutedUntil are null when unset.
type Mentions ¶
type Mentions struct {
UserIDs []string `json:"user_ids"`
Channel bool `json:"channel"`
Here bool `json:"here"`
}
Mentions lists who a message mentions.
type Message ¶
type Message struct {
ID string `json:"id"`
ChannelID string `json:"channel_id"`
ThreadRootID *string `json:"thread_root_id"`
Kind string `json:"kind"`
Author Author `json:"author"`
OverrideName *string `json:"override_name"`
Body string `json:"body"`
Files []File `json:"files"`
Reactions []Reaction `json:"reactions"`
Mentions Mentions `json:"mentions"`
ReplyCount int `json:"reply_count"`
LastReplyAt *string `json:"last_reply_at"`
EditedAt *string `json:"edited_at"`
Deleted bool `json:"deleted"`
CreatedAt string `json:"created_at"`
Alert *Alert `json:"alert"`
}
Message is the wire view of a chat message. A deleted message keeps its row as a tombstone: Deleted is true, Body is empty and Files, Reactions and Mentions are empty.
type MessageDeleted ¶
type MessageDeleted struct {
ID string `json:"id"`
ChannelID string `json:"channel_id"`
ThreadRootID *string `json:"thread_root_id"`
DeletedAt string `json:"deleted_at"`
}
MessageDeleted is the payload of message.deleted. The message row stays as a tombstone; ThreadRootID is set when the deleted message was a reply.
type MessagePage ¶
type MessagePage struct {
Items []Message `json:"items"`
HasMoreBefore bool `json:"has_more_before"`
HasMoreAfter bool `json:"has_more_after"`
}
MessagePage is a page of messages in chronological order (oldest first).
type NewMessage ¶
type NewMessage = CreateMessageRequest
NewMessage is the body of POST /api/v1/channels/{id}/messages.
type PairingApproval ¶
PairingApproval is the answer of an approval: the app (new, or the replaced one) and the ids of the channels its bot was added to (the alerts channel first).
type PairingChannel ¶ added in v0.3.0
PairingChannel is a channel the bot of a paired app is a member of.
type PairingCreated ¶
type PairingCreated struct {
ID string `json:"id"`
PollSecret string `json:"poll_secret"`
Code string `json:"code"`
ExpiresAt string `json:"expires_at"`
}
PairingCreated is the answer of POST /pairing/requests. The app shows Code to the admin and polls with PollSecret, which is shown only here.
type PairingReplaces ¶ added in v0.3.0
type PairingReplaces struct {
AppID string `json:"app_id"`
Name string `json:"name"`
Username string `json:"username"`
DisabledAt *string `json:"disabled_at"`
Channels []PairingChannel `json:"channels"`
}
PairingReplaces is the existing app a pairing request names: its id, name, bot username, when it was disabled (nil while enabled) and the public and private channels, not archived, that its bot is in, sorted by name then id (never nil). Approving with ReplaceApp hands that bot and those channels to the new token.
type PairingRequest ¶
type PairingRequest = PairingRequestInput
PairingRequest is the body of POST /api/v1/pairing/requests.
type PairingRequestInput ¶
type PairingRequestInput struct {
AppName string `json:"app_name"`
Description string `json:"description,omitempty"`
RequestedScopes []string `json:"requested_scopes,omitempty"`
ReplacesAppID string `json:"replaces_app_id,omitempty"`
}
PairingRequestInput is the body of POST /pairing/requests. ReplacesAppID is optional: the id of the app this client was paired as before (the app id GET /apps/self reports). The admin then sees which app the request would replace and can reconnect it instead of creating a new one. An id that names no app is accepted and ignored.
type PairingStatus ¶
type PairingStatus struct {
State string `json:"state"`
Token string `json:"token,omitempty"`
ExpiresAt string `json:"expires_at"`
Channels []PairingChannel `json:"channels,omitempty"`
}
PairingStatus is the answer of GET /pairing/requests/{id}. Token is set exactly once, on the first poll after the admin approved the request; the state is then claimed. Channels is set in that same answer only: the public and private channels, not archived, that the app's bot is a member of at the claim, sorted by name then id. It is left out when the bot is in no channel, and in every other answer.
type PasswordResetLink ¶
PasswordResetLink answers POST /admin/users/{id}/password-reset. URL is the one-time link; it is in this answer only.
type Patch ¶
Patch is one field of a partial update: absent from the JSON (Set false, leave unchanged), null (Set true, Value nil: clear) or a value.
func (Patch[T]) MarshalJSON ¶
MarshalJSON writes the value, or null to clear it.
func (*Patch[T]) UnmarshalJSON ¶
UnmarshalJSON records that the field was present.
type PendingPairing ¶
type PendingPairing struct {
ID string `json:"id"`
AppName string `json:"app_name"`
Description string `json:"description"`
RequestedScopes []string `json:"requested_scopes"`
Code string `json:"code"`
SourceIP string `json:"source_ip"`
CAFingerprint string `json:"ca_fingerprint"`
CreatedAt string `json:"created_at"`
ExpiresAt string `json:"expires_at"`
Replaces *PairingReplaces `json:"replaces,omitempty"`
}
PendingPairing is a pairing request as the admin sees it: the code to compare with the one the app shows, where it came from, and the CA fingerprint the app displays too. Replaces is set when the request names an existing app (PairingRequestInput.ReplacesAppID) whose bot account is not deactivated: such an app cannot be reconnected, so the request then shows as a new app.
type PendingPairingList ¶
type PendingPairingList struct {
Items []PendingPairing `json:"items"`
}
PendingPairingList is the body of GET /admin/pairing-requests.
type Pin ¶
type Pin struct {
Message Message `json:"message"`
PinnedBy *string `json:"pinned_by"`
PinnedAt string `json:"pinned_at"`
}
Pin is a pinned message of a channel.
type PinEvent ¶
type PinEvent struct {
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
UserID string `json:"user_id"`
PinnedAt string `json:"pinned_at,omitempty"`
}
PinEvent is the payload of pin.added and pin.removed.
type PinList ¶
type PinList struct {
Items []Pin `json:"items"`
}
PinList is the body of GET /channels/{id}/pins, newest pin first.
type Pong ¶
type Pong struct {
Type string `json:"type"` // FramePong
}
Pong answers a client ping frame.
type PostedAlert ¶
PostedAlert is the answer of POST /alerts: the alert's message and what the post did to the alert (an AlertTransition* constant). A new alert is 201 with transition created; a repeat is 200.
type PresenceEvent ¶
type PresenceEvent struct {
UserID string `json:"user_id"`
State string `json:"state"` // PresenceOnline | PresenceIdle | PresenceOffline
}
PresenceEvent is the payload of the ephemeral presence.changed event.
type PushKeys ¶
PushKeys are the subscription keys a browser's PushSubscription.toJSON() returns: the client's P-256 public key and its 16-byte auth secret, both base64url without padding (RFC 8291).
type PushPayload ¶
type PushPayload struct {
Title string `json:"title"`
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
Body string `json:"body,omitempty"`
}
PushPayload is the JSON the service worker receives in a push message. Body is present only when the admin set push_payload to "full" (a whitespace-collapsed excerpt of at most 120 characters).
type PushSubscribeRequest ¶
PushSubscribeRequest is the body of POST /push/subscriptions. The endpoint must be an https URL of a known browser push service.
type PushUnsubscribeRequest ¶
type PushUnsubscribeRequest struct {
Endpoint string `json:"endpoint"`
}
PushUnsubscribeRequest is the body of DELETE /push/subscriptions.
type PushVapidKey ¶
type PushVapidKey struct {
Key string `json:"key"`
}
PushVapidKey is the response of GET /push/vapid-public-key: the server's VAPID public key (base64url, uncompressed P-256 point) for PushManager.subscribe({applicationServerKey}).
type Reaction ¶
type Reaction struct {
Emoji string `json:"emoji"`
Count int `json:"count"`
UserIDs []string `json:"user_ids"`
}
Reaction is the aggregate of one emoji on a message.
type ReactionEvent ¶
type ReactionEvent struct {
MessageID string `json:"message_id"`
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
Emoji string `json:"emoji"`
Count int `json:"count"`
}
ReactionEvent is the payload of reaction.added and reaction.removed. Count is the number of users with this emoji on the message after the change.
type ReactionList ¶
type ReactionList struct {
Items []Reaction `json:"items"`
}
ReactionList is the body of PUT and DELETE /messages/{id}/reactions/{emoji}: the message's reactions after the change.
type ReadEvent ¶
type ReadEvent struct {
ChannelID string `json:"channel_id"`
LastReadID string `json:"last_read_id"`
Unread int `json:"unread"`
Mentions int `json:"mentions"`
}
ReadEvent is the payload of read.updated: the new read marker of the recipient and the unread and mention counts after the change.
type RegisterRequest ¶
type RegisterRequest struct {
// Name is the person's display name; the @handle is derived from it.
Name string `json:"name"`
Password string `json:"password"`
}
RegisterRequest is the body of POST /register.
type RegistrationActionRequest ¶ added in v0.2.0
type RegistrationActionRequest struct {
Action string `json:"action"`
}
RegistrationActionRequest is the body of POST /admin/registration.
type ResetPasswordRequest ¶
type ResetPasswordRequest struct {
Password string `json:"password"`
}
ResetPasswordRequest is the body of POST /password-resets/{code}.
type ResetPreview ¶
type ResetPreview struct {
Users int `json:"users"`
Channels int `json:"channels"`
Messages int `json:"messages"`
Files int `json:"files"`
Bytes int64 `json:"bytes"`
}
ResetPreview is the body of GET /admin/reset/preview: what a reset would delete, shown in the confirmation dialog. Bytes is the stored size of the distinct uploaded files.
type ResetRequest ¶
type ResetRequest struct {
Mode string `json:"mode"`
Confirm string `json:"confirm"`
Password string `json:"password"`
RotateCA bool `json:"rotate_ca,omitempty"`
KeepSettings bool `json:"keep_settings,omitempty"`
}
ResetRequest is the body of POST /admin/reset. Confirm must equal the instance name and Password is the admin's own password. RotateCA and KeepSettings apply to ResetFactory only.
type ResolveAlertByKeyRequest ¶
type ResolveAlertByKeyRequest struct {
DedupeKey string `json:"dedupe_key"`
Text string `json:"text,omitempty"`
}
ResolveAlertByKeyRequest is the body of POST /alerts/resolve.
type ResolveAlertRequest ¶
type ResolveAlertRequest struct {
Text string `json:"text,omitempty"`
}
ResolveAlertRequest is the optional body of POST /alerts/{id}/resolve.
type RespondCommandRequest ¶
RespondCommandRequest is the body of POST /commands/invocations/{id}/respond.
type RespondedCommand ¶
type RespondedCommand struct {
Ephemeral bool `json:"ephemeral"`
Message *Message `json:"message"`
}
RespondedCommand is the response to a command response. Message is the posted message, null for an ephemeral response (which is never stored).
type SearchPage ¶
type SearchPage struct {
Items []SearchResult `json:"items"`
NextCursor *string `json:"next_cursor"`
}
SearchPage is the body of GET /search, best match first. NextCursor is the opaque cursor of the following page, null on the last page.
type SearchResult ¶
SearchResult is one hit of GET /search: the message and a short excerpt of its text.
Snippet is an HTML fragment that is safe to render as markup: all message text in it is HTML-escaped (&, <, >, " and ') and the only tags are <mark> and </mark> around the matched terms.
type ServerStatus ¶ added in v0.2.0
type ServerStatus struct {
InstanceName string `json:"instance_name"`
// RegistrationOpen reports whether anyone may sign up right now.
RegistrationOpen bool `json:"registration_open"`
// RegistrationClosesAt is when open sign-up ends; null when it has no
// deadline or is closed.
RegistrationClosesAt *string `json:"registration_closes_at"`
}
ServerStatus is the body of GET /status, which needs no sign-in: what a client shows before anyone is signed in.
type Session ¶
type Session struct {
ID string `json:"id"`
Kind string `json:"kind"`
Current bool `json:"current"`
CreatedAt string `json:"created_at"`
LastSeenAt string `json:"last_seen_at"`
IdleExpires string `json:"idle_expires_at"`
AbsExpires string `json:"abs_expires_at"`
UserAgent string `json:"user_agent"`
IP string `json:"ip"`
}
Session describes one signed-in browser or device of the caller.
type SessionList ¶
type SessionList struct {
Items []Session `json:"items"`
}
SessionList is the body of GET /me/sessions.
type SessionRevokedEvent ¶
type SessionRevokedEvent struct {
SessionID string `json:"session_id,omitempty"`
All bool `json:"all,omitempty"`
ExceptSessionID string `json:"except_session_id,omitempty"`
}
SessionRevokedEvent is the payload of session.revoked: one session (SessionID) or all of the user's sessions except ExceptSessionID.
type SettingsPublic ¶
type SettingsPublic struct {
InstanceName string `json:"instance_name"`
UploadMaxBytes int64 `json:"upload_max_bytes"`
WebPushEnabled bool `json:"web_push_enabled"`
}
SettingsPublic is the part of the instance settings every signed-in user may read.
type SettingsUpdatedEvent ¶
type SettingsUpdatedEvent struct {
Keys []string `json:"keys"`
}
SettingsUpdatedEvent is the payload of settings.updated: the changed setting keys; clients re-fetch what they display.
type StartDMRequest ¶
type StartDMRequest struct {
UserIDs []string `json:"user_ids"`
}
StartDMRequest is the body of POST /dms.
type Thread ¶
type Thread struct {
Root Message `json:"root"`
Replies []Message `json:"replies"`
HasMoreBefore bool `json:"has_more_before"`
HasMoreAfter bool `json:"has_more_after"`
}
Thread is a thread root with a page of its replies, oldest first.
type TypingEvent ¶
TypingEvent is the payload of the ephemeral typing event.
type Unread ¶
type Unread struct {
ChannelID string `json:"channel_id"`
Unread int `json:"unread"`
Mentions int `json:"mentions"`
}
Unread is the unread and mention count of one joined channel.
type UpdateAdminChannelRequest ¶
type UpdateAdminChannelRequest struct {
RetentionDays json.RawMessage `json:"retention_days,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
Archived *bool `json:"archived,omitempty"`
}
UpdateAdminChannelRequest is the body of PATCH /admin/channels/{id}. RetentionDays is the JSON number, null (keep forever) or absent.
type UpdateAdminUserRequest ¶
type UpdateAdminUserRequest struct {
Role *string `json:"role,omitempty"`
Deactivated *bool `json:"deactivated,omitempty"`
}
UpdateAdminUserRequest is the body of PATCH /admin/users/{id}.
type UpdateAppRequest ¶
type UpdateAppRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Disabled *bool `json:"disabled,omitempty"`
}
UpdateAppRequest is the body of PATCH /admin/apps/{id}. An absent field is left alone; disabled true rejects the app's tokens until it is false again.
type UpdateChannelRequest ¶
type UpdateChannelRequest struct {
Name *string `json:"name,omitempty"`
Topic *string `json:"topic,omitempty"`
Description *string `json:"description,omitempty"`
RetentionDays Patch[int] `json:"retention_days,omitzero"`
}
UpdateChannelRequest is the body of PATCH /channels/{id}. retention_days null removes the channel's own retention.
type UpdateMeRequest ¶
type UpdateMeRequest struct {
DisplayName Patch[string] `json:"display_name,omitzero"`
StatusText Patch[string] `json:"status_text,omitzero"`
AvatarFileID Patch[string] `json:"avatar_file_id,omitzero"`
Prefs Patch[json.RawMessage] `json:"prefs,omitzero"`
}
UpdateMeRequest is the body of PATCH /me. An absent field is left alone. display_name and prefs cannot be null; status_text null clears the text; avatar_file_id null removes the avatar. prefs replaces the whole object.
type UpdateMembershipRequest ¶
type UpdateMembershipRequest struct {
NotifyLevel *string `json:"notify_level,omitempty"`
AlertMinSeverity *string `json:"alert_min_severity,omitempty"`
MutedUntil Patch[string] `json:"muted_until,omitzero"`
}
UpdateMembershipRequest is the body of PATCH /channels/{id}/membership. muted_until null unmutes.
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
Kind string `json:"kind"`
Role string `json:"role"`
AvatarFileID *string `json:"avatar_file_id"`
StatusText string `json:"status_text"`
Deactivated bool `json:"deactivated"`
CreatedAt string `json:"created_at"`
}
User is the public view of an account.
type UserList ¶
type UserList struct {
Items []User `json:"items"`
}
UserList is the body of GET /users.
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
ChannelID string `json:"channel_id"`
AppID string `json:"app_id"`
Name string `json:"name"`
CreatedBy *string `json:"created_by"`
CreatedAt string `json:"created_at"`
RevokedAt *string `json:"revoked_at"`
}
Webhook is an incoming webhook: a secret URL that posts into one channel as a pseudo-app (a bot account named after the webhook). The secret itself is shown once, when the webhook is created; afterwards nothing identifies the URL but this record.
type WebhookList ¶
type WebhookList struct {
Items []Webhook `json:"items"`
}
WebhookList is the body of GET /admin/webhooks.