store

package
v0.0.0-...-7bda4f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAccessHash = errors.New("access hash not found")

Functions

This section is empty.

Types

type Container

type Container struct {
	*dbutil.Database

	TelegramFile *TelegramFileQuery
}

func NewStore

func NewStore(db *dbutil.Database, log dbutil.DatabaseLogger) *Container

func (*Container) GetScopedStore

func (c *Container) GetScopedStore(telegramUserID int64) *ScopedStore

func (*Container) Upgrade

func (c *Container) Upgrade(ctx context.Context) error

type ScopedStore

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

ScopedStore is a wrapper around a database that implements [session.Storage] scoped to a specific Telegram user ID.

func (*ScopedStore) DeleteAccessHashesForUser

func (s *ScopedStore) DeleteAccessHashesForUser(ctx context.Context) (err error)

func (*ScopedStore) DeleteChannelStateForUser

func (s *ScopedStore) DeleteChannelStateForUser(ctx context.Context) (err error)

func (*ScopedStore) DeleteUserState

func (s *ScopedStore) DeleteUserState(ctx context.Context) (err error)

func (*ScopedStore) ForEachChannels

func (s *ScopedStore) ForEachChannels(ctx context.Context, userID int64, f func(ctx context.Context, channelID int64, pts int) error) error

func (*ScopedStore) GetAccessHash

func (s *ScopedStore) GetAccessHash(ctx context.Context, entityType ids.PeerType, entityID int64) (accessHash int64, err error)

func (*ScopedStore) GetChannelAccessHash deprecated

func (s *ScopedStore) GetChannelAccessHash(ctx context.Context, forUserID, channelID int64) (accessHash int64, found bool, err error)

Deprecated: only for interface, don't use directly. Use [GetAccessHash] instead.

func (*ScopedStore) GetChannelPts

func (s *ScopedStore) GetChannelPts(ctx context.Context, userID int64, channelID int64) (pts int, found bool, err error)

func (*ScopedStore) GetEntityIDByUsername

func (s *ScopedStore) GetEntityIDByUsername(ctx context.Context, username string) (entityType ids.PeerType, entityID int64, err error)

func (*ScopedStore) GetState

func (s *ScopedStore) GetState(ctx context.Context, userID int64) (state updates.State, found bool, err error)

func (*ScopedStore) GetUserAccessHash deprecated

func (s *ScopedStore) GetUserAccessHash(ctx context.Context, forUserID int64, userID int64) (accessHash int64, found bool, err error)

Deprecated: only for interface, don't use directly. Use [GetAccessHash] instead.

func (*ScopedStore) GetUserIDByPhoneNumber

func (s *ScopedStore) GetUserIDByPhoneNumber(ctx context.Context, phoneNumber string) (userID int64, err error)

func (*ScopedStore) GetUsername

func (s *ScopedStore) GetUsername(ctx context.Context, entityType ids.PeerType, userID int64) (username string, err error)

func (*ScopedStore) SetAccessHash

func (s *ScopedStore) SetAccessHash(ctx context.Context, entityType ids.PeerType, entityID, accessHash int64) (err error)

func (*ScopedStore) SetChannelAccessHash deprecated

func (s *ScopedStore) SetChannelAccessHash(ctx context.Context, forUserID, channelID, accessHash int64) (err error)

Deprecated: only for interface, don't use directly. Use [SetAccessHash] instead.

func (*ScopedStore) SetChannelPts

func (s *ScopedStore) SetChannelPts(ctx context.Context, userID int64, channelID int64, pts int) (err error)

func (*ScopedStore) SetDate

func (s *ScopedStore) SetDate(ctx context.Context, userID int64, date int) (err error)

func (*ScopedStore) SetDateSeq

func (s *ScopedStore) SetDateSeq(ctx context.Context, userID int64, date int, seq int) (err error)

func (*ScopedStore) SetPhoneNumber

func (s *ScopedStore) SetPhoneNumber(ctx context.Context, userID int64, phoneNumber string) (err error)

func (*ScopedStore) SetPts

func (s *ScopedStore) SetPts(ctx context.Context, userID int64, pts int) (err error)

func (*ScopedStore) SetQts

func (s *ScopedStore) SetQts(ctx context.Context, userID int64, qts int) (err error)

func (*ScopedStore) SetSeq

func (s *ScopedStore) SetSeq(ctx context.Context, userID int64, seq int) (err error)

func (*ScopedStore) SetState

func (s *ScopedStore) SetState(ctx context.Context, userID int64, state updates.State) (err error)

func (*ScopedStore) SetUserAccessHash deprecated

func (s *ScopedStore) SetUserAccessHash(ctx context.Context, forUserID int64, userID int64, accessHash int64) error

Deprecated: only for interface, don't use directly. Use [SetAccessHash] instead.

func (*ScopedStore) SetUsername

func (s *ScopedStore) SetUsername(ctx context.Context, entityType ids.PeerType, entityID int64, username string) (err error)

type TelegramFile

type TelegramFile struct {
	LocationID TelegramFileLocationID
	MXC        id.ContentURIString
	MIMEType   string
	Size       int
	// contains filtered or unexported fields
}

func (*TelegramFile) Insert

func (f *TelegramFile) Insert(ctx context.Context) error

func (*TelegramFile) Scan

func (f *TelegramFile) Scan(row dbutil.Scannable) (*TelegramFile, error)

type TelegramFileLocationID

type TelegramFileLocationID string

type TelegramFileQuery

type TelegramFileQuery struct {
	*dbutil.QueryHelper[*TelegramFile]
}

func (*TelegramFileQuery) GetByLocationID

func (fq *TelegramFileQuery) GetByLocationID(ctx context.Context, locationID TelegramFileLocationID) (*TelegramFile, error)

func (*TelegramFileQuery) GetByMXC

func (fq *TelegramFileQuery) GetByMXC(ctx context.Context, mxc string) (*TelegramFile, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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