Documentation
¶
Overview ¶
Package store is the persistence layer: the Store facade, the Driver interface implemented by store/db/{sqlite,mysql,postgres,d1}, migrations, seed data, and the in-memory cache.
Layering: store may import provider, markdown, filter, proto/gen, and internal. It must not import core or server; business rules that need several store calls live in core.
Index ¶
- Constants
- Variables
- func AttachmentNeedsInstanceStorageSetting(attachment *Attachment) bool
- func FindStorage(setting *storepb.InstanceStorageSetting, storageID string) *storepb.Storage
- func GetDefaultStorage(setting *storepb.InstanceStorageSetting) *storepb.Storage
- func MemoAttachmentBindingOwnerAllowed(attachmentCreatorID, memoCreatorID, actorUserID int32, actorIsAdmin bool) bool
- func MemoAttachmentRemovalAllowed(attachment *Attachment, memoID, actorUserID int32, actorIsAdmin bool) bool
- func MemoDeleteActorCanRead(rowStatus RowStatus, visibility Visibility, spaceID *int32, ...) bool
- func NormalizeEmail(email string) (string, error)
- func NormalizeInstanceStorageSetting(setting *storepb.InstanceStorageSetting)
- func NullInt32Pointer(value sql.NullInt64) *int32
- func PrepareInstanceStorageSettingUpdate(incoming, existing *storepb.InstanceStorageSetting) error
- func ResolveStorage(setting *storepb.InstanceStorageSetting, storageID string, ...) (*storepb.Storage, error)
- func StorageNamespaceEqual(a, b *storepb.Storage) bool
- func ValidateAttachmentDeletionMemoSnapshots(memoIDs []int32, expectedMemoContents map[int32]string) error
- func ValidateAttachmentMutationTargets(actorUserID int32, actorIsAdmin bool, attachmentIDs []int32, ...) ([]int32, error)
- func ValidateMemoCommentAuthorization(snapshot *MemoCommentAuthorizationSnapshot) error
- func ValidateMemoRelationDelete(delete *DeleteMemoRelation) error
- func ValidateMemoRelationEndpointRead(snapshot *MemoRelationEndpointSnapshot) error
- func ValidateMemoViewIcon(icon *storepb.MemoViewsUserSetting_MemoView_Icon) error
- func ValidateMemoWriteSnapshot(policy *MemoWritePolicy, update *UpdateMemo, snapshot *MemoWriteSnapshot) error
- func ValidateReactionWithdrawal(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error
- func ValidateReactionWriteParticipation(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error
- func ValidateSpaceIcon(icon *storepb.SpacePayload_Icon) error
- func WithCreateAttachmentPolicyFailpoint(ctx context.Context) context.Context
- func WithCreateAttachmentPostCommitFailpoint(ctx context.Context) context.Context
- func WithDeleteAttachmentStorageFailpoint(ctx context.Context) context.Context
- func WithDeleteUserFailpoint(ctx context.Context, failpoint DeleteUserFailpoint) context.Context
- type AcceptSpaceInvitation
- type Attachment
- type AttachmentDeletionPolicy
- type AuthenticationConfigMutation
- type AuthenticationConfigState
- type DeclineSpaceInvitation
- type DeleteAttachment
- type DeleteIdentityProvider
- type DeleteInbox
- type DeleteInstanceSetting
- type DeleteMemo
- type DeleteMemoRelation
- type DeleteMemoShare
- type DeleteMemoWithPolicy
- type DeleteMemoWithPolicyResult
- type DeleteReaction
- type DeleteSpace
- type DeleteSpaceMember
- type DeleteSpaceResult
- type DeleteUser
- type DeleteUserFailpoint
- type DeleteUserIdentity
- type DeleteUserResult
- type DeleteUserSetting
- type Driver
- type FindAttachment
- type FindIdentityProvider
- type FindInbox
- type FindInstanceSetting
- type FindMemo
- type FindMemoPayload
- type FindMemoRelation
- type FindMemoShare
- type FindReaction
- type FindSpace
- type FindSpaceInvitation
- type FindSpaceMember
- type FindUser
- type FindUserIdentity
- type FindUserSetting
- type IdentityProvider
- type Inbox
- type InboxStatus
- type InstanceSetting
- type Memo
- type MemoAccessScope
- type MemoActorState
- type MemoAttachmentBinding
- type MemoCommentAuthorizationSnapshot
- type MemoMutation
- type MemoRelation
- type MemoRelationEndpointSnapshot
- type MemoRelationType
- type MemoShare
- type MemoWritePolicy
- type MemoWriteSnapshot
- type PATQueryResult
- type Reaction
- type ReactionWritePolicy
- type RefreshTokenQueryResult
- type RevokeSpaceInvitation
- type Role
- type RowStatus
- type Space
- type SpaceInvitation
- type SpaceMember
- type SpaceMemberRole
- type SpaceMemberStatus
- type Store
- func (s *Store) AcceptSpaceInvitation(ctx context.Context, accept *AcceptSpaceInvitation, actorUserID int32) (*SpaceMember, error)
- func (s *Store) AddUserMemoView(ctx context.Context, userID int32, ...) error
- func (s *Store) AddUserPersonalAccessToken(ctx context.Context, userID int32, ...) error
- func (s *Store) AddUserRefreshToken(ctx context.Context, userID int32, ...) error
- func (s *Store) AddUserWebhook(ctx context.Context, userID int32, ...) error
- func (s *Store) AllowsAnonymousAccess(ctx context.Context) (bool, error)
- func (s *Store) ApplyMemoMutation(ctx context.Context, mutation *MemoMutation) error
- func (s *Store) Close() error
- func (s *Store) CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
- func (s *Store) CreateIdentityProvider(ctx context.Context, create *storepb.IdentityProvider) (*storepb.IdentityProvider, error)
- func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
- func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
- func (s *Store) CreateMemoComment(ctx context.Context, create *Memo, contextMemoID, actorUserID int32) (*Memo, error)
- func (s *Store) CreateMemoShare(ctx context.Context, create *MemoShare) (*MemoShare, error)
- func (s *Store) CreateSpace(ctx context.Context, create *Space, creatorID int32) (*Space, error)
- func (s *Store) CreateSpaceInvitation(ctx context.Context, create *SpaceInvitation, actorUserID int32) (*SpaceInvitation, error)
- func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error)
- func (s *Store) CreateUserIdentity(ctx context.Context, create *UserIdentity) (*UserIdentity, error)
- func (s *Store) CreateUserIfNoUsers(ctx context.Context, create *User) (*User, bool, error)
- func (s *Store) CreateUserWithIdentity(ctx context.Context, createUser *User, createIdentity *UserIdentity) (*User, error)
- func (s *Store) DeclineSpaceInvitation(ctx context.Context, decline *DeclineSpaceInvitation, actorUserID int32) error
- func (s *Store) DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error
- func (s *Store) DeleteAttachmentStorage(ctx context.Context, attachment *Attachment) error
- func (s *Store) DeleteAttachmentStorageWithInstanceSetting(ctx context.Context, attachment *Attachment, ...) error
- func (s *Store) DeleteAttachments(ctx context.Context, attachments []*Attachment) error
- func (s *Store) DeleteAttachmentsWithPolicy(ctx context.Context, policy *AttachmentDeletionPolicy, attachmentIDs []int32) error
- func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
- func (s *Store) DeleteIdentityProviderSafely(ctx context.Context, delete *DeleteIdentityProvider) error
- func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error
- func (s *Store) DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error
- func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error
- func (s *Store) DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
- func (s *Store) DeleteMemoShare(ctx context.Context, delete *DeleteMemoShare) error
- func (s *Store) DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error)
- func (s *Store) DeleteReaction(ctx context.Context, delete *DeleteReaction) error
- func (s *Store) DeleteSpace(ctx context.Context, delete *DeleteSpace) (*DeleteSpaceResult, error)
- func (s *Store) DeleteSpaceMember(ctx context.Context, delete *DeleteSpaceMember, actorUserID int32) error
- func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error)
- func (s *Store) DeleteUserIdentities(ctx context.Context, delete *DeleteUserIdentity) error
- func (s *Store) DeleteUserSettings(ctx context.Context, delete *DeleteUserSetting) error
- func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)
- func (s *Store) GetAttachmentStorageUsage(ctx context.Context, creatorID int32) (int64, error)
- func (s *Store) GetCurrentSchemaVersion() (string, error)
- func (s *Store) GetDataDir() string
- func (s *Store) GetDriver() Driver
- func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
- func (s *Store) GetInstanceAISetting(ctx context.Context) (*storepb.InstanceAISetting, error)
- func (s *Store) GetInstanceAccessSetting(ctx context.Context) (*storepb.InstanceAccessSetting, error)
- func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error)
- func (s *Store) GetInstanceGeneralSetting(ctx context.Context) (*storepb.InstanceGeneralSetting, error)
- func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error)
- func (s *Store) GetInstanceNotificationSetting(ctx context.Context) (*storepb.InstanceNotificationSetting, error)
- func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error)
- func (s *Store) GetInstanceTagsSetting(ctx context.Context) (*storepb.InstanceTagsSetting, error)
- func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error)
- func (s *Store) GetMemoShare(ctx context.Context, find *FindMemoShare) (*MemoShare, error)
- func (s *Store) GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)
- func (s *Store) GetSpace(ctx context.Context, find *FindSpace) (*Space, error)
- func (s *Store) GetSpaceInvitation(ctx context.Context, find *FindSpaceInvitation) (*SpaceInvitation, error)
- func (s *Store) GetSpaceMember(ctx context.Context, find *FindSpaceMember) (*SpaceMember, error)
- func (s *Store) GetStoredIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
- func (s *Store) GetStoredInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error)
- func (s *Store) GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)
- func (s *Store) GetUserIdentity(ctx context.Context, find *FindUserIdentity) (*UserIdentity, error)
- func (s *Store) GetUserMemoViews(ctx context.Context, userID int32) ([]*storepb.MemoViewsUserSetting_MemoView, error)
- func (s *Store) GetUserPersonalAccessTokens(ctx context.Context, userID int32) ([]*storepb.PersonalAccessTokensUserSetting_PersonalAccessToken, error)
- func (s *Store) GetUserRefreshTokenByID(ctx context.Context, userID int32, tokenID string) (*storepb.RefreshTokensUserSetting_RefreshToken, error)
- func (s *Store) GetUserRefreshTokens(ctx context.Context, userID int32) ([]*storepb.RefreshTokensUserSetting_RefreshToken, error)
- func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)
- func (s *Store) GetUserWebhooks(ctx context.Context, userID int32) ([]*storepb.WebhooksUserSetting_Webhook, error)
- func (s *Store) IsIdentityProviderDeploymentConfigured(uid string) bool
- func (s *Store) IsInstanceSettingDeploymentConfigured(key storepb.InstanceSettingKey) bool
- func (s *Store) ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
- func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*storepb.IdentityProvider, error)
- func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
- func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error)
- func (s *Store) ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
- func (s *Store) ListMemoShares(ctx context.Context, find *FindMemoShare) ([]*MemoShare, error)
- func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
- func (s *Store) ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
- func (s *Store) ListSpaceInvitations(ctx context.Context, find *FindSpaceInvitation) ([]*SpaceInvitation, error)
- func (s *Store) ListSpaceMembers(ctx context.Context, find *FindSpaceMember) ([]*SpaceMember, error)
- func (s *Store) ListSpaces(ctx context.Context, find *FindSpace) ([]*Space, error)
- func (s *Store) ListUserIdentities(ctx context.Context, find *FindUserIdentity) ([]*UserIdentity, error)
- func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)
- func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
- func (s *Store) LoadDeploymentConfiguration(ctx context.Context) error
- func (s *Store) LoadDeploymentConfigurationDir(ctx context.Context, dir string) error
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) RemoveUserMemoView(ctx context.Context, userID int32, memoViewID string) (bool, error)
- func (s *Store) RemoveUserPersonalAccessToken(ctx context.Context, userID int32, tokenID string) error
- func (s *Store) RemoveUserRefreshToken(ctx context.Context, userID int32, tokenID string) error
- func (s *Store) RemoveUserRefreshTokensExcept(ctx context.Context, userID int32, keepTokenID string) error
- func (s *Store) RemoveUserWebhook(ctx context.Context, userID int32, webhookID string) error
- func (s *Store) ResolveAttachmentS3Driver(ctx context.Context, attachment *Attachment) (storage.Driver, *storepb.AttachmentPayload_S3Object, error)
- func (s *Store) ResolveStorageDriver(ctx context.Context, setting *storepb.InstanceStorageSetting, storageID string, ...) (storage.Driver, error)
- func (s *Store) RevokeSpaceInvitation(ctx context.Context, revoke *RevokeSpaceInvitation, actorUserID int32) error
- func (s *Store) StorageDriver(ctx context.Context, resolvedStorage *storepb.Storage) (storage.Driver, error)
- func (s *Store) UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
- func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProviderV1) (*storepb.IdentityProvider, error)
- func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
- func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error
- func (s *Store) UpdatePATLastUsed(ctx context.Context, userID int32, tokenID string, ...) error
- func (s *Store) UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserID int32) (*Space, error)
- func (s *Store) UpdateSpaceMember(ctx context.Context, update *UpdateSpaceMember, actorUserID int32) (*SpaceMember, error)
- func (s *Store) UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
- func (s *Store) UpdateUserMemoView(ctx context.Context, userID int32, memoViewID string, title *string, ...) (*storepb.MemoViewsUserSetting_MemoView, error)
- func (s *Store) UpdateUserWebhook(ctx context.Context, userID int32, ...) error
- func (s *Store) UpsertInstanceGeneralSettingSafely(ctx context.Context, setting *storepb.InstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error)
- func (s *Store) UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
- func (s *Store) UpsertReaction(ctx context.Context, upsert *Reaction) (*Reaction, error)
- func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
- type UpdateAttachment
- type UpdateIdentityProvider
- type UpdateIdentityProviderV1
- type UpdateInbox
- type UpdateMemo
- type UpdateSpace
- type UpdateSpaceMember
- type UpdateUser
- type User
- type UserIdentity
- type UserSetting
- type Visibility
Constants ¶
const ( // MigrateFileNameSplit is the split character between the patch version and the description in the migration file name. // For example, "1__create_table.sql". MigrateFileNameSplit = "__" // LatestSchemaFileName is the name of the latest schema file. // This file is used to initialize fresh installations with the current schema. LatestSchemaFileName = "LATEST.sql" )
const DefaultContentLengthLimit = 8 * 1024
DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.
const (
// DefaultDeploymentConfigurationDir is the directory scanned for runtime configuration files.
DefaultDeploymentConfigurationDir = "/etc/secrets"
)
Variables ¶
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}
DefaultReactions is the default reactions for memo related setting.
var ErrCreateAttachmentPostCommitFailpoint = errors.New("create attachment post-commit failpoint")
ErrCreateAttachmentPostCommitFailpoint is returned after the test-only attachment create failpoint persists a row.
var ErrDeleteAttachmentStorageFailpoint = errors.New("delete attachment storage failpoint")
ErrDeleteAttachmentStorageFailpoint is returned by the test-only attachment storage failpoint.
var ErrEmailTaken = stderrors.New("email is already in use")
ErrEmailTaken reports that another user already holds the email address.
var ErrLastSpaceAdmin = errors.New("cannot remove the last space admin")
ErrLastSpaceAdmin indicates that a membership mutation would leave an active space without an administrator.
var ErrMemoMutationConflict = errors.New("memo state changed")
ErrMemoMutationConflict indicates that memo or attachment state changed after an API request prepared its mutation.
var ErrMemoPermissionDenied = errors.New("memo mutation permission denied")
ErrMemoPermissionDenied indicates that the actor no longer owns the memo being mutated.
ErrMemoShareConflict indicates that an active share conflicts with a SPACE audience transition.
var ErrMemoSpaceMembershipRequired = errors.New("active space membership required")
ErrMemoSpaceMembershipRequired indicates that the memo creator is not an active member of its assigned space.
var ErrMemoSpaceNotWritable = errors.New("memo space is not writable")
ErrMemoSpaceNotWritable indicates that a memo targets a missing or otherwise invalid Space.
var ErrReactionMemoNotFound = stderrors.New("reaction memo not found")
ErrReactionMemoNotFound indicates that a reaction's memo no longer exists.
var ErrReactionPermissionDenied = stderrors.New("reaction mutation permission denied")
ErrReactionPermissionDenied indicates that an actor cannot mutate the reaction.
var ErrSpaceAlreadyExists = errors.New("space already exists")
ErrSpaceAlreadyExists indicates a duplicate immutable space ID.
var ErrSpaceInvitationNotFound = errors.New("space invitation not found")
ErrSpaceInvitationNotFound indicates a missing pending invitation.
var ErrSpaceMemberAlreadyExists = errors.New("space member already exists")
ErrSpaceMemberAlreadyExists indicates an existing membership or invitation.
var ErrSpaceMemberNotActive = errors.New("space member user is not active")
ErrSpaceMemberNotActive indicates that a membership target is not an active user.
var ErrSpaceMemberNotFound = errors.New("space member not found")
ErrSpaceMemberNotFound indicates a missing membership mutation target.
var ErrSpaceNotFound = errors.New("space not found")
ErrSpaceNotFound indicates a missing mutation target.
var ErrSpacePermissionDenied = errors.New("space permission denied")
ErrSpacePermissionDenied indicates that the actor cannot perform a space mutation.
var ErrUnsafeAuthenticationConfiguration = errors.New("password authentication for regular users cannot be disabled without an effective identity provider")
ErrUnsafeAuthenticationConfiguration indicates a mutation would lock regular users out.
var ErrUserHasSpaceMembership = stderrors.New("user still has space memberships")
ErrUserHasSpaceMembership blocks account deletion until its Space lifecycle has been resolved explicitly.
var ErrUserIdentityTaken = stderrors.New("user identity is already linked")
ErrUserIdentityTaken reports that an external identity linkage already exists, either for the same (provider, extern_uid) pair or for the same (user, provider) pair.
var ErrUsernameTaken = stderrors.New("username is already in use")
ErrUsernameTaken reports that another user already holds the username.
Functions ¶
func AttachmentNeedsInstanceStorageSetting ¶ added in v0.29.0
func AttachmentNeedsInstanceStorageSetting(attachment *Attachment) bool
AttachmentNeedsInstanceStorageSetting reports whether cleanup should load the configured storage registry for an S3 attachment.
func FindStorage ¶ added in v0.14.0
func FindStorage(setting *storepb.InstanceStorageSetting, storageID string) *storepb.Storage
FindStorage returns the configured storage with the given stable identifier.
func GetDefaultStorage ¶ added in v0.31.0
func GetDefaultStorage(setting *storepb.InstanceStorageSetting) *storepb.Storage
GetDefaultStorage returns the storage used for new attachments.
func MemoAttachmentBindingOwnerAllowed ¶ added in v0.31.0
func MemoAttachmentBindingOwnerAllowed(attachmentCreatorID, memoCreatorID, actorUserID int32, actorIsAdmin bool) bool
MemoAttachmentBindingOwnerAllowed reports whether an unbound attachment may be bound to a memo: it must be owned by the memo author, or by the acting instance administrator. Ownership is never transferred between accounts.
func MemoAttachmentRemovalAllowed ¶ added in v0.31.0
func MemoAttachmentRemovalAllowed(attachment *Attachment, memoID, actorUserID int32, actorIsAdmin bool) bool
MemoAttachmentRemovalAllowed reports whether an attachment may be removed from a memo. Removal deletes the attachment, so it must be bound to that memo and owned by the actor unless the actor is an instance administrator.
func MemoDeleteActorCanRead ¶ added in v0.31.0
func MemoDeleteActorCanRead(rowStatus RowStatus, visibility Visibility, spaceID *int32, spaceExists, actorMember bool) bool
MemoDeleteActorCanRead applies the memo-local audience matrix after the deletion transaction has established that the actor is the active author or an instance administrator, who counts as a member everywhere. Invalid lifecycle or audience state fails closed. Placement validity matters only for the Space audience; it is not an extra read gate for other values.
func NormalizeEmail ¶ added in v0.31.0
NormalizeEmail validates an email address and returns its canonical stored form: surrounding whitespace removed and every character lowercased. An empty input (after trimming) is valid and returns "", meaning no address.
Display-name forms such as "Alice <alice@example.com>" are rejected even though the mail parser accepts them, because the stored value must be the bare address. The local part is lowercased along with the domain: every mainstream provider treats it case-insensitively, and folding both halves is what makes the instance-wide uniqueness rule match what users expect.
func NormalizeInstanceStorageSetting ¶ added in v0.31.0
func NormalizeInstanceStorageSetting(setting *storepb.InstanceStorageSetting)
NormalizeInstanceStorageSetting populates the named storage model from legacy fields and keeps the legacy fields synchronized for older clients.
func NullInt32Pointer ¶ added in v0.31.0
NullInt32Pointer converts a nullable SQL integer to an optional int32.
func PrepareInstanceStorageSettingUpdate ¶ added in v0.31.0
func PrepareInstanceStorageSettingUpdate(incoming, existing *storepb.InstanceStorageSetting) error
PrepareInstanceStorageSettingUpdate preserves storages still referenced by existing attachments and assigns a new identity when a physical namespace changes.
func ResolveStorage ¶ added in v0.31.0
func ResolveStorage( setting *storepb.InstanceStorageSetting, storageID string, legacyS3Config *storepb.StorageS3Config, ) (*storepb.Storage, error)
ResolveStorage resolves the configured storage referenced by an attachment. It returns a registry entry when one matches — its Id is the stable identity — or a synthesized storage wrapping the legacy config otherwise (empty Id). legacyS3Config supports attachments written before storage IDs were introduced.
func StorageNamespaceEqual ¶ added in v0.31.0
StorageNamespaceEqual reports whether two configurations address the same physical storage namespace. Credentials and transport options are deliberately excluded so they can be rotated without changing storage identity.
func ValidateAttachmentDeletionMemoSnapshots ¶ added in v0.31.0
func ValidateAttachmentDeletionMemoSnapshots(memoIDs []int32, expectedMemoContents map[int32]string) error
ValidateAttachmentDeletionMemoSnapshots requires exactly one expected content snapshot for every memo currently bound to the selected attachments.
func ValidateAttachmentMutationTargets ¶ added in v0.31.0
func ValidateAttachmentMutationTargets(actorUserID int32, actorIsAdmin bool, attachmentIDs []int32, attachments []*Attachment) ([]int32, error)
ValidateAttachmentMutationTargets verifies attachment rows used by a transport-facing mutation and returns their distinct memo bindings in ascending order. Every attachment must be owned by the actor unless the actor is an instance administrator.
func ValidateMemoCommentAuthorization ¶ added in v0.31.0
func ValidateMemoCommentAuthorization(snapshot *MemoCommentAuthorizationSnapshot) error
ValidateMemoCommentAuthorization validates participation in the context memo. The replying memo is authorized independently by the normal memo-create policy; no placement or audience is inherited from this snapshot.
func ValidateMemoRelationDelete ¶ added in v0.31.0
func ValidateMemoRelationDelete(delete *DeleteMemoRelation) error
ValidateMemoRelationDelete ensures the generic deletion path can only mutate reference relations. COMMENT relations are immutable context and are removed only as part of the lifecycle of an incident memo.
func ValidateMemoRelationEndpointRead ¶ added in v0.31.0
func ValidateMemoRelationEndpointRead(snapshot *MemoRelationEndpointSnapshot) error
ValidateMemoRelationEndpointRead applies authenticated memo-local read policy to an endpoint. An active instance administrator passes the audience checks; structural validity still applies.
func ValidateMemoViewIcon ¶ added in v0.31.0
func ValidateMemoViewIcon(icon *storepb.MemoViewsUserSetting_MemoView_Icon) error
ValidateMemoViewIcon validates optional display metadata for a saved view.
func ValidateMemoWriteSnapshot ¶ added in v0.31.0
func ValidateMemoWriteSnapshot(policy *MemoWritePolicy, update *UpdateMemo, snapshot *MemoWriteSnapshot) error
ValidateMemoWriteSnapshot applies the transport-independent write invariants to current database state.
func ValidateReactionWithdrawal ¶ added in v0.31.0
func ValidateReactionWithdrawal(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error
ValidateReactionWithdrawal allows an active actor to withdraw their own reaction without requiring continued access to or participation in the memo. The driver also verifies ownership of the stored reaction in the same transaction.
func ValidateReactionWriteParticipation ¶ added in v0.31.0
func ValidateReactionWriteParticipation(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error
ValidateReactionWriteParticipation applies the reaction actor identity and memo-local participation rules to state loaded by the write transaction.
func ValidateSpaceIcon ¶ added in v0.31.0
func ValidateSpaceIcon(icon *storepb.SpacePayload_Icon) error
ValidateSpaceIcon validates display metadata without depending on a client's installed Lucide catalog. A nil icon requests the default Space mark.
func WithCreateAttachmentPolicyFailpoint ¶ added in v0.31.0
WithCreateAttachmentPolicyFailpoint forces a policy-bearing attachment create to fail before its database insert.
func WithCreateAttachmentPostCommitFailpoint ¶ added in v0.31.0
WithCreateAttachmentPostCommitFailpoint forces CreateAttachment to return an error after its database insert succeeds.
func WithDeleteAttachmentStorageFailpoint ¶ added in v0.28.0
WithDeleteAttachmentStorageFailpoint forces DeleteAttachmentStorage to return a failpoint error.
func WithDeleteUserFailpoint ¶ added in v0.28.0
func WithDeleteUserFailpoint(ctx context.Context, failpoint DeleteUserFailpoint) context.Context
WithDeleteUserFailpoint is a test-only helper that forces DeleteUser to roll back.
Types ¶
type AcceptSpaceInvitation ¶ added in v0.31.0
AcceptSpaceInvitation identifies an invitation accepted by its invitee.
type Attachment ¶ added in v0.25.0
type Attachment struct {
// ID is the system generated unique identifier for the attachment.
ID int32
// UID is the user defined unique identifier for the attachment.
UID string
// Standard fields
CreatorID int32
CreatedTs int64
UpdatedTs int64
// Domain specific fields
Filename string
Blob []byte
Type string
Size int64
StorageType storepb.AttachmentStorageType
Reference string
Payload *storepb.AttachmentPayload
// The related memo ID.
MemoID *int32
// Policy is present for transport-facing direct-link mutations. Drivers
// revalidate it in the same transaction as the attachment insert.
Policy *MemoWritePolicy
// Composed field
MemoUID *string
}
type AttachmentDeletionPolicy ¶ added in v0.31.0
AttachmentDeletionPolicy captures the caller and the memo content observed while validating a transport-facing attachment deletion. Drivers compare the snapshots with current memo state in the deletion transaction.
type AuthenticationConfigMutation ¶ added in v0.30.0
type AuthenticationConfigMutation struct {
UpsertGeneralSetting *InstanceSetting
DeleteIdentityProviderID *int32
Validate func(*AuthenticationConfigState) error
}
AuthenticationConfigMutation validates and applies one stored authentication mutation atomically.
type AuthenticationConfigState ¶ added in v0.30.0
type AuthenticationConfigState struct {
GeneralSetting *InstanceSetting
IdentityProviders []*IdentityProvider
}
AuthenticationConfigState is the stored authentication configuration read inside a transaction.
type DeclineSpaceInvitation ¶ added in v0.31.0
DeclineSpaceInvitation identifies an invitation declined by its invitee.
type DeleteAttachment ¶ added in v0.25.0
type DeleteIdentityProvider ¶ added in v0.13.2
type DeleteIdentityProvider struct {
ID int32
}
type DeleteInbox ¶ added in v0.17.0
type DeleteInbox struct {
ID int32
}
DeleteInbox specifies which inbox item to delete.
type DeleteInstanceSetting ¶ added in v0.25.3
type DeleteInstanceSetting struct {
Name string
}
type DeleteMemo ¶ added in v0.14.0
type DeleteMemo struct {
ID int32
}
type DeleteMemoRelation ¶ added in v0.14.0
type DeleteMemoRelation struct {
MemoID *int32
RelatedMemoID *int32
Type *MemoRelationType
}
type DeleteMemoShare ¶ added in v0.27.0
type DeleteMemoShare struct {
// the same transaction as the delete.
Policy *MemoWritePolicy
}
DeleteMemoShare identifies a share grant to remove.
type DeleteMemoWithPolicy ¶ added in v0.31.0
DeleteMemoWithPolicy identifies one memo to delete atomically on behalf of its author or an instance administrator. Relations do not confer lifecycle authority, so no related memo is deleted.
type DeleteMemoWithPolicyResult ¶ added in v0.31.0
type DeleteMemoWithPolicyResult struct {
ActorCanRead bool
Attachments []*Attachment
}
DeleteMemoWithPolicyResult contains authorization state captured by the deletion transaction.
type DeleteReaction ¶ added in v0.20.0
type DeleteReaction struct {
ID *int32
MemoID *int32
ActorUserID *int32
// Policy is required for transport-facing participation mutations. It is
// revalidated in the same transaction before the reaction row is deleted.
Policy *ReactionWritePolicy
}
type DeleteSpace ¶ added in v0.31.0
DeleteSpace identifies a Space to hard-delete.
type DeleteSpaceMember ¶ added in v0.31.0
DeleteSpaceMember identifies a membership to delete.
type DeleteSpaceResult ¶ added in v0.31.0
type DeleteSpaceResult struct {
Attachments []*Attachment
}
DeleteSpaceResult contains external resources to clean after commit.
type DeleteUser ¶ added in v0.14.0
type DeleteUser struct {
ID int32
}
type DeleteUserFailpoint ¶ added in v0.28.0
type DeleteUserFailpoint string
DeleteUserFailpoint is a test-only hook for forcing a delete-user rollback.
const ( // DeleteUserFailpointBeforeCommit aborts after all delete statements run but before commit. DeleteUserFailpointBeforeCommit DeleteUserFailpoint = "before_commit" )
func GetDeleteUserFailpoint ¶ added in v0.29.0
func GetDeleteUserFailpoint(ctx context.Context) DeleteUserFailpoint
GetDeleteUserFailpoint returns the delete-user failpoint attached to ctx, if any.
type DeleteUserIdentity ¶ added in v0.28.0
DeleteUserIdentity is used to delete user identity linkage rows.
type DeleteUserResult ¶ added in v0.29.0
type DeleteUserResult struct {
Attachments []*Attachment
UserSettingKeys []storepb.UserSetting_Key
}
DeleteUserResult contains resources collected while deleting a user.
type DeleteUserSetting ¶ added in v0.28.0
type DeleteUserSetting struct {
UserID *int32
Key storepb.UserSetting_Key
}
type Driver ¶ added in v0.16.0
type Driver interface {
GetDB() *sql.DB
Close() error
IsInitialized(ctx context.Context) (bool, error)
// GetDatabaseSize returns the database size in bytes, or -1 if unavailable.
// A non-nil error indicates a hard failure; -1 with nil error means the
// driver cannot report a size from the underlying database.
GetDatabaseSize(ctx context.Context) (int64, error)
// Attachment model related methods.
CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
GetAttachmentStorageUsage(ctx context.Context, creatorID int32) (int64, error)
UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error
DeleteAttachments(ctx context.Context, deletes []*DeleteAttachment) error
DeleteAttachmentsWithPolicy(ctx context.Context, policy *AttachmentDeletionPolicy, attachmentIDs []int32) error
ApplyMemoMutation(ctx context.Context, mutation *MemoMutation) error
// Memo model related methods.
CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
UpdateMemo(ctx context.Context, update *UpdateMemo) error
DeleteMemo(ctx context.Context, delete *DeleteMemo) error
DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error)
// Space model related methods.
CreateSpace(ctx context.Context, create *Space, creatorID int32) (*Space, error)
ListSpaces(ctx context.Context, find *FindSpace) ([]*Space, error)
UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserID int32) (*Space, error)
DeleteSpace(ctx context.Context, delete *DeleteSpace) (*DeleteSpaceResult, error)
ListSpaceMembers(ctx context.Context, find *FindSpaceMember) ([]*SpaceMember, error)
UpdateSpaceMember(ctx context.Context, update *UpdateSpaceMember, actorUserID int32) (*SpaceMember, error)
DeleteSpaceMember(ctx context.Context, delete *DeleteSpaceMember, actorUserID int32) error
CreateSpaceInvitation(ctx context.Context, create *SpaceInvitation, actorUserID int32) (*SpaceInvitation, error)
ListSpaceInvitations(ctx context.Context, find *FindSpaceInvitation) ([]*SpaceInvitation, error)
AcceptSpaceInvitation(ctx context.Context, accept *AcceptSpaceInvitation, actorUserID int32) (*SpaceMember, error)
DeclineSpaceInvitation(ctx context.Context, decline *DeclineSpaceInvitation, actorUserID int32) error
RevokeSpaceInvitation(ctx context.Context, revoke *RevokeSpaceInvitation, actorUserID int32) error
// MemoRelation model related methods.
UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
// InstanceSetting model related methods.
// CreateInstanceSettingIfNotExists atomically creates the setting when its name is absent and reports whether it inserted the row.
CreateInstanceSettingIfNotExists(ctx context.Context, create *InstanceSetting) (bool, error)
UpsertInstanceSetting(ctx context.Context, upsert *InstanceSetting) (*InstanceSetting, error)
ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*InstanceSetting, error)
DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error
// User model related methods.
CreateUser(ctx context.Context, create *User) (*User, error)
UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error)
// UserSetting model related methods.
UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error)
ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error)
DeleteUserSettings(ctx context.Context, delete *DeleteUserSetting) error
GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)
// IdentityProvider model related methods.
CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProvider) (*IdentityProvider, error)
DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
ApplyAuthenticationConfigMutation(ctx context.Context, mutation *AuthenticationConfigMutation) error
IsRetryableAuthenticationMutationError(err error) bool
// Inbox model related methods.
CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
DeleteInbox(ctx context.Context, delete *DeleteInbox) error
// Reaction model related methods.
UpsertReaction(ctx context.Context, create *Reaction) (*Reaction, error)
ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)
DeleteReaction(ctx context.Context, delete *DeleteReaction) error
// MemoShare model related methods.
// UserIdentity model related methods.
CreateUserIdentity(ctx context.Context, create *UserIdentity) (*UserIdentity, error)
CreateUserWithIdentity(ctx context.Context, createUser *User, createIdentity *UserIdentity) (*User, error)
ListUserIdentities(ctx context.Context, find *FindUserIdentity) ([]*UserIdentity, error)
DeleteUserIdentities(ctx context.Context, delete *DeleteUserIdentity) error
}
Driver is an interface for store driver. It contains all methods that store database driver should implement.
type FindAttachment ¶ added in v0.25.0
type FindAttachment struct {
GetBlob bool
ID *int32
UID *string
CreatorID *int32
Filename *string
FilenameSearch *string
MemoID *int32
MemoIDList []int32
HasRelatedMemo bool
Filters []string
// Access applies memo-local authorization to linked attachments
// before pagination. Unlinked attachments are visible only to the active
// matching creator. Nil is reserved for trusted internal callers.
Access *MemoAccessScope
Limit *int
Offset *int
SkipDefaultLimit bool
}
type FindIdentityProvider ¶ added in v0.13.2
type FindInbox ¶ added in v0.17.0
type FindInbox struct {
ID *int32
SenderID *int32
ReceiverID *int32
Status *InboxStatus
MessageType *storepb.InboxMessage_Type
// Pagination
Limit *int
Offset *int
}
FindInbox specifies filter criteria for querying inbox items.
type FindInstanceSetting ¶ added in v0.25.3
type FindInstanceSetting struct {
Name string
}
type FindMemo ¶ added in v0.14.0
type FindMemo struct {
ID *int32
UID *string
IDList []int32
UIDList []string
// Standard fields
RowStatus *RowStatus
CreatorID *int32
// Domain specific fields
VisibilityList []Visibility
CommentContextMemoID *int32
Access *MemoAccessScope
ExcludeContent bool
ExcludeComments bool
Filters []string
// Pagination
Limit *int
Offset *int
// Ordering
OrderByPinned bool
OrderByUpdatedTs bool
OrderByTimeAsc bool
}
type FindMemoPayload ¶ added in v0.22.0
type FindMemoRelation ¶ added in v0.14.0
type FindMemoRelation struct {
MemoID *int32
RelatedMemoID *int32
Type *MemoRelationType
MemoFilter *string
// SourceMemoRowStatus filters the relation source memo before pagination.
SourceMemoRowStatus *RowStatus
// MemoIDList matches relations where memo_id OR related_memo_id is in the list.
MemoIDList []int32
// SourceMemoIDList matches relations where memo_id is in the list.
SourceMemoIDList []int32
// RelatedMemoIDList matches relations where related_memo_id is in the list.
RelatedMemoIDList []int32
Limit *int
Offset *int
}
type FindMemoShare ¶ added in v0.27.0
type FindMemoShare struct {
}
FindMemoShare is used to filter memo shares in list/get queries.
type FindReaction ¶ added in v0.20.0
type FindSpace ¶ added in v0.31.0
type FindSpace struct {
ID *int32
IDList []int32
UID *string
MemberUserID *int32
Limit *int
Offset *int
}
FindSpace selects spaces. MemberUserID restricts results to spaces where the user has a membership, populates the viewer summary, and is applied before pagination.
type FindSpaceInvitation ¶ added in v0.31.0
type FindSpaceInvitation struct {
SpaceID *int32
UserID *int32
ViewerUserID *int32
Limit *int
Offset *int
}
FindSpaceInvitation selects pending invitations. ViewerUserID restricts results to invitations visible to that user: their own or those in a space they actively administer.
type FindSpaceMember ¶ added in v0.31.0
type FindSpaceMember struct {
SpaceID *int32
UserID *int32
ViewerUserID *int32
Limit *int
Offset *int
}
FindSpaceMember selects memberships.
type FindUser ¶ added in v0.14.0
type FindUser struct {
ID *int32
IDList []int32
UsernameList []string
RowStatus *RowStatus
Username *string
Role *Role
Email *string
Nickname *string
Search *string
// Domain specific fields
Filters []string
// The maximum number of users to return.
Limit *int
// The offset of the returned users.
Offset *int
}
type FindUserIdentity ¶ added in v0.28.0
FindUserIdentity is used to filter user identities in list/get queries.
type FindUserSetting ¶ added in v0.13.2
type FindUserSetting struct {
UserID *int32
Key storepb.UserSetting_Key
}
type IdentityProvider ¶ added in v0.13.2
type Inbox ¶ added in v0.17.0
type Inbox struct {
ID int32
CreatedTs int64
SenderID int32 // The user who triggered the notification
ReceiverID int32 // The user who receives the notification
Status InboxStatus // Current status (unread/archived)
Message *storepb.InboxMessage // The notification message content
}
Inbox represents a notification in a user's inbox.
type InboxStatus ¶ added in v0.17.0
type InboxStatus string
InboxStatus represents the status of an inbox notification.
const ( // UNREAD indicates the notification has not been read by the user. UNREAD InboxStatus = "UNREAD" // ARCHIVED indicates the notification has been archived/dismissed by the user. ARCHIVED InboxStatus = "ARCHIVED" )
func (InboxStatus) String ¶ added in v0.17.0
func (s InboxStatus) String() string
type InstanceSetting ¶ added in v0.25.3
type Memo ¶ added in v0.14.0
type Memo struct {
// ID is the system generated unique identifier for the memo.
ID int32
// UID is the user defined unique identifier for the memo.
UID string
// Standard fields
RowStatus RowStatus
CreatorID int32
CreatedTs int64
UpdatedTs int64
// Domain specific fields
Content string
Visibility Visibility
Pinned bool
Payload *storepb.MemoPayload
SpaceID *int32
// Composed fields
ParentUID *string
}
type MemoAccessScope ¶ added in v0.31.0
MemoAccessScope is a typed, fail-closed read authorization predicate. When present on FindMemo, drivers apply it in SQL before pagination.
type MemoActorState ¶ added in v0.31.0
MemoActorState is the actor's user row state as read inside a mutation transaction. Admin marks an active instance administrator; see access.IsInstanceAdmin for what that grants. A missing user is the zero value.
func NewMemoActorState ¶ added in v0.31.0
func NewMemoActorState(rowStatus RowStatus, role Role) MemoActorState
NewMemoActorState derives the actor state from a user row. An archived administrator is neither active nor privileged.
type MemoAttachmentBinding ¶ added in v0.31.0
MemoAttachmentBinding describes one attachment that should be bound to a memo. WasBoundToMemo distinguishes an existing binding from a new one so the driver can reject ownership transfers while preserving legacy rows already attached to the memo. A new binding must be owned by the memo author, or by the acting instance administrator.
type MemoCommentAuthorizationSnapshot ¶ added in v0.31.0
type MemoCommentAuthorizationSnapshot struct {
ActorUserID int32
Actor MemoActorState
ContextID int32
ContextCreatorID int32
ContextRowStatus RowStatus
ContextVisibility Visibility
ContextSpaceID *int32
ContextSpaceExists bool
ContextMemberActive bool
}
MemoCommentAuthorizationSnapshot is the memo-local database state read by a driver before it creates an immutable COMMENT relation.
type MemoMutation ¶ added in v0.31.0
type MemoMutation struct {
// MemoCreate requests that the memo row be created in this same transaction
// before attachments and relations are applied. CommentContextMemoID creates
// one immutable COMMENT relation from the new memo to the named context memo.
MemoCreate *Memo
CommentContextMemoID *int32
MemoID int32
MemoCreatorID int32
ExpectedMemoContent string
MemoUpdate *UpdateMemo
Bindings []*MemoAttachmentBinding
RemovedAttachmentIDs []int32
RequiredAttachmentIDs []int32
ReplaceReferenceRelations bool
ReferenceRelations []*MemoRelation
Policy *MemoWritePolicy
}
MemoMutation atomically updates a memo, its attachment bindings, and its reference relations. Removed attachment rows are deleted in the same transaction; callers may clean up external objects after the commit.
func (*MemoMutation) ActorUserID ¶ added in v0.31.0
func (m *MemoMutation) ActorUserID() int32
ActorUserID returns the user performing the mutation. Transport-facing updates carry the actor in their policy, which may differ from the memo author when an instance administrator acts; creations act as the author.
func (*MemoMutation) WritePolicy ¶ added in v0.31.0
func (m *MemoMutation) WritePolicy() *MemoWritePolicy
WritePolicy returns the transport-facing policy governing the mutation, if any: the mutation's own policy, else the one carried by its memo update.
type MemoRelation ¶ added in v0.14.0
type MemoRelation struct {
MemoID int32
RelatedMemoID int32
Type MemoRelationType
}
type MemoRelationEndpointSnapshot ¶ added in v0.31.0
type MemoRelationEndpointSnapshot struct {
ActorUserID int32
Actor MemoActorState
EndpointID int32
EndpointCreatorID int32
EndpointRowStatus RowStatus
EndpointVisibility Visibility
EndpointSpaceID *int32
EndpointSpaceExists bool
EndpointMemberActive bool
}
MemoRelationEndpointSnapshot is the memo-local database state used to authorize one endpoint during a reference-relation mutation.
type MemoRelationType ¶ added in v0.13.0
type MemoRelationType string
const ( // MemoRelationReference is the type for a reference memo relation. MemoRelationReference MemoRelationType = "REFERENCE" // MemoRelationComment is the type for a comment memo relation. MemoRelationComment MemoRelationType = "COMMENT" )
type MemoShare ¶ added in v0.27.0
type MemoShare struct {
}
MemoShare is an access grant that permits read-only access to a memo via a bearer token.
type MemoWritePolicy ¶ added in v0.31.0
type MemoWritePolicy struct {
ActorUserID int32
// LifecycleOnly permits an author who is no longer a member of the source
// Space to move or withdraw the memo. It never permits content, metadata,
// attachment, relation, or share mutations.
LifecycleOnly bool
// SPACE. Share revocation deliberately leaves this false.
CreatingShare bool
}
MemoWritePolicy identifies the actor and the intended kind of transport-facing mutation. Drivers discover and authorize the current memo, Space, membership, and share state in the write transaction.
type MemoWriteSnapshot ¶ added in v0.31.0
type MemoWriteSnapshot struct {
// ActorIsAdmin is true when the policy actor is an active instance
// administrator. It bypasses authorship and membership checks only.
ActorIsAdmin bool
CreatorID int32
RowStatus RowStatus
SpaceID *int32
Visibility Visibility
SourceSpaceExists bool
SourceMemberActive bool
TargetSpaceExists bool
TargetMemberActive bool
}
MemoWriteSnapshot is the current database state used to validate a MemoWritePolicy. Driver packages populate it in the mutation transaction.
type PATQueryResult ¶ added in v0.26.0
type PATQueryResult struct {
UserID int32
User *User
PAT *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken
}
PATQueryResult contains the result of querying a PAT by hash.
type Reaction ¶ added in v0.21.1
type Reaction struct {
ID int32
CreatedTs int64
CreatorID int32
// MemoID is the ID of the memo that the reaction is for.
MemoID int32
ReactionType string
// Policy is required for transport-facing participation mutations. A nil
// policy preserves trusted internal and migration callers.
Policy *ReactionWritePolicy
}
Reaction is a reaction attached to a memo.
type ReactionWritePolicy ¶ added in v0.31.0
type ReactionWritePolicy struct {
ActorUserID int32
}
ReactionWritePolicy identifies the actor for a transport-facing reaction mutation. Drivers authorize that actor against the memo's current state.
type RefreshTokenQueryResult ¶ added in v0.26.0
type RefreshTokenQueryResult struct {
UserID int32
RefreshToken *storepb.RefreshTokensUserSetting_RefreshToken
}
RefreshTokenQueryResult contains the result of querying a refresh token.
type RevokeSpaceInvitation ¶ added in v0.31.0
RevokeSpaceInvitation identifies an invitation revoked by a space administrator.
type Space ¶ added in v0.31.0
type Space struct {
ID int32
UID string
Title string
Description string
Payload *storepb.SpacePayload
CurrentUserRole SpaceMemberRole
MemberCount int32
}
Space groups memos and memberships.
type SpaceInvitation ¶ added in v0.31.0
type SpaceInvitation struct {
SpaceID int32
UserID int32
Role SpaceMemberRole
}
SpaceInvitation is a pending offer for an existing user to join a space.
type SpaceMember ¶ added in v0.31.0
type SpaceMember struct {
SpaceID int32
UserID int32
Role SpaceMemberRole
}
SpaceMember associates a user with a space.
type SpaceMemberRole ¶ added in v0.31.0
type SpaceMemberRole string
SpaceMemberRole is the role of a user within a space.
const ( // SpaceMemberRoleAdmin can manage the space and its membership. SpaceMemberRoleAdmin SpaceMemberRole = "ADMIN" // SpaceMemberRoleUser is a regular space member. SpaceMemberRoleUser SpaceMemberRole = "USER" )
func (SpaceMemberRole) IsActiveMember ¶ added in v0.31.0
func (r SpaceMemberRole) IsActiveMember() bool
IsActiveMember reports whether the role can grant space membership. The relationship must separately be ACTIVE before the role grants access.
type SpaceMemberStatus ¶ added in v0.31.0
type SpaceMemberStatus string
SpaceMemberStatus is the state of a user's relationship with a space.
const ( // SpaceMemberStatusInvited represents an invitation that the user has not accepted. SpaceMemberStatusInvited SpaceMemberStatus = "INVITED" // SpaceMemberStatusActive represents a membership that the user has accepted. SpaceMemberStatusActive SpaceMemberStatus = "ACTIVE" )
func (SpaceMemberStatus) IsValid ¶ added in v0.31.0
func (s SpaceMemberStatus) IsValid() bool
IsValid reports whether the status is recognized.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides database access to all raw objects.
func (*Store) AcceptSpaceInvitation ¶ added in v0.31.0
func (s *Store) AcceptSpaceInvitation(ctx context.Context, accept *AcceptSpaceInvitation, actorUserID int32) (*SpaceMember, error)
AcceptSpaceInvitation activates a pending invitation only when the actor is the invitee.
func (*Store) AddUserMemoView ¶ added in v0.31.0
func (s *Store) AddUserMemoView(ctx context.Context, userID int32, memoView *storepb.MemoViewsUserSetting_MemoView) error
AddUserMemoView appends a new memo view for the user.
func (*Store) AddUserPersonalAccessToken ¶ added in v0.26.0
func (s *Store) AddUserPersonalAccessToken(ctx context.Context, userID int32, token *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken) error
AddUserPersonalAccessToken adds a new PAT for the user.
func (*Store) AddUserRefreshToken ¶ added in v0.26.0
func (s *Store) AddUserRefreshToken(ctx context.Context, userID int32, token *storepb.RefreshTokensUserSetting_RefreshToken) error
AddUserRefreshToken adds a new refresh token for the user.
func (*Store) AddUserWebhook ¶ added in v0.25.0
func (s *Store) AddUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error
AddUserWebhook adds a new webhook for the user.
func (*Store) AllowsAnonymousAccess ¶ added in v0.31.0
AllowsAnonymousAccess reports whether the effective instance access policy is public.
func (*Store) ApplyMemoMutation ¶ added in v0.31.0
func (s *Store) ApplyMemoMutation(ctx context.Context, mutation *MemoMutation) error
ApplyMemoMutation atomically applies memo fields, attachment bindings, and reference relations after rechecking the state used by API validation.
func (*Store) CreateAttachment ¶ added in v0.25.0
func (s *Store) CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
func (*Store) CreateIdentityProvider ¶ added in v0.11.0
func (s *Store) CreateIdentityProvider(ctx context.Context, create *storepb.IdentityProvider) (*storepb.IdentityProvider, error)
func (*Store) CreateInbox ¶ added in v0.17.0
CreateInbox creates a new inbox notification.
func (*Store) CreateMemo ¶
func (*Store) CreateMemoComment ¶ added in v0.31.0
func (s *Store) CreateMemoComment(ctx context.Context, create *Memo, contextMemoID, actorUserID int32) (*Memo, error)
CreateMemoComment atomically creates one independent memo and its immutable COMMENT relation to a context memo.
func (*Store) CreateMemoShare ¶ added in v0.27.0
CreateMemoShare creates a new share grant.
func (*Store) CreateSpace ¶ added in v0.31.0
CreateSpace creates a space and its first ADMIN membership atomically.
func (*Store) CreateSpaceInvitation ¶ added in v0.31.0
func (s *Store) CreateSpaceInvitation(ctx context.Context, create *SpaceInvitation, actorUserID int32) (*SpaceInvitation, error)
CreateSpaceInvitation creates a pending invitation. It never creates an active membership; only the invitee can do that by accepting it.
func (*Store) CreateUser ¶
func (*Store) CreateUserIdentity ¶ added in v0.28.0
func (s *Store) CreateUserIdentity(ctx context.Context, create *UserIdentity) (*UserIdentity, error)
CreateUserIdentity creates a new external-identity linkage record. A unique-constraint violation is returned as ErrUserIdentityTaken; callers are responsible for reconciling concurrent first-login races on (Provider, ExternUID).
func (*Store) CreateUserIfNoUsers ¶ added in v0.28.0
CreateUserIfNoUsers creates a user only when the instance has no users. The in-process lock prevents concurrent first-user setup requests from creating multiple admins in the same server process.
func (*Store) CreateUserWithIdentity ¶ added in v0.30.0
func (s *Store) CreateUserWithIdentity(ctx context.Context, createUser *User, createIdentity *UserIdentity) (*User, error)
CreateUserWithIdentity atomically creates a local user and its external identity linkage, returning the created user. Unique-constraint violations are returned as ErrUsernameTaken, ErrEmailTaken, or ErrUserIdentityTaken so the caller can tell which conflict it hit.
func (*Store) DeclineSpaceInvitation ¶ added in v0.31.0
func (s *Store) DeclineSpaceInvitation(ctx context.Context, decline *DeclineSpaceInvitation, actorUserID int32) error
DeclineSpaceInvitation deletes a pending invitation only when the actor is the invitee.
func (*Store) DeleteAttachment ¶ added in v0.25.0
func (s *Store) DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error
func (*Store) DeleteAttachmentStorage ¶ added in v0.27.0
func (s *Store) DeleteAttachmentStorage(ctx context.Context, attachment *Attachment) error
func (*Store) DeleteAttachmentStorageWithInstanceSetting ¶ added in v0.29.0
func (s *Store) DeleteAttachmentStorageWithInstanceSetting(ctx context.Context, attachment *Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) error
DeleteAttachmentStorageWithInstanceSetting deletes attachment storage using a preloaded instance storage setting.
func (*Store) DeleteAttachments ¶ added in v0.27.0
func (s *Store) DeleteAttachments(ctx context.Context, attachments []*Attachment) error
func (*Store) DeleteAttachmentsWithPolicy ¶ added in v0.31.0
func (s *Store) DeleteAttachmentsWithPolicy(ctx context.Context, policy *AttachmentDeletionPolicy, attachmentIDs []int32) error
DeleteAttachmentsWithPolicy atomically authorizes and removes the selected attachment rows. External object cleanup remains the caller's responsibility after the transaction commits.
func (*Store) DeleteIdentityProvider ¶ added in v0.11.0
func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
func (*Store) DeleteIdentityProviderSafely ¶ added in v0.30.0
func (s *Store) DeleteIdentityProviderSafely(ctx context.Context, delete *DeleteIdentityProvider) error
DeleteIdentityProviderSafely validates and deletes an IdP as one serialized operation.
func (*Store) DeleteInbox ¶ added in v0.17.0
func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error
DeleteInbox permanently removes an inbox item.
func (*Store) DeleteInstanceSetting ¶ added in v0.31.0
func (s *Store) DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error
DeleteInstanceSetting deletes a database-backed instance setting and clears cached state derived from it.
func (*Store) DeleteMemo ¶
func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error
func (*Store) DeleteMemoRelation ¶ added in v0.13.0
func (s *Store) DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error
func (*Store) DeleteMemoShare ¶ added in v0.27.0
func (s *Store) DeleteMemoShare(ctx context.Context, delete *DeleteMemoShare) error
DeleteMemoShare removes a share grant.
func (*Store) DeleteMemoWithPolicy ¶ added in v0.31.0
func (s *Store) DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error)
DeleteMemoWithPolicy atomically deletes exactly one memo, its owned database resources, and relations for which it is an endpoint.
func (*Store) DeleteReaction ¶ added in v0.20.0
func (s *Store) DeleteReaction(ctx context.Context, delete *DeleteReaction) error
func (*Store) DeleteSpace ¶ added in v0.31.0
func (s *Store) DeleteSpace(ctx context.Context, delete *DeleteSpace) (*DeleteSpaceResult, error)
DeleteSpace atomically deletes a Space, all directly assigned memos, and their owned database resources. Memo relations are not followed.
func (*Store) DeleteSpaceMember ¶ added in v0.31.0
func (s *Store) DeleteSpaceMember(ctx context.Context, delete *DeleteSpaceMember, actorUserID int32) error
DeleteSpaceMember deletes a membership after checking that the change keeps an active ADMIN.
func (*Store) DeleteUser ¶ added in v0.3.0
func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error)
DeleteUser removes a user and returns cache invalidation state. Deleting an already-missing user is idempotent and returns an empty result.
func (*Store) DeleteUserIdentities ¶ added in v0.28.0
func (s *Store) DeleteUserIdentities(ctx context.Context, delete *DeleteUserIdentity) error
DeleteUserIdentities deletes all linkage records matching the filter.
func (*Store) DeleteUserSettings ¶ added in v0.28.0
func (s *Store) DeleteUserSettings(ctx context.Context, delete *DeleteUserSetting) error
func (*Store) GetAttachment ¶ added in v0.25.0
func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)
func (*Store) GetAttachmentStorageUsage ¶ added in v0.31.0
GetAttachmentStorageUsage returns the total persisted attachment size for a creator in bytes.
func (*Store) GetCurrentSchemaVersion ¶ added in v0.22.5
GetCurrentSchemaVersion returns the latest schema version available for the configured database driver.
A driver introduced after the last schema change ships only LATEST.sql and no versioned migration files. LATEST.sql describes the same schema on every driver, so such a driver reports the highest version any driver's migration directory defines and picks up future migrations from there.
func (*Store) GetDataDir ¶ added in v0.28.0
GetDataDir returns the store data directory.
func (*Store) GetIdentityProvider ¶ added in v0.11.0
func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
func (*Store) GetInstanceAISetting ¶ added in v0.27.0
GetInstanceAISetting gets the AI provider settings for the instance.
func (*Store) GetInstanceAccessSetting ¶ added in v0.31.0
func (s *Store) GetInstanceAccessSetting(ctx context.Context) (*storepb.InstanceAccessSetting, error)
GetInstanceAccessSetting gets the instance access policy, defaulting to private.
func (*Store) GetInstanceBasicSetting ¶ added in v0.25.3
func (*Store) GetInstanceGeneralSetting ¶ added in v0.25.3
func (*Store) GetInstanceMemoRelatedSetting ¶ added in v0.25.3
func (*Store) GetInstanceNotificationSetting ¶ added in v0.27.0
func (*Store) GetInstanceSetting ¶ added in v0.25.3
func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
func (*Store) GetInstanceStorageSetting ¶ added in v0.25.3
func (*Store) GetInstanceTagsSetting ¶ added in v0.27.0
func (*Store) GetMemoShare ¶ added in v0.27.0
GetMemoShare returns the first share grant matching the filter, or nil if none found.
func (*Store) GetReaction ¶ added in v0.25.3
func (*Store) GetSpaceInvitation ¶ added in v0.31.0
func (s *Store) GetSpaceInvitation(ctx context.Context, find *FindSpaceInvitation) (*SpaceInvitation, error)
GetSpaceInvitation returns the first matching pending invitation.
func (*Store) GetSpaceMember ¶ added in v0.31.0
func (s *Store) GetSpaceMember(ctx context.Context, find *FindSpaceMember) (*SpaceMember, error)
GetSpaceMember returns the first matching membership.
func (*Store) GetStoredIdentityProvider ¶ added in v0.30.0
func (s *Store) GetStoredIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)
GetStoredIdentityProvider returns a database-backed provider without deployment shadowing.
func (*Store) GetStoredInstanceSetting ¶ added in v0.30.0
func (s *Store) GetStoredInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)
GetStoredInstanceSetting returns a database-backed setting without deployment shadowing.
func (*Store) GetUserByPATHash ¶ added in v0.26.0
GetUserByPATHash finds a user by PAT hash.
func (*Store) GetUserIdentity ¶ added in v0.28.0
func (s *Store) GetUserIdentity(ctx context.Context, find *FindUserIdentity) (*UserIdentity, error)
GetUserIdentity returns the first linkage record matching the filter, or nil if none found.
func (*Store) GetUserMemoViews ¶ added in v0.31.0
func (s *Store) GetUserMemoViews(ctx context.Context, userID int32) ([]*storepb.MemoViewsUserSetting_MemoView, error)
GetUserMemoViews returns the memo views of the user.
func (*Store) GetUserPersonalAccessTokens ¶ added in v0.26.0
func (s *Store) GetUserPersonalAccessTokens(ctx context.Context, userID int32) ([]*storepb.PersonalAccessTokensUserSetting_PersonalAccessToken, error)
GetUserPersonalAccessTokens returns the PATs of the user.
func (*Store) GetUserRefreshTokenByID ¶ added in v0.26.0
func (s *Store) GetUserRefreshTokenByID(ctx context.Context, userID int32, tokenID string) (*storepb.RefreshTokensUserSetting_RefreshToken, error)
GetUserRefreshTokenByID returns a specific refresh token.
func (*Store) GetUserRefreshTokens ¶ added in v0.26.0
func (s *Store) GetUserRefreshTokens(ctx context.Context, userID int32) ([]*storepb.RefreshTokensUserSetting_RefreshToken, error)
GetUserRefreshTokens returns the refresh tokens of the user.
func (*Store) GetUserSetting ¶ added in v0.13.2
func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)
func (*Store) GetUserWebhooks ¶ added in v0.25.0
func (s *Store) GetUserWebhooks(ctx context.Context, userID int32) ([]*storepb.WebhooksUserSetting_Webhook, error)
GetUserWebhooks returns the webhooks of the user.
func (*Store) IsIdentityProviderDeploymentConfigured ¶ added in v0.30.0
IsIdentityProviderDeploymentConfigured reports whether uid is file-backed.
func (*Store) IsInstanceSettingDeploymentConfigured ¶ added in v0.30.0
func (s *Store) IsInstanceSettingDeploymentConfigured(key storepb.InstanceSettingKey) bool
IsInstanceSettingDeploymentConfigured reports whether key is file-backed.
func (*Store) ListAttachments ¶ added in v0.25.0
func (s *Store) ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
func (*Store) ListIdentityProviders ¶ added in v0.11.0
func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*storepb.IdentityProvider, error)
func (*Store) ListInboxes ¶ added in v0.17.0
ListInboxes retrieves inbox items matching the filter criteria.
func (*Store) ListInstanceSettings ¶ added in v0.25.3
func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error)
func (*Store) ListMemoRelations ¶ added in v0.13.0
func (s *Store) ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
func (*Store) ListMemoShares ¶ added in v0.27.0
ListMemoShares returns all share grants matching the filter.
func (*Store) ListReactions ¶ added in v0.20.0
func (*Store) ListSpaceInvitations ¶ added in v0.31.0
func (s *Store) ListSpaceInvitations(ctx context.Context, find *FindSpaceInvitation) ([]*SpaceInvitation, error)
ListSpaceInvitations returns pending invitations matching find.
func (*Store) ListSpaceMembers ¶ added in v0.31.0
func (s *Store) ListSpaceMembers(ctx context.Context, find *FindSpaceMember) ([]*SpaceMember, error)
ListSpaceMembers returns memberships matching find.
func (*Store) ListSpaces ¶ added in v0.31.0
ListSpaces returns spaces matching find.
func (*Store) ListUserIdentities ¶ added in v0.28.0
func (s *Store) ListUserIdentities(ctx context.Context, find *FindUserIdentity) ([]*UserIdentity, error)
ListUserIdentities returns all linkage records matching the filter.
func (*Store) ListUserSettings ¶ added in v0.13.2
func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)
func (*Store) LoadDeploymentConfiguration ¶ added in v0.30.0
LoadDeploymentConfiguration loads the default runtime deployment configuration.
func (*Store) LoadDeploymentConfigurationDir ¶ added in v0.30.0
LoadDeploymentConfigurationDir loads and atomically publishes runtime configuration from dir.
func (*Store) Migrate ¶ added in v0.22.5
Migrate migrates the database schema to the latest version. It checks the current schema version and applies any necessary migrations. It also seeds the database with initial data if in demo mode.
func (*Store) RemoveUserMemoView ¶ added in v0.31.0
func (s *Store) RemoveUserMemoView(ctx context.Context, userID int32, memoViewID string) (bool, error)
RemoveUserMemoView removes the memo view of the user. It reports whether a matching memo view was found.
func (*Store) RemoveUserPersonalAccessToken ¶ added in v0.26.0
func (s *Store) RemoveUserPersonalAccessToken(ctx context.Context, userID int32, tokenID string) error
RemoveUserPersonalAccessToken removes a PAT from the user.
func (*Store) RemoveUserRefreshToken ¶ added in v0.26.0
RemoveUserRefreshToken removes a refresh token from the user.
func (*Store) RemoveUserRefreshTokensExcept ¶ added in v0.31.0
func (s *Store) RemoveUserRefreshTokensExcept(ctx context.Context, userID int32, keepTokenID string) error
RemoveUserRefreshTokensExcept revokes every refresh token of the user other than keepTokenID. An empty keepTokenID revokes all of them.
func (*Store) RemoveUserWebhook ¶ added in v0.25.0
RemoveUserWebhook removes the webhook of the user.
func (*Store) ResolveAttachmentS3Driver ¶ added in v0.31.0
func (s *Store) ResolveAttachmentS3Driver(ctx context.Context, attachment *Attachment) (storage.Driver, *storepb.AttachmentPayload_S3Object, error)
ResolveAttachmentS3Driver resolves the storage driver referenced by an S3 attachment payload, validating the payload and supplying the instance setting.
func (*Store) ResolveStorageDriver ¶ added in v0.31.0
func (s *Store) ResolveStorageDriver( ctx context.Context, setting *storepb.InstanceStorageSetting, storageID string, legacyS3Config *storepb.StorageS3Config, ) (storage.Driver, error)
ResolveStorageDriver resolves the configured storage referenced by an attachment and returns its driver, reusing the Store cache for named storage. legacyS3Config supports attachments written before storage IDs were introduced.
func (*Store) RevokeSpaceInvitation ¶ added in v0.31.0
func (s *Store) RevokeSpaceInvitation(ctx context.Context, revoke *RevokeSpaceInvitation, actorUserID int32) error
RevokeSpaceInvitation deletes a pending invitation after authorizing an active space administrator.
func (*Store) StorageDriver ¶ added in v0.31.0
func (s *Store) StorageDriver(ctx context.Context, resolvedStorage *storepb.Storage) (storage.Driver, error)
StorageDriver returns the driver for a resolved storage, reusing cached clients so request paths do not rebuild an S3 client (config load, HTTP transport) per call. ID-less legacy storages are not cached.
func (*Store) UpdateAttachment ¶ added in v0.25.0
func (s *Store) UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
func (*Store) UpdateIdentityProvider ¶ added in v0.11.0
func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProviderV1) (*storepb.IdentityProvider, error)
func (*Store) UpdateInbox ¶ added in v0.17.0
UpdateInbox updates an existing inbox item.
func (*Store) UpdateMemo ¶ added in v0.13.1
func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error
func (*Store) UpdatePATLastUsed ¶ added in v0.26.0
func (s *Store) UpdatePATLastUsed(ctx context.Context, userID int32, tokenID string, lastUsed *timestamppb.Timestamp) error
UpdatePATLastUsed updates the last_used_at timestamp of a PAT.
func (*Store) UpdateSpace ¶ added in v0.31.0
func (s *Store) UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserID int32) (*Space, error)
UpdateSpace updates and returns a space.
func (*Store) UpdateSpaceMember ¶ added in v0.31.0
func (s *Store) UpdateSpaceMember(ctx context.Context, update *UpdateSpaceMember, actorUserID int32) (*SpaceMember, error)
UpdateSpaceMember updates and returns a membership after checking that the change keeps an active ADMIN.
func (*Store) UpdateUser ¶ added in v0.14.0
func (*Store) UpdateUserMemoView ¶ added in v0.31.0
func (s *Store) UpdateUserMemoView( ctx context.Context, userID int32, memoViewID string, title *string, filter *string, icon **storepb.MemoViewsUserSetting_MemoView_Icon, ) (*storepb.MemoViewsUserSetting_MemoView, error)
UpdateUserMemoView applies the non-nil field updates to the memo view carrying the same ID. A non-nil icon update containing nil resets the icon. It returns nil when no matching memo view is found.
func (*Store) UpdateUserWebhook ¶ added in v0.25.0
func (s *Store) UpdateUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error
UpdateUserWebhook updates an existing webhook for the user.
func (*Store) UpsertInstanceGeneralSettingSafely ¶ added in v0.30.0
func (s *Store) UpsertInstanceGeneralSettingSafely(ctx context.Context, setting *storepb.InstanceSetting) (*storepb.InstanceSetting, error)
UpsertInstanceGeneralSettingSafely validates and stores GENERAL as one serialized operation.
func (*Store) UpsertInstanceSetting ¶ added in v0.25.3
func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error)
func (*Store) UpsertMemoRelation ¶ added in v0.13.0
func (s *Store) UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
func (*Store) UpsertReaction ¶ added in v0.20.0
func (*Store) UpsertUserSetting ¶ added in v0.4.0
func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)
type UpdateAttachment ¶ added in v0.25.0
type UpdateAttachment struct {
ID int32
UID *string
UpdatedTs *int64
Filename *string
MemoID *int32
Payload *storepb.AttachmentPayload
// Policy is present for transport-facing updates. Drivers discover the
// current attachment binding and authorize any linked memo in the same
// transaction as the update.
Policy *MemoWritePolicy
}
type UpdateIdentityProvider ¶ added in v0.13.2
type UpdateIdentityProviderV1 ¶ added in v0.21.1
type UpdateIdentityProviderV1 struct {
ID int32
Type storepb.IdentityProvider_Type
Name *string
IdentifierFilter *string
Config *storepb.IdentityProviderConfig
}
type UpdateInbox ¶ added in v0.17.0
type UpdateInbox struct {
ID int32
Status InboxStatus
}
UpdateInbox contains fields that can be updated for an inbox item.
type UpdateMemo ¶ added in v0.14.0
type UpdateMemo struct {
ID int32
UID *string
CreatedTs *int64
UpdatedTs *int64
RowStatus *RowStatus
Content *string
Visibility *Visibility
Pinned *bool
Payload *storepb.MemoPayload
SpaceID *int32
ClearSpace bool
// Policy is set by transport-facing author mutations. Drivers revalidate it
// in the same transaction as the update; nil preserves trusted internal and
// migration callers.
Policy *MemoWritePolicy
}
type UpdateSpace ¶ added in v0.31.0
type UpdateSpace struct {
ID int32
Title *string
Description *string
Payload *storepb.SpacePayload
}
UpdateSpace contains mutable space fields.
type UpdateSpaceMember ¶ added in v0.31.0
type UpdateSpaceMember struct {
SpaceID int32
UserID int32
Role *SpaceMemberRole
}
UpdateSpaceMember contains mutable membership fields.
type UpdateUser ¶ added in v0.14.0
type UserIdentity ¶ added in v0.28.0
type UserIdentity struct {
ID int32
UserID int32
Provider string
ExternUID string
CreatedTs int64
UpdatedTs int64
}
UserIdentity is the linkage between an external identity subject and a local user. Uniqueness is enforced on (Provider, ExternUID); one local user may have multiple identities across different providers.
type UserSetting ¶ added in v0.13.2
type UserSetting struct {
UserID int32
Key storepb.UserSetting_Key
Value string
}
type Visibility ¶ added in v0.13.1
type Visibility string
Visibility is the type of a visibility.
const ( // Public is the PUBLIC visibility. Public Visibility = "PUBLIC" // Protected is the PROTECTED visibility. Protected Visibility = "PROTECTED" // Private is the PRIVATE visibility. Private Visibility = "PRIVATE" // SpaceAudience is visible only to active members of its space. SpaceAudience Visibility = "SPACE" )
func (Visibility) String ¶ added in v0.13.1
func (v Visibility) String() string
Source Files
¶
- attachment.go
- attachment_delete.go
- auth_config.go
- cache.go
- common.go
- custom_icon.go
- deployment_config.go
- doc.go
- driver.go
- email.go
- idp.go
- inbox.go
- instance_setting.go
- memo.go
- memo_attachment.go
- memo_comment.go
- memo_delete_policy.go
- memo_relation.go
- memo_share.go
- memo_view_icon.go
- migrator.go
- migrator_email.go
- reaction.go
- reaction_policy.go
- space.go
- space_icon.go
- storage.go
- store.go
- user.go
- user_delete.go
- user_identity.go
- user_setting.go
- user_unique.go