domain

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

View Source
const (
	EventMessageNew     = "message.new"
	EventPresenceUpdate = "presence.update"
)

Event type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllDMInfo

type AllDMInfo struct {
	ChannelID     int64
	ChannelName   string
	User1Username string // removed User1ID, User2ID — not needed
	User2Username string
}

type BackupStore added in v0.9.0

type BackupStore interface {
	Store
	ImportMessage(channelID int64, identityID string, body string, threadID *int64, mentionIdentityIDs []string, createdAt time.Time) (int64, error)
	IsEmpty() (bool, error)
	WipeAll() error
}

BackupStore extends Store with backup-specific operations. These methods are only needed in backup restore paths and are intentionally excluded from the composite Store to honour the Interface Segregation Principle — daemon handlers must not accidentally call WipeAll or ImportMessage. A concrete adapter satisfies BackupStore if and only if it implements Store plus the three methods below.

type Channel

type Channel struct {
	ID        int64
	Name      string
	Public    bool
	Type      string // "channel" or "dm"
	CreatedAt time.Time
}

type ChannelStore

type ChannelStore interface {
	CreateChannel(name string, public bool, memberIDs []string, channelType string) (int64, error)
	GetChannelByID(id int64) (*Channel, error)
	GetChannelByName(name string) (*Channel, error)
	ListChannelsForUser(identityID string) ([]ChannelWithMembership, error)
	ListAllChannelsWithMembership(identityID string) ([]ChannelWithMembership, error)
	AddChannelMember(channelID int64, identityID string) error
	ChannelMemberUsernames(channelID int64) ([]string, error)
	IsChannelMember(channelID int64, identityID string) (bool, error)
	GetServiceMemberUsernames(channelID int64) ([]string, error)
	ListDMsForUser(identityID string) ([]DMInfo, error)
	ListAllDMs() ([]AllDMInfo, error)
	OpenDM(identityID string, otherIdentityID string, otherUsername string) (string, bool, error)
}

type ChannelWithMembership

type ChannelWithMembership struct {
	Channel
	Member bool
}

type DMInfo

type DMInfo struct {
	ChannelID     int64
	ChannelName   string
	OtherUsername string // removed OtherUserID — not needed
}

type Event added in v0.4.0

type Event struct {
	Type    string
	Payload any
}

Event is a typed message published to the event bus.

type EventBus added in v0.4.0

type EventBus interface {
	Publish(event Event)
	Subscribe(eventTypes ...string) Subscription
}

EventBus is an in-process pub/sub system for domain events.

func NewEventBus added in v0.4.0

func NewEventBus() EventBus

NewEventBus creates a new in-process event bus.

type Identity added in v0.6.0

type Identity struct {
	ID          string // Internal stable UUID (never changes after creation)
	AuthID      string // Passport-provided UUID (may change if user is recreated)
	Username    string
	DisplayName string
	Type        string // "user", "agent", "service"
	Role        string
	CreatedAt   time.Time
}

type IdentityStore added in v0.6.0

type IdentityStore interface {
	UpsertIdentity(authID, username, displayName, identityType, role string) (*Identity, error)
	GetIdentityByID(id string) (*Identity, error)
	GetIdentityByUsername(username string) (*Identity, error)
	ListIdentities() ([]Identity, error)
}

type IdentityWebhook added in v0.7.0

type IdentityWebhook struct {
	ID         string
	IdentityID string
	URL        string
	Active     bool
}

type MentionGroup added in v0.5.0

type MentionGroup struct {
	ID        int64     `json:"id"`
	Slug      string    `json:"slug"`
	CreatedBy string    `json:"created_by,omitempty"`
	Members   []string  `json:"members,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

type MentionGroupStore added in v0.5.0

type MentionGroupStore interface {
	CreateMentionGroup(slug string, createdByID string) (int64, error)
	DeleteMentionGroup(id int64) error
	GetMentionGroup(slug string) (*MentionGroup, error)
	ListMentionGroups() ([]MentionGroup, error)
	AddMentionGroupMember(groupID int64, identityID string) error
	RemoveMentionGroupMember(groupID int64, identityID string) error
	GetMentionGroupMembers(groupID int64) ([]string, error)
	ExpandMentionGroups(slugs []string) (map[string][]string, error)
}

type Message

type Message struct {
	ID         int64
	ChannelID  int64
	IdentityID string // was UserID int64
	From       string
	Body       string
	ThreadID   *int64
	Mentions   []string
	Metadata   *string // JSON string, nullable
	CreatedAt  time.Time
}

type MessageEvent added in v0.4.0

type MessageEvent struct {
	ChannelName string
	ChannelType string // "channel" or "dm"
	From        string
	Body        string
	MessageID   int64
	SentAt      time.Time
	Mentions    []string
	ThreadID    *int64
	Metadata    *string // JSON string, opaque
}

MessageEvent is the payload for EventMessageNew.

type MessageStore

type MessageStore interface {
	SendMessage(channelID int64, identityID string, body string, threadID *int64, mentionIdentityIDs []string, metadata *string) (int64, error)
	GetMessages(channelID int64, before *int64, after *int64, limit int, threadID *int64) ([]Message, error)
	GetUnreadMessages(identityID string, channelID *int64, mentionsOnly bool, threadID *int64) ([]Message, error)
	GetUnreadCounts(identityID string) ([]UnreadCount, error)
	MarkRead(identityID string, channelID int64, messageID *int64) error
}

type Role

type Role struct {
	Name    string
	BuiltIn bool
}

type RoleStore

type RoleStore interface {
	CreateRole(name string) error
	DeleteRole(name string) error
	ListRoles() ([]Role, error)
	GrantPermission(role, permission string) error
	RevokePermission(role, permission string) error
	GetRolePermissions(role string) ([]string, error)
	GetUserPermissions(username string) ([]string, error)
	HasPermission(username, permission string) (bool, error)
	SetUserRole(username, role string) error
	SetUserType(username, userType string) error
}

type SettingsStore

type SettingsStore interface {
	GetSetting(key string) (string, error)
	SetSetting(key, value string) error
	ListSettings() (map[string]string, error)
}

type Store

Store is the composite interface for convenient wiring.

type Subscription added in v0.4.0

type Subscription interface {
	Events() <-chan Event
	Close()
}

Subscription receives events from the bus.

type UnreadCount

type UnreadCount struct {
	ChannelID    int64
	Channel      string
	UnreadCount  int
	MentionCount int
	Type         string
}

type WebhookStore added in v0.7.0

type WebhookStore interface {
	RegisterWebhook(identityID, url string) (string, error)
	UnregisterWebhook(identityID, webhookID string) error
	GetActiveWebhooksForIdentity(identityID string) ([]IdentityWebhook, error)
	// GetWebhooksForChannel returns active webhooks for all service members of a channel.
	GetWebhooksForChannel(channelID int64) ([]IdentityWebhook, error)
}

Jump to

Keyboard shortcuts

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