Documentation
¶
Overview ¶
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
Index ¶
- type Store
- func (s *Store) AddChannelMember(channelID, userID int64) error
- func (s *Store) ChannelMemberUsernames(channelID int64) ([]string, error)
- func (s *Store) Close() error
- func (s *Store) CreateChannel(name string, public bool, memberIDs []int64, channelType string) (int64, error)
- func (s *Store) CreateRole(name string) error
- func (s *Store) CreateUser(username, password string) (int64, error)
- func (s *Store) DeleteRole(name string) error
- func (s *Store) GetChannelByID(id int64) (*domain.Channel, error)
- func (s *Store) GetChannelByName(name string) (*domain.Channel, error)
- func (s *Store) GetMessages(channelID int64, before *int64, after *int64, limit int, threadID *int64) ([]domain.Message, error)
- func (s *Store) GetRolePermissions(role string) ([]string, error)
- func (s *Store) GetSetting(key string) (string, error)
- func (s *Store) GetUnreadCounts(userID int64) ([]domain.UnreadCount, error)
- func (s *Store) GetUnreadMessages(userID int64, channelID *int64, mentionsOnly bool, threadID *int64) ([]domain.Message, error)
- func (s *Store) GetUserByUsername(username string) (*domain.User, error)
- func (s *Store) GetUserPermissions(username string) ([]string, error)
- func (s *Store) GrantPermission(role, permission string) error
- func (s *Store) HasPermission(username, permission string) (bool, error)
- func (s *Store) IsChannelMember(channelID, userID int64) (bool, error)
- func (s *Store) ListAllChannelsWithMembership(userID int64) ([]domain.ChannelWithMembership, error)
- func (s *Store) ListAllDMs() ([]domain.AllDMInfo, error)
- func (s *Store) ListChannelsForUser(userID int64) ([]domain.ChannelWithMembership, error)
- func (s *Store) ListDMsForUser(userID int64) ([]domain.DMInfo, error)
- func (s *Store) ListRoles() ([]domain.Role, error)
- func (s *Store) ListSettings() (map[string]string, error)
- func (s *Store) ListUsers() ([]domain.User, error)
- func (s *Store) MarkRead(userID, channelID int64, messageID *int64) error
- func (s *Store) OpenDM(userID, otherUserID int64, otherUsername string) (string, bool, error)
- func (s *Store) RevokePermission(role, permission string) error
- func (s *Store) SendMessage(channelID, userID int64, body string, threadID *int64, mentionUserIDs []int64) (int64, error)
- func (s *Store) SetSetting(key, value string) error
- func (s *Store) SetUserRole(username, role string) error
- func (s *Store) SetUserType(username, userType string) error
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 (*Store) AddChannelMember ¶
AddChannelMember adds a user to a channel.
func (*Store) ChannelMemberUsernames ¶
ChannelMemberUsernames returns the usernames of all members of a channel.
func (*Store) CreateChannel ¶
func (s *Store) CreateChannel(name string, public bool, memberIDs []int64, channelType string) (int64, error)
CreateChannel creates a channel with the given members in a transaction. channelType should be "channel" or "dm".
func (*Store) CreateRole ¶
CreateRole inserts a new custom role.
func (*Store) CreateUser ¶
CreateUser inserts a new user and returns its ID.
func (*Store) DeleteRole ¶
DeleteRole removes a custom role. Built-in roles cannot be deleted.
func (*Store) GetChannelByID ¶
GetChannelByID returns a channel by its ID.
func (*Store) GetChannelByName ¶
GetChannelByName returns a channel by its name.
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 ¶
GetRolePermissions returns all permissions granted to a role.
func (*Store) GetSetting ¶
GetSetting returns the value for a setting key.
func (*Store) GetUnreadCounts ¶
func (s *Store) GetUnreadCounts(userID int64) ([]domain.UnreadCount, error)
GetUnreadCounts returns per-channel unread message and mention counts for a user. Only returns channels with >0 unreads. Excludes the user's own messages.
func (*Store) GetUnreadMessages ¶
func (s *Store) GetUnreadMessages(userID int64, channelID *int64, mentionsOnly bool, threadID *int64) ([]domain.Message, error)
GetUnreadMessages returns unread messages for a user, 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) GetUserByUsername ¶
GetUserByUsername returns a user by username.
func (*Store) GetUserPermissions ¶
GetUserPermissions returns all permissions for a user based on their role.
func (*Store) GrantPermission ¶
GrantPermission grants a permission to a role. If already granted, this is a no-op.
func (*Store) HasPermission ¶
HasPermission reports whether a user has the given permission via their role.
func (*Store) IsChannelMember ¶
IsChannelMember returns true if the user is a member of the channel.
func (*Store) ListAllChannelsWithMembership ¶
func (s *Store) ListAllChannelsWithMembership(userID int64) ([]domain.ChannelWithMembership, error)
ListAllChannelsWithMembership returns all non-DM channels with membership status for the given user.
func (*Store) ListAllDMs ¶
ListAllDMs returns all DM channels with both participants (admin view).
func (*Store) ListChannelsForUser ¶
func (s *Store) ListChannelsForUser(userID int64) ([]domain.ChannelWithMembership, error)
ListChannelsForUser returns non-DM channels visible to a user: all public channels plus private channels where the user is a member. Each result includes whether the user is a member.
func (*Store) ListDMsForUser ¶
ListDMsForUser returns all DM channels the user is a member of, with the other participant's info.
func (*Store) ListSettings ¶
ListSettings returns all settings as a map.
func (*Store) MarkRead ¶
MarkRead advances the read cursor for a user in a channel. If messageID is nil, advances to the latest message. Forward-only: never moves the cursor backwards.
func (*Store) OpenDM ¶
OpenDM finds or creates a DM channel between two users. Returns the channel name and whether it was newly created.
func (*Store) RevokePermission ¶
RevokePermission removes a permission from a role.
func (*Store) SendMessage ¶
func (s *Store) SendMessage(channelID, userID int64, body string, threadID *int64, mentionUserIDs []int64) (int64, error)
SendMessage inserts a message into a channel with optional thread and mentions.
func (*Store) SetSetting ¶
SetSetting sets a setting key to a value (upsert).
func (*Store) SetUserRole ¶
SetUserRole updates a user's role. Returns an error if the user does not exist.
func (*Store) SetUserType ¶
SetUserType updates a user's type. Returns an error if the user does not exist.