domain

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 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
	User1ID       int64
	User1Username string
	User2ID       int64
	User2Username string
}

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 []int64, channelType string) (int64, error)
	GetChannelByID(id int64) (*Channel, error)
	GetChannelByName(name string) (*Channel, error)
	ListChannelsForUser(userID int64) ([]ChannelWithMembership, error)
	ListAllChannelsWithMembership(userID int64) ([]ChannelWithMembership, error)
	AddChannelMember(channelID, userID int64) error
	ChannelMemberUsernames(channelID int64) ([]string, error)
	IsChannelMember(channelID, userID int64) (bool, error)
	ListDMsForUser(userID int64) ([]DMInfo, error)
	ListAllDMs() ([]AllDMInfo, error)
	OpenDM(userID, otherUserID int64, otherUsername string) (string, bool, error)
}

type ChannelWithMembership

type ChannelWithMembership struct {
	Channel
	Member bool
}

type DMInfo

type DMInfo struct {
	ChannelID     int64
	ChannelName   string
	OtherUserID   int64
	OtherUsername string
}

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 MentionGroup added in v0.5.0

type MentionGroup struct {
	ID        int64
	Slug      string
	CreatedBy string   // username of creator
	Members   []string // member usernames
	CreatedAt time.Time
}

type MentionGroupStore added in v0.5.0

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

type Message

type Message struct {
	ID        int64
	ChannelID int64
	UserID    int64
	From      string // username
	Body      string
	ThreadID  *int64
	Mentions  []string
	CreatedAt time.Time
}

type MessageEvent added in v0.4.0

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

MessageEvent is the payload for EventMessageNew.

type MessageStore

type MessageStore interface {
	SendMessage(channelID, userID int64, body string, threadID *int64, mentionUserIDs []int64) (int64, error)
	GetMessages(channelID int64, before *int64, after *int64, limit int, threadID *int64) ([]Message, error)
	GetUnreadMessages(userID int64, channelID *int64, mentionsOnly bool, threadID *int64) ([]Message, error)
	GetUnreadCounts(userID int64) ([]UnreadCount, error)
	MarkRead(userID, 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 User

type User struct {
	ID        int64
	Username  string
	Password  string
	Role      string
	Type      string
	CreatedAt time.Time
}

type UserStore

type UserStore interface {
	CreateUser(username, password string) (int64, error)
	GetUserByUsername(username string) (*User, error)
	ListUsers() ([]User, error)
}

Jump to

Keyboard shortcuts

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