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
- type AllDMInfo
- type BackupStore
- type Channel
- type ChannelStore
- type ChannelWithMembership
- type DMInfo
- type Event
- type EventBus
- type Identity
- type IdentityStore
- type IdentityWebhook
- type MentionGroup
- type MentionGroupStore
- type Message
- type MessageEvent
- type MessageStore
- type Role
- type RoleStore
- type SettingsStore
- type Store
- type Subscription
- type UnreadCount
- type WebhookStore
Constants ¶
const ( EventMessageNew = "message.new" EventPresenceUpdate = "presence.update" )
Event type constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 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 IdentityStore ¶ added in v0.6.0
type IdentityWebhook ¶ added in v0.7.0
type MentionGroup ¶ added in v0.5.0
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 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 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 Store ¶
type Store interface {
IdentityStore
ChannelStore
MessageStore
RoleStore
MentionGroupStore
SettingsStore
WebhookStore
Close() error
}
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 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)
}