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 ¶
- type Store
- func (s *Store) AddChannelMember(channelID int64, identityID string) error
- func (s *Store) AddMentionGroupMember(groupID int64, identityID string) error
- func (s *Store) ChannelMemberUsernames(channelID int64) ([]string, error)
- func (s *Store) Close() error
- func (s *Store) CreateChannel(name string, public bool, memberIDs []string, channelType string) (int64, error)
- func (s *Store) CreateMentionGroup(slug string, createdByID string) (int64, error)
- func (s *Store) CreateRole(name string) error
- func (s *Store) DeleteMentionGroup(id int64) error
- func (s *Store) DeleteRole(name string) error
- func (s *Store) ExpandMentionGroups(slugs []string) (map[string][]string, error)
- func (s *Store) GetActiveWebhooksForIdentity(identityID string) ([]domain.IdentityWebhook, error)
- func (s *Store) GetChannelByID(id int64) (*domain.Channel, error)
- func (s *Store) GetChannelByName(name string) (*domain.Channel, error)
- func (s *Store) GetIdentityByID(id string) (*domain.Identity, error)
- func (s *Store) GetIdentityByUsername(username string) (*domain.Identity, error)
- func (s *Store) GetMentionGroup(slug string) (*domain.MentionGroup, error)
- func (s *Store) GetMentionGroupMembers(groupID int64) ([]string, 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) GetServiceMemberUsernames(channelID int64) ([]string, error)
- func (s *Store) GetSetting(key string) (string, error)
- func (s *Store) GetUnreadCounts(identityID string) ([]domain.UnreadCount, error)
- func (s *Store) GetUnreadMessages(identityID string, channelID *int64, mentionsOnly bool, threadID *int64) ([]domain.Message, error)
- func (s *Store) GetUserPermissions(username string) ([]string, error)
- func (s *Store) GetWebhooksForChannel(channelID int64) ([]domain.IdentityWebhook, error)
- func (s *Store) GrantPermission(role, permission string) error
- func (s *Store) HasPermission(username, permission string) (bool, error)
- func (s *Store) ImportMessage(channelID int64, identityID string, body string, threadID *int64, ...) (int64, error)
- func (s *Store) IsChannelMember(channelID int64, identityID string) (bool, error)
- func (s *Store) IsEmpty() (bool, error)
- func (s *Store) ListAllChannelsWithMembership(identityID string) ([]domain.ChannelWithMembership, error)
- func (s *Store) ListAllDMs() ([]domain.AllDMInfo, error)
- func (s *Store) ListChannelsForUser(identityID string) ([]domain.ChannelWithMembership, error)
- func (s *Store) ListDMsForUser(identityID string) ([]domain.DMInfo, error)
- func (s *Store) ListIdentities() ([]domain.Identity, error)
- func (s *Store) ListMentionGroups() ([]domain.MentionGroup, error)
- func (s *Store) ListRoles() ([]domain.Role, error)
- func (s *Store) ListSettings() (map[string]string, error)
- func (s *Store) MarkRead(identityID string, channelID int64, messageID *int64) error
- func (s *Store) OpenDM(identityID, otherIdentityID string, otherUsername string) (string, bool, error)
- func (s *Store) RegisterWebhook(identityID, url string) (string, error)
- func (s *Store) RemoveMentionGroupMember(groupID int64, identityID string) error
- func (s *Store) RevokePermission(role, permission string) error
- func (s *Store) SendMessage(channelID int64, identityID string, body string, threadID *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
- func (s *Store) UnregisterWebhook(identityID, webhookID string) error
- func (s *Store) UpsertIdentity(authID, username, displayName, identityType, role string) (*domain.Identity, error)
- func (s *Store) WipeAll() 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 PostgreSQL.
func Open ¶
Open opens a PostgreSQL database and runs migrations. dsn should be a postgres:// or postgresql:// connection string.
func (*Store) AddChannelMember ¶
AddChannelMember adds an identity to a channel.
func (*Store) AddMentionGroupMember ¶ added in v0.5.0
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 []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 (*Store) CreateRole ¶
CreateRole inserts a new custom role.
func (*Store) DeleteMentionGroup ¶ added in v0.5.0
func (*Store) DeleteRole ¶
DeleteRole removes a custom role. Built-in roles cannot be deleted.
func (*Store) ExpandMentionGroups ¶ added in v0.5.0
func (*Store) GetActiveWebhooksForIdentity ¶ added in v0.7.0
func (s *Store) GetActiveWebhooksForIdentity(identityID string) ([]domain.IdentityWebhook, error)
func (*Store) GetChannelByID ¶
GetChannelByID returns a channel by its ID.
func (*Store) GetChannelByName ¶
GetChannelByName returns a channel by its name.
func (*Store) GetIdentityByID ¶ added in v0.6.0
func (*Store) GetIdentityByUsername ¶ added in v0.6.0
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 (*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) GetServiceMemberUsernames ¶ added in v0.7.0
GetServiceMemberUsernames returns usernames of service-type members of a channel.
func (*Store) GetSetting ¶
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).
Concurrency fix: loadMentions runs inside the transaction so that the mention set is consistent with the message snapshot.
func (*Store) GetUserPermissions ¶
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 ¶
GrantPermission grants a permission to a role. If already granted, this is a no-op.
func (*Store) HasPermission ¶
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 ¶
IsChannelMember returns true if the identity is a member of the channel.
func (*Store) IsEmpty ¶ added in v0.3.0
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 ¶
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 ¶
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 (*Store) ListMentionGroups ¶ added in v0.5.0
func (s *Store) ListMentionGroups() ([]domain.MentionGroup, error)
func (*Store) ListSettings ¶
ListSettings returns all settings as a map.
func (*Store) MarkRead ¶
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.
Concurrency: wrapped in a transaction. The unique index on channels(name) with deterministic dm-<lower>-<higher> naming prevents duplicates.
func (*Store) RegisterWebhook ¶ added in v0.7.0
func (*Store) RemoveMentionGroupMember ¶ added in v0.5.0
func (*Store) RevokePermission ¶
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 ¶
SetSetting sets a setting key to a value (upsert).
func (*Store) SetUserRole ¶
SetUserRole updates an identity's role. Returns an error if the identity does not exist.
func (*Store) SetUserType ¶
SetUserType updates an identity's type. Returns an error if the identity does not exist.