sqlite

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: 13 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

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

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

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements domain.Store backed by SQLite.

func Open

func Open(path string) (*Store, error)

Open opens an SQLite database and runs migrations.

func (*Store) AddChannelMember

func (s *Store) AddChannelMember(channelID int64, identityID string) error

AddChannelMember adds an identity to a channel.

func (*Store) AddMentionGroupMember added in v0.5.0

func (s *Store) AddMentionGroupMember(groupID int64, identityID string) error

func (*Store) ChannelMemberUsernames

func (s *Store) ChannelMemberUsernames(channelID int64) ([]string, error)

ChannelMemberUsernames returns the usernames of all members of a channel.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) CreateChannel

func (s *Store) CreateChannel(name string, public bool, memberIDs []string, channelType string) (int64, error)

CreateChannel creates a channel with the given members in a transaction. channelType should be "channel" or "dm".

func (*Store) CreateMentionGroup added in v0.5.0

func (s *Store) CreateMentionGroup(slug string, createdByID string) (int64, error)

func (*Store) CreateRole

func (s *Store) CreateRole(name string) error

CreateRole inserts a new custom role.

func (*Store) DeleteMentionGroup added in v0.5.0

func (s *Store) DeleteMentionGroup(id int64) error

func (*Store) DeleteRole

func (s *Store) DeleteRole(name string) error

DeleteRole removes a custom role. Built-in roles cannot be deleted.

func (*Store) ExpandMentionGroups added in v0.5.0

func (s *Store) ExpandMentionGroups(slugs []string) (map[string][]string, error)

func (*Store) GetActiveWebhooksForIdentity added in v0.7.0

func (s *Store) GetActiveWebhooksForIdentity(identityID string) ([]domain.IdentityWebhook, error)

func (*Store) GetChannelByID

func (s *Store) GetChannelByID(id int64) (*domain.Channel, error)

GetChannelByID returns a channel by its ID.

func (*Store) GetChannelByName

func (s *Store) GetChannelByName(name string) (*domain.Channel, error)

GetChannelByName returns a channel by its name.

func (*Store) GetIdentityByID added in v0.6.0

func (s *Store) GetIdentityByID(id string) (*domain.Identity, error)

func (*Store) GetIdentityByUsername added in v0.6.0

func (s *Store) GetIdentityByUsername(username string) (*domain.Identity, error)

func (*Store) GetMentionGroup added in v0.5.0

func (s *Store) GetMentionGroup(slug string) (*domain.MentionGroup, error)

func (*Store) GetMentionGroupMembers added in v0.5.0

func (s *Store) GetMentionGroupMembers(groupID int64) ([]string, error)

func (*Store) GetMessages

func (s *Store) GetMessages(channelID int64, before *int64, after *int64, limit int, threadID *int64) ([]domain.Message, error)

GetMessages returns messages for a channel with cursor-based pagination. If before is set, returns messages with id < before (most recent first up to limit, returned in ASC order). If after is set, returns messages with id > after in ASC order. If neither is set, returns the most recent `limit` messages in ASC order. If threadID is set, only returns replies to that parent message.

func (*Store) GetRolePermissions

func (s *Store) GetRolePermissions(role string) ([]string, error)

GetRolePermissions returns all permissions granted to a role.

func (*Store) GetServiceMemberUsernames added in v0.7.0

func (s *Store) GetServiceMemberUsernames(channelID int64) ([]string, error)

GetServiceMemberUsernames returns usernames of service-type members of a channel.

func (*Store) GetSetting

func (s *Store) GetSetting(key string) (string, error)

GetSetting returns the value for a setting key.

func (*Store) GetUnreadCounts

func (s *Store) GetUnreadCounts(identityID string) ([]domain.UnreadCount, error)

GetUnreadCounts returns per-channel unread message and mention counts for an identity. Only returns channels with >0 unreads. Excludes the identity's own messages.

func (*Store) GetUnreadMessages

func (s *Store) GetUnreadMessages(identityID string, channelID *int64, mentionsOnly bool, threadID *int64) ([]domain.Message, error)

GetUnreadMessages returns unread messages for an identity, optionally filtered by channel, mentions, or thread. Advances the read cursor only when no filters are active (a filtered read is partial and shouldn't mark everything as read).

func (*Store) GetUserPermissions

func (s *Store) GetUserPermissions(username string) ([]string, error)

GetUserPermissions returns all permissions for an identity based on their role.

func (*Store) GetWebhooksForChannel added in v0.7.0

func (s *Store) GetWebhooksForChannel(channelID int64) ([]domain.IdentityWebhook, error)

func (*Store) GrantPermission

func (s *Store) GrantPermission(role, permission string) error

GrantPermission grants a permission to a role. If already granted, this is a no-op.

func (*Store) HasPermission

func (s *Store) HasPermission(username, permission string) (bool, error)

HasPermission reports whether an identity has the given permission via their role.

func (*Store) ImportMessage added in v0.3.0

func (s *Store) ImportMessage(channelID int64, identityID string, body string, threadID *int64, mentionIdentityIDs []string, createdAt time.Time) (int64, error)

ImportMessage inserts a message with an explicit created_at timestamp. Used by the backup import to preserve original message timestamps.

func (*Store) IsChannelMember

func (s *Store) IsChannelMember(channelID int64, identityID string) (bool, error)

IsChannelMember returns true if the identity is a member of the channel.

func (*Store) IsEmpty added in v0.3.0

func (s *Store) IsEmpty() (bool, error)

IsEmpty reports whether the identities table has no rows. Used by backup import to prevent importing into a non-empty database.

func (*Store) ListAllChannelsWithMembership

func (s *Store) ListAllChannelsWithMembership(identityID string) ([]domain.ChannelWithMembership, error)

ListAllChannelsWithMembership returns all non-DM channels with membership status for the given identity.

func (*Store) ListAllDMs

func (s *Store) ListAllDMs() ([]domain.AllDMInfo, error)

ListAllDMs returns all DM channels with both participants (admin view).

func (*Store) ListChannelsForUser

func (s *Store) ListChannelsForUser(identityID string) ([]domain.ChannelWithMembership, error)

ListChannelsForUser returns non-DM channels visible to an identity: all public channels plus private channels where the identity is a member. Each result includes whether the identity is a member.

func (*Store) ListDMsForUser

func (s *Store) ListDMsForUser(identityID string) ([]domain.DMInfo, error)

ListDMsForUser returns all DM channels the identity is a member of, with the other participant's info.

func (*Store) ListIdentities added in v0.6.0

func (s *Store) ListIdentities() ([]domain.Identity, error)

func (*Store) ListMentionGroups added in v0.5.0

func (s *Store) ListMentionGroups() ([]domain.MentionGroup, error)

func (*Store) ListRoles

func (s *Store) ListRoles() ([]domain.Role, error)

ListRoles returns all roles ordered by name.

func (*Store) ListSettings

func (s *Store) ListSettings() (map[string]string, error)

ListSettings returns all settings as a map.

func (*Store) MarkRead

func (s *Store) MarkRead(identityID string, channelID int64, messageID *int64) error

MarkRead advances the read cursor for an identity in a channel. If messageID is nil, advances to the latest message. Forward-only: never moves the cursor backwards.

func (*Store) OpenDM

func (s *Store) OpenDM(identityID, otherIdentityID string, otherUsername string) (string, bool, error)

OpenDM finds or creates a DM channel between two identities. Returns the channel name and whether it was newly created.

func (*Store) RegisterWebhook added in v0.7.0

func (s *Store) RegisterWebhook(identityID, url string) (string, error)

func (*Store) RemoveMentionGroupMember added in v0.5.0

func (s *Store) RemoveMentionGroupMember(groupID int64, identityID string) error

func (*Store) RevokePermission

func (s *Store) RevokePermission(role, permission string) error

RevokePermission removes a permission from a role.

func (*Store) SendMessage

func (s *Store) SendMessage(channelID int64, identityID string, body string, threadID *int64, mentionIdentityIDs []string, metadata *string) (int64, error)

SendMessage inserts a message into a channel with optional thread, mentions, and metadata.

func (*Store) SetSetting

func (s *Store) SetSetting(key, value string) error

SetSetting sets a setting key to a value (upsert).

func (*Store) SetUserRole

func (s *Store) SetUserRole(username, role string) error

SetUserRole updates an identity's role. Returns an error if the identity does not exist.

func (*Store) SetUserType

func (s *Store) SetUserType(username, userType string) error

SetUserType updates an identity's type. Returns an error if the identity does not exist.

func (*Store) UnregisterWebhook added in v0.7.0

func (s *Store) UnregisterWebhook(identityID, webhookID string) error

func (*Store) UpsertIdentity added in v0.6.0

func (s *Store) UpsertIdentity(authID, username, displayName, identityType, role string) (*domain.Identity, error)

func (*Store) WipeAll added in v0.3.0

func (s *Store) WipeAll() error

WipeAll deletes all user data, preserving schema and built-in RBAC seeds.

Jump to

Keyboard shortcuts

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