chat

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 21 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

Overview

Package chat is the chat domain service: channels, direct messages, messages, threads, reactions, pins, read state and the bootstrap snapshot.

Every mutation runs in exactly one store transaction that writes its rows and appends the matching events (internal/events) before it commits, so the event log and the tables never disagree. Each mutation exists twice: Foo opens its own transaction, FooTx joins the caller's, which is how alerts, webhooks and commands reuse the same code path. Callers of a Tx variant own the transaction; an error returned from it must be returned from the transaction function so nothing partial commits.

Index

Constants

View Source
const (
	ScopeJoined = "joined"
	ScopePublic = "public"
)

Channel list scopes.

View Source
const (
	MaxBodyChars           = 8000
	MaxFileIDs             = 10
	MaxNonceLen            = 64
	MaxOverrideNameChars   = 80
	MaxChannelNameLen      = 64
	MaxTopicChars          = 250
	MaxDescriptionChars    = 1000
	MaxGroupDMParticipants = 9
	MaxInitialMembers      = 200
	MaxReactionsPerMessage = 50
	MaxEmojiBytes          = 64
	MaxMentionedUsers      = 50
	DefaultPageLimit       = 50
	MaxPageLimit           = 100
)

Limits enforced by the chat service. Most mirror CHECK constraints of the schema so a violation is a clear validation error instead of a constraint failure.

View Source
const (
	ScopeMessagesRead  = "messages:read"
	ScopeMessagesWrite = "messages:write"
	ScopeChannelsRead  = "channels:read"
	ScopeDMWrite       = "dm:write"
)

App token scopes the permission matrix looks at.

View Source
const (
	ClassAdmin  = "admin"
	ClassMember = "member"
	ClassGuest  = "guest"
	ClassApp    = "app"
)

Actor classes of the permission matrix.

View Source
const GeneralName = "general"

GeneralName is the name of the default channel created at setup.

View Source
const MaxUserQueryChars = 64

MaxUserQueryChars bounds the q parameter of a user search.

Variables

View Source
var (
	ErrNotFound   = errors.New("not found")
	ErrForbidden  = errors.New("forbidden")
	ErrConflict   = errors.New("conflict")
	ErrValidation = errors.New("validation failed")
)

Errors returned by the chat service. Callers match them with errors.Is; a *ValidationError additionally carries per-field reasons.

Actions lists every action in matrix order.

Functions

func BuiltinCommands

func BuiltinCommands() []protocol.Command

BuiltinCommands lists the slash commands the server runs itself.

func Can

func Can(a Actor, act Action, ch ChannelInfo) error

Can decides whether actor may perform act on a channel. It returns nil when allowed, ErrNotFound when the channel is invisible to the actor (so its existence never leaks), ErrForbidden when it is visible but the action is not allowed, and ErrConflict when the channel is archived (read-only).

Visibility: members see their channels; admins and members also see public channels; guests and apps see only channels they belong to (apps further limited by their token's channel allowlist). Nobody, admins included, sees a private channel, DM or group DM they are not in.

func DMKey

func DMKey(ids []string) string

DMKey is the dm_key of a set of participants: the sorted, de-duplicated ids joined by ",". The same participants give the same key in any order, which makes get-or-create idempotent.

func IsBuiltin

func IsBuiltin(name string) bool

IsBuiltin reports whether name is a built-in command.

func NormalizeChannelName

func NormalizeChannelName(name string) (string, string)

NormalizeChannelName lowercases name, trims blanks and one leading "#" and reports why the result is not a valid channel name ("" when valid).

Types

type Action

type Action string

Action is something an actor can try to do in or about a channel.

const (
	ActView          Action = "view"           // see the channel and read its history
	ActPost          Action = "post"           // send messages
	ActJoin          Action = "join"           // join a public channel
	ActLeave         Action = "leave"          // leave a public or private channel
	ActManage        Action = "manage"         // rename, topic, description, retention
	ActAddMember     Action = "add_member"     // add or promote a member
	ActRemoveMember  Action = "remove_member"  // remove another member
	ActDeleteAny     Action = "delete_any"     // delete other people's messages
	ActPin           Action = "pin"            // pin and unpin messages
	ActReact         Action = "react"          // add and remove own reactions
	ActArchive       Action = "archive"        // archive and unarchive
	ActCreateChannel Action = "create_channel" // create a public or private channel
	ActStartDM       Action = "start_dm"       // start a DM or group DM
)

The actions of the permission matrix.

const ActReadContent Action = "read_content"

ActReadContent gates the bytes of a file, on top of ActView's visibility: an app needs messages:read for content, while channels:read shows the channel only. It is not a matrix column, so Actions does not list it.

type Actor

type Actor struct {
	ID string
	// Role is the account role: admin, member or guest.
	Role string
	// Kind is human (or empty) or app.
	Kind string
	// Scopes and ChannelIDs apply to apps only. ChannelIDs is the token's
	// channel allowlist; nil means every channel the app is a member of.
	Scopes     []string
	ChannelIDs []string
}

Actor is the authenticated caller of a chat operation.

func (Actor) Class

func (a Actor) Class() string

Class returns the row of the permission matrix the actor falls in, or "" for an unknown role.

func (Actor) HasScope

func (a Actor) HasScope(scope string) bool

HasScope reports whether an app token carries scope.

func (Actor) IsApp

func (a Actor) IsApp() bool

IsApp reports whether the actor is an app account.

type AdminChannelPatch

type AdminChannelPatch struct {
	RetentionDays Nullable[int]
	IsDefault     *bool
	Archived      *bool
}

AdminChannelPatch is a partial admin change of a public or private channel.

type BuiltinInput

type BuiltinInput struct {
	Command      string
	Args         string
	ChannelID    string
	ThreadRootID string
	// Catalog is the command list /help shows; empty means the built-ins.
	Catalog []protocol.Command
}

BuiltinInput are the inputs of RunBuiltin.

type BuiltinResult

type BuiltinResult struct {
	Notice string
}

BuiltinResult is what a built-in command wants shown to its invoker: a private notice, empty when the command needs none.

type ChannelInfo

type ChannelInfo struct {
	ID       string
	Kind     string
	Archived bool
	// Member reports whether the actor is a member; Owner whether their
	// membership role is owner.
	Member bool
	Owner  bool
}

ChannelInfo is what the permission matrix needs to know about a channel and the actor's relation to it.

type CreateChannelParams

type CreateChannelParams struct {
	Name        string
	Kind        string // public or private
	Topic       string
	Description string
	// MemberIDs are added as plain members next to the creator, who becomes
	// the owner.
	MemberIDs []string
}

CreateChannelParams are the inputs of CreateChannel.

type CreateMessageParams

type CreateMessageParams struct {
	ChannelID string
	// AuthorID is the sender. CreateMessage overwrites it with the actor.
	AuthorID string
	// Kind is text (the default), alert or system. Alert and system messages
	// never carry mentions, whatever their body says.
	Kind string
	Body string
	// ThreadRootID makes the message a reply. Replying to a reply attaches
	// to the reply's thread root.
	ThreadRootID string
	FileIDs      []string
	// Nonce makes the call idempotent per author: the same nonce returns the
	// existing message and writes nothing.
	Nonce string
	// OverrideName is the display name of a webhook post; it can only be set
	// through CreateMessageTx.
	OverrideName string
	// DisableMentions stores the message without mention rows and with
	// mention_channel and mention_here at 0, whatever the body says. Webhook
	// posts set it: their text comes from outside, so it must not be able to
	// notify anyone.
	DisableMentions bool
	// AfterInsert runs inside the transaction once the message row exists
	// and before the message.created event is built, so the alerts service
	// can insert its alerts row and have it in the event payload.
	AfterInsert func(tx *store.Tx, messageID string) error
}

CreateMessageParams are the inputs of CreateMessage and CreateMessageTx.

type Error

type Error struct {
	Kind error
	Msg  string
}

Error is a typed service error: Kind is one of the sentinels above and Msg is safe to show to the caller.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FileAttacher

type FileAttacher interface {
	AttachTx(tx *store.Tx, messageID, authorID string, fileIDs []string) ([]protocol.File, error)
}

FileAttacher links already uploaded files to a new message. It is implemented by the files service (T9) and runs inside the message's transaction: it must verify the uploader owns the files, insert the attachments rows and return the wire view of the files in fileIDs order.

type MembershipUpdate

type MembershipUpdate struct {
	NotifyLevel      *string
	AlertMinSeverity *string
	MutedUntil       Nullable[time.Time]
}

MembershipUpdate are the partial inputs of UpdateMembership; unset fields stay as they are.

type Mentions

type Mentions struct {
	// Usernames are the lower-cased @username tokens in order of first
	// appearance, without @channel and @here. They are not yet checked
	// against existing users.
	Usernames []string
	Channel   bool
	Here      bool
}

Mentions found in a message body.

func ExtractMentions

func ExtractMentions(body string) Mentions

ExtractMentions returns the mentions in a Markdown body, ignoring code spans, fenced and indented code blocks and raw HTML.

type Nullable

type Nullable[T any] struct {
	Set   bool
	Value *T
}

Nullable distinguishes "leave unchanged" (Set false), "clear" (Set true, Value nil) and "set" (Set true, Value non-nil) in partial updates.

func Clear

func Clear[T any]() Nullable[T]

Clear returns a Nullable that clears the field.

func Some

func Some[T any](v T) Nullable[T]

Some returns a Nullable that sets v.

type PageOptions

type PageOptions struct {
	Before, After, Around string
	Limit                 int
}

PageOptions select a page of messages by id. At most one of Before, After and Around may be set; none means the newest messages.

type Service

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

Service is the chat domain service.

func New

func New(db *store.DB, st *settings.Store) *Service

New returns a Service over db. settings supplies the values bootstrap reports and the retention ceiling.

func (*Service) AddMember

func (s *Service) AddMember(ctx context.Context, actor Actor, channelID, userID, role string) (protocol.Membership, error)

AddMember adds userID to a channel, or changes the role of an existing member (role "" means member). Adding an existing member with the same role changes nothing. A new member emits channel.member_joined; a role change emits membership.updated to that member.

func (*Service) AddMemberTx

func (s *Service) AddMemberTx(tx *store.Tx, actor Actor, channelID, userID, role string) (protocol.Membership, error)

AddMemberTx is AddMember inside the caller's transaction.

func (*Service) AddReaction

func (s *Service) AddReaction(ctx context.Context, actor Actor, messageID, emoji string) ([]protocol.Reaction, error)

AddReaction adds the actor's emoji reaction to a message and returns the message's reactions. Adding a reaction that exists changes nothing. A message holds at most 50 distinct emoji. It emits reaction.added.

func (*Service) AddReactionTx

func (s *Service) AddReactionTx(tx *store.Tx, actor Actor, messageID, emoji string) ([]protocol.Reaction, error)

AddReactionTx is AddReaction inside the caller's transaction.

func (*Service) AdminListChannels

func (s *Service) AdminListChannels(ctx context.Context, actor Actor) ([]protocol.Channel, error)

AdminListChannels returns every public and private channel with its name, settings and member count, whether or not the admin is a member. It never reads messages; DMs and group DMs are not listed.

func (*Service) AdminUpdateChannel

func (s *Service) AdminUpdateChannel(ctx context.Context, actor audit.Actor, admin Actor, channelID string, p AdminChannelPatch) (protocol.Channel, error)

AdminUpdateChannel sets retention, the default flag and the archived state of a public or private channel without needing to be a member. Events are the usual channel.updated / channel.archived / channel.unarchived.

func (*Service) ArchiveChannel

func (s *Service) ArchiveChannel(ctx context.Context, actor Actor, channelID string) (protocol.Channel, error)

ArchiveChannel makes a channel read-only. It emits channel.archived.

func (*Service) ArchiveChannelTx

func (s *Service) ArchiveChannelTx(tx *store.Tx, actor Actor, channelID string) (protocol.Channel, error)

ArchiveChannelTx is ArchiveChannel inside the caller's transaction.

func (*Service) Bootstrap

func (s *Service) Bootstrap(ctx context.Context, actor Actor) (protocol.Bootstrap, error)

Bootstrap assembles the GET /bootstrap snapshot for the actor. All reads share one read transaction, so the data is consistent with SeqHead: a client that replays events after SeqHead converges to the current state. Guests and apps see only the users they share a channel with and no channel directory. An app token with a channel allowlist also sees only those channels, their memberships and unread counts, and the users who share them.

func (*Service) CheckPost

func (s *Service) CheckPost(ctx context.Context, actor Actor, channelID, threadRootID string) error

CheckPost reports whether actor may post in channelID (and in the thread of threadRootID when given): nil, or the typed error a post would get. It writes nothing.

func (*Service) CreateChannel

func (s *Service) CreateChannel(ctx context.Context, actor Actor, p CreateChannelParams) (protocol.Channel, error)

CreateChannel creates a public or private channel owned by the actor.

func (*Service) CreateChannelTx

func (s *Service) CreateChannelTx(tx *store.Tx, actor Actor, p CreateChannelParams) (protocol.Channel, error)

CreateChannelTx is CreateChannel inside the caller's transaction. It emits channel.created.

func (*Service) CreateMessage

func (s *Service) CreateMessage(ctx context.Context, actor Actor, p CreateMessageParams) (protocol.Message, bool, error)

CreateMessage posts a text message as actor and reports whether it was created (false: the nonce matched an existing message and nothing was written). It emits message.created, and message.updated for the thread root of a reply.

func (*Service) CreateMessageAsTx

func (s *Service) CreateMessageAsTx(tx *store.Tx, actor Actor, p CreateMessageParams) (protocol.Message, bool, error)

CreateMessageAsTx is CreateMessage inside the caller's transaction.

func (*Service) CreateMessageTx

func (s *Service) CreateMessageTx(tx *store.Tx, p CreateMessageParams) (protocol.Message, error)

CreateMessageTx writes a message and its events inside the caller's transaction without checking who may post: the caller (alerts, webhooks, commands, system notices) has authorized the author already. The channel must exist and not be archived; the author need not be a member.

func (*Service) DeleteMessage

func (s *Service) DeleteMessage(ctx context.Context, actor Actor, messageID string) error

DeleteMessage turns a message into a tombstone: the body, reactions, mentions, pin and attachments are removed, the row stays so threads and ids remain stable. The author, a channel owner or an admin (see ActDeleteAny) may delete. It emits message.deleted, pin.removed for a pinned message and message.updated for the root of a deleted reply. Deleting a deleted message does nothing.

func (*Service) DeleteMessageTx

func (s *Service) DeleteMessageTx(tx *store.Tx, actor Actor, messageID string) error

DeleteMessageTx is DeleteMessage inside the caller's transaction.

func (*Service) EditMessage

func (s *Service) EditMessage(ctx context.Context, actor Actor, messageID, body string) (protocol.Message, error)

EditMessage replaces the body of the actor's own text message. It emits message.updated and re-extracts the mentions. Editing a deleted message is ErrConflict.

func (*Service) EditMessageTx

func (s *Service) EditMessageTx(tx *store.Tx, actor Actor, messageID, body string) (protocol.Message, error)

EditMessageTx is EditMessage inside the caller's transaction.

func (*Service) GetChannel

func (s *Service) GetChannel(ctx context.Context, actor Actor, channelID string) (protocol.Channel, error)

GetChannel returns a channel the actor may view.

func (*Service) GetMessage

func (s *Service) GetMessage(ctx context.Context, actor Actor, messageID string) (protocol.Message, error)

GetMessage returns a message from a channel the actor may view. An app needs messages:read; a channel it can see but not read is ErrForbidden.

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, actor Actor, userID string) (protocol.User, error)

GetUser returns one account the actor may know about; any other id, existing or not, is not found.

func (*Service) HydrateMessagesUnchecked

func (s *Service) HydrateMessagesUnchecked(ctx context.Context, ids []string) ([]protocol.Message, error)

HydrateMessagesUnchecked loads the wire view of the messages with the given ids, in that order, skipping ids that do not exist.

It performs no permission check (hence the name): the caller (internal/search, internal/alerts) has already restricted ids to messages the actor may see.

func (*Service) JoinChannel

func (s *Service) JoinChannel(ctx context.Context, actor Actor, channelID string) (protocol.Membership, error)

JoinChannel joins a public channel. Joining a channel the actor is already in changes nothing and emits nothing. It emits channel.member_joined.

func (*Service) JoinChannelTx

func (s *Service) JoinChannelTx(tx *store.Tx, actor Actor, channelID string) (protocol.Membership, error)

JoinChannelTx is JoinChannel inside the caller's transaction.

func (*Service) LeaveChannel

func (s *Service) LeaveChannel(ctx context.Context, actor Actor, channelID string) error

LeaveChannel removes the actor from a public or private channel. It emits channel.member_left.

func (*Service) LeaveChannelTx

func (s *Service) LeaveChannelTx(tx *store.Tx, actor Actor, channelID string) error

LeaveChannelTx is LeaveChannel inside the caller's transaction.

func (*Service) ListChannels

func (s *Service) ListChannels(ctx context.Context, actor Actor, scope string) ([]protocol.Channel, error)

ListChannels returns the channels the actor is in (ScopeJoined) or the public directory (ScopePublic, not available to guests and apps).

func (*Service) ListMembers

func (s *Service) ListMembers(ctx context.Context, actor Actor, channelID string) ([]protocol.Member, error)

ListMembers returns the members of a channel the actor may view, oldest first.

func (*Service) ListMessages

func (s *Service) ListMessages(ctx context.Context, actor Actor, channelID string, o PageOptions) (protocol.MessagePage, error)

ListMessages returns a page of the channel's root messages, oldest first. Replies are fetched per thread with ListThread. An app needs messages:read (ActReadContent); channels:read alone shows the channel, not its messages.

func (*Service) ListPins

func (s *Service) ListPins(ctx context.Context, actor Actor, channelID string) ([]protocol.Pin, error)

ListPins returns the channel's pinned messages, newest pin first. An app needs messages:read.

func (*Service) ListThread

func (s *Service) ListThread(ctx context.Context, actor Actor, messageID string, o PageOptions) (protocol.Thread, error)

ListThread returns the thread messageID belongs to: its root and a page of the replies, oldest first. messageID may be the root or any reply. An app needs messages:read.

func (*Service) ListUsers

func (s *Service) ListUsers(ctx context.Context, actor Actor, q string) ([]protocol.User, error)

ListUsers returns the accounts the actor may know about, ordered by id. Members and admins see everyone; guests and apps see only themselves and the users who share a channel with them (an app token's channel allowlist narrows that further). A non-empty q keeps users whose username or display name contains it, ignoring ASCII case.

func (*Service) LoadMessageTx

func (s *Service) LoadMessageTx(tx *store.Tx, id string) (protocol.Message, error)

LoadMessageTx returns the wire view of a message inside the caller's transaction, so it sees the caller's uncommitted changes (an alert row updated in the same transaction, say). It performs no permission check; the caller has authorized access. A missing message is ErrNotFound.

func (*Service) MarkRead

func (s *Service) MarkRead(ctx context.Context, actor Actor, channelID, messageID string) (protocol.ReadEvent, error)

MarkRead moves the actor's read marker in a channel forward to messageID, or past the thread replies after it (see readTarget). The marker never moves backwards: an older (or equal) target changes nothing and emits nothing. It emits read.updated to the actor, carrying the resulting unread and mention counts.

func (*Service) MarkReadTx

func (s *Service) MarkReadTx(tx *store.Tx, actor Actor, channelID, messageID string) (protocol.ReadEvent, error)

MarkReadTx is MarkRead inside the caller's transaction.

func (*Service) OnBootstrapTx added in v0.2.0

func (s *Service) OnBootstrapTx(_ context.Context, tx *store.Tx, adminID string) error

OnBootstrapTx creates #general, owned by the first admin, inside the bootstrap transaction. It matches auth.Options.OnBootstrap.

func (*Service) OnUserCreatedTx

func (s *Service) OnUserCreatedTx(ctx context.Context, tx *store.Tx, userID string) error

OnUserCreatedTx joins a new human member or admin to every default channel. Guests and apps join nothing; they only see channels they are added to. It matches auth.Options.OnUserCreated and emits channel.member_joined per channel.

func (*Service) PinMessage

func (s *Service) PinMessage(ctx context.Context, actor Actor, channelID, messageID string) (protocol.Pin, error)

PinMessage pins a message of the channel; any member may. Pinning a pinned message changes nothing. It emits pin.added.

func (*Service) PinMessageTx

func (s *Service) PinMessageTx(tx *store.Tx, actor Actor, channelID, messageID string) (protocol.Pin, error)

PinMessageTx is PinMessage inside the caller's transaction.

func (*Service) RemoveMember

func (s *Service) RemoveMember(ctx context.Context, actor Actor, channelID, userID string) error

RemoveMember removes another member from a channel (removing oneself is leaving). It emits channel.member_left.

func (*Service) RemoveMemberTx

func (s *Service) RemoveMemberTx(tx *store.Tx, actor Actor, channelID, userID string) error

RemoveMemberTx is RemoveMember inside the caller's transaction.

func (*Service) RemoveReaction

func (s *Service) RemoveReaction(ctx context.Context, actor Actor, messageID, emoji string) ([]protocol.Reaction, error)

RemoveReaction removes the actor's emoji reaction and returns the message's reactions. Removing a reaction that does not exist changes nothing. It emits reaction.removed.

func (*Service) RemoveReactionTx

func (s *Service) RemoveReactionTx(tx *store.Tx, actor Actor, messageID, emoji string) ([]protocol.Reaction, error)

RemoveReactionTx is RemoveReaction inside the caller's transaction.

func (*Service) RunBuiltin

func (s *Service) RunBuiltin(ctx context.Context, actor Actor, in BuiltinInput) (BuiltinResult, error)

RunBuiltin runs a built-in command as actor. A command the actor may not run, or ran wrongly, is not an error: the reason comes back as the notice. Only an infrastructure failure is returned as an error.

func (*Service) SetBodyQuietTx

func (s *Service) SetBodyQuietTx(tx *store.Tx, messageID, body string) error

SetBodyQuietTx is SetBodyTx for a body that came from outside (a webhook): the message keeps no mentions, whatever the body says. SetBodyTx already keeps alert and system messages free of mentions, so the two are the same for them.

func (*Service) SetBodyTx

func (s *Service) SetBodyTx(tx *store.Tx, messageID, body string) error

SetBodyTx replaces the body of a message on behalf of the server itself, without an author or permission check: the alerts service re-renders the body of an alert message when the alert repeats. The body is validated like any message body, the plain text and mentions are refreshed (an alert or system message keeps none), and edited_at stays untouched (the author did not edit anything). It emits no event; the caller appends message.updated once the rest of its change is written. The message must exist and not be deleted.

func (*Service) SetDefault

func (s *Service) SetDefault(ctx context.Context, actor Actor, channelID string, isDefault bool) (protocol.Channel, error)

SetDefault marks a public channel as a default channel (or not). New members and admins join default channels automatically. Admin only.

func (*Service) SetDefaultTx

func (s *Service) SetDefaultTx(tx *store.Tx, actor Actor, channelID string, isDefault bool) (protocol.Channel, error)

SetDefaultTx is SetDefault inside the caller's transaction.

func (*Service) SetFileAttacher

func (s *Service) SetFileAttacher(a FileAttacher)

SetFileAttacher installs the file attacher. Until one is set, a message with file_ids is rejected as a validation error.

func (*Service) StartDM

func (s *Service) StartDM(ctx context.Context, actor Actor, userIDs []string) (protocol.Channel, bool, error)

StartDM returns the direct message between the actor and userIDs, creating it if needed: one other user gives a dm, several a group_dm (at most 9 participants including the actor), none a note-to-self. The result is the same whatever the order of ids; created reports whether a channel was made. A new channel emits channel.created.

func (*Service) StartDMTx

func (s *Service) StartDMTx(tx *store.Tx, actor Actor, userIDs []string) (protocol.Channel, bool, error)

StartDMTx is StartDM inside the caller's transaction.

func (*Service) UnarchiveChannel

func (s *Service) UnarchiveChannel(ctx context.Context, actor Actor, channelID string) (protocol.Channel, error)

UnarchiveChannel reopens an archived channel. It emits channel.unarchived.

func (*Service) UnarchiveChannelTx

func (s *Service) UnarchiveChannelTx(tx *store.Tx, actor Actor, channelID string) (protocol.Channel, error)

UnarchiveChannelTx is UnarchiveChannel inside the caller's transaction.

func (*Service) UnpinMessage

func (s *Service) UnpinMessage(ctx context.Context, actor Actor, channelID, messageID string) error

UnpinMessage removes a pin; any member may. Unpinning a message that is not pinned changes nothing. It emits pin.removed.

func (*Service) UnpinMessageTx

func (s *Service) UnpinMessageTx(tx *store.Tx, actor Actor, channelID, messageID string) error

UnpinMessageTx is UnpinMessage inside the caller's transaction.

func (*Service) UnreadCounts

func (s *Service) UnreadCounts(ctx context.Context, userID string) ([]protocol.Unread, error)

UnreadCounts returns the unread and mention counts of every channel the user has joined.

func (*Service) UpdateChannel

func (s *Service) UpdateChannel(ctx context.Context, actor Actor, channelID string, p UpdateChannelParams) (protocol.Channel, error)

UpdateChannel renames a channel or changes its topic, description or retention. Only owners (and admins) may. It emits channel.updated unless nothing changed.

func (*Service) UpdateChannelTx

func (s *Service) UpdateChannelTx(tx *store.Tx, actor Actor, channelID string, p UpdateChannelParams) (protocol.Channel, error)

UpdateChannelTx is UpdateChannel inside the caller's transaction.

func (*Service) UpdateMembership

func (s *Service) UpdateMembership(ctx context.Context, actor Actor, channelID string, u MembershipUpdate) (protocol.Membership, error)

UpdateMembership changes the actor's own notification preferences for a channel. It emits membership.updated to the actor unless nothing changed.

func (*Service) UpdateMembershipTx

func (s *Service) UpdateMembershipTx(tx *store.Tx, actor Actor, channelID string, u MembershipUpdate) (protocol.Membership, error)

UpdateMembershipTx is UpdateMembership inside the caller's transaction.

type UpdateChannelParams

type UpdateChannelParams struct {
	Name          *string
	Topic         *string
	Description   *string
	RetentionDays Nullable[int]
}

UpdateChannelParams are the partial inputs of UpdateChannel; nil / unset fields stay as they are.

type ValidationError

type ValidationError struct{ Fields map[string]string }

ValidationError reports invalid input; Fields maps a request field to the reason it was rejected.

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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