database

package
v0.0.0-...-8217dc8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const VariableCountLimit = 512

Variables

This section is empty.

Functions

func Migrate

func Migrate(old *Database, new *Database)

Types

type Database

type Database struct {
	*sql.DB

	User    *UserQuery
	Portal  *PortalQuery
	Puppet  *PuppetQuery
	Message *MessageQuery
	// contains filtered or unexported fields
}

func New

func New(dbType string, uri string, baseLog log.Logger) (*Database, error)

func (*Database) Init

func (db *Database) Init() error

type Message

type Message struct {
	Chat      PortalKey
	PID       pulsesms.MessageID // TODO: change to string?
	MXID      id.EventID
	Sender    pulsesms.PhoneNumber
	Timestamp int64
	Sent      bool
	Content   string // TODO: richer type? compare to wa.ProtoMessage
	// contains filtered or unexported fields
}

func (*Message) Delete

func (msg *Message) Delete()

func (*Message) Insert

func (msg *Message) Insert()

func (*Message) IsFakeMXID

func (msg *Message) IsFakeMXID() bool

func (*Message) MarkSent

func (msg *Message) MarkSent()

func (*Message) Scan

func (msg *Message) Scan(row Scannable) *Message

type MessageQuery

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

func (*MessageQuery) GetAll

func (mq *MessageQuery) GetAll(chat PortalKey) (messages []*Message)

func (*MessageQuery) GetByMXID

func (mq *MessageQuery) GetByMXID(mxid id.EventID) *Message

func (*MessageQuery) GetByPID

func (mq *MessageQuery) GetByPID(chat PortalKey, pid string) *Message

TODO accept pulsesms.MessageID (int)

func (*MessageQuery) GetLastInChat

func (mq *MessageQuery) GetLastInChat(chat PortalKey) *Message

func (*MessageQuery) GetLastInChatBefore

func (mq *MessageQuery) GetLastInChatBefore(chat PortalKey, maxTimestamp int64) *Message

func (*MessageQuery) New

func (mq *MessageQuery) New() *Message

type Portal

type Portal struct {
	Key  PortalKey
	MXID id.RoomID

	Name      string
	Topic     string
	Avatar    string
	AvatarURL id.ContentURI
	Encrypted bool
	// contains filtered or unexported fields
}

func (*Portal) Delete

func (portal *Portal) Delete()

func (*Portal) GetUserIDs

func (portal *Portal) GetUserIDs() []id.UserID

func (*Portal) Insert

func (portal *Portal) Insert()

func (*Portal) Scan

func (portal *Portal) Scan(row Scannable) *Portal

func (*Portal) Update

func (portal *Portal) Update()

type PortalKey

type PortalKey struct {
	PID      pulsesms.ChatID
	Receiver pulsesms.ChatID
}

func GroupPortalKey

func GroupPortalKey(pid pulsesms.ChatID) PortalKey

func NewPortalKey

func NewPortalKey(pid, receiver pulsesms.ChatID) PortalKey

func (PortalKey) String

func (key PortalKey) String() string

type PortalKeyWithMeta

type PortalKeyWithMeta struct {
	PortalKey
	InCommunity bool
}

type PortalQuery

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

func (*PortalQuery) FindPrivateChats

func (pq *PortalQuery) FindPrivateChats(receiver pulsesms.PhoneNumber) []*Portal

func (*PortalQuery) GetAll

func (pq *PortalQuery) GetAll() []*Portal

func (*PortalQuery) GetAllByPID

func (pq *PortalQuery) GetAllByPID(pid pulsesms.PhoneNumber) []*Portal

func (*PortalQuery) GetByMXID

func (pq *PortalQuery) GetByMXID(mxid id.RoomID) *Portal

func (*PortalQuery) GetByPID

func (pq *PortalQuery) GetByPID(key PortalKey) *Portal

func (*PortalQuery) New

func (pq *PortalQuery) New() *Portal

type Puppet

type Puppet struct {
	PID         pulsesms.PhoneNumber
	Avatar      string
	AvatarURL   id.ContentURI
	Displayname string
	NameQuality int8

	CustomMXID     id.UserID
	AccessToken    string
	NextBatch      string
	EnablePresence bool
	EnableReceipts bool
	// contains filtered or unexported fields
}

func (*Puppet) Insert

func (puppet *Puppet) Insert()

func (*Puppet) Scan

func (puppet *Puppet) Scan(row Scannable) *Puppet

func (*Puppet) Update

func (puppet *Puppet) Update()

type PuppetQuery

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

func (*PuppetQuery) Get

func (pq *PuppetQuery) Get(pid pulsesms.PhoneNumber) *Puppet

func (*PuppetQuery) GetAll

func (pq *PuppetQuery) GetAll() (puppets []*Puppet)

func (*PuppetQuery) GetAllWithCustomMXID

func (pq *PuppetQuery) GetAllWithCustomMXID() (puppets []*Puppet)

func (*PuppetQuery) GetByCustomMXID

func (pq *PuppetQuery) GetByCustomMXID(mxid id.UserID) *Puppet

func (*PuppetQuery) New

func (pq *PuppetQuery) New() *Puppet

type SQLCryptoStore

type SQLCryptoStore struct {
	*crypto.SQLCryptoStore
	UserID        id.UserID
	GhostIDFormat string
}

func NewSQLCryptoStore

func NewSQLCryptoStore(db *Database, userID id.UserID, ghostIDFormat string) *SQLCryptoStore

func (*SQLCryptoStore) FindDeviceID

func (store *SQLCryptoStore) FindDeviceID() (deviceID id.DeviceID)

func (*SQLCryptoStore) GetRoomMembers

func (store *SQLCryptoStore) GetRoomMembers(roomID id.RoomID) (members []id.UserID, err error)

type SQLStateStore

type SQLStateStore struct {
	*appservice.TypingStateStore

	Typing map[id.RoomID]map[id.UserID]int64
	// contains filtered or unexported fields
}

func NewSQLStateStore

func NewSQLStateStore(db *Database) *SQLStateStore

func (*SQLStateStore) FindSharedRooms

func (store *SQLStateStore) FindSharedRooms(userID id.UserID) (rooms []id.RoomID)

func (*SQLStateStore) GetMember

func (store *SQLStateStore) GetMember(roomID id.RoomID, userID id.UserID) *event.MemberEventContent

func (*SQLStateStore) GetMembership

func (store *SQLStateStore) GetMembership(roomID id.RoomID, userID id.UserID) event.Membership

func (*SQLStateStore) GetPowerLevel

func (store *SQLStateStore) GetPowerLevel(roomID id.RoomID, userID id.UserID) int

func (*SQLStateStore) GetPowerLevelRequirement

func (store *SQLStateStore) GetPowerLevelRequirement(roomID id.RoomID, eventType event.Type) int

func (*SQLStateStore) GetPowerLevels

func (store *SQLStateStore) GetPowerLevels(roomID id.RoomID) (levels *event.PowerLevelsEventContent)

func (*SQLStateStore) GetRoomMembers

func (store *SQLStateStore) GetRoomMembers(roomID id.RoomID) map[id.UserID]*event.MemberEventContent

func (*SQLStateStore) HasPowerLevel

func (store *SQLStateStore) HasPowerLevel(roomID id.RoomID, userID id.UserID, eventType event.Type) bool

func (*SQLStateStore) IsInRoom

func (store *SQLStateStore) IsInRoom(roomID id.RoomID, userID id.UserID) bool

func (*SQLStateStore) IsInvited

func (store *SQLStateStore) IsInvited(roomID id.RoomID, userID id.UserID) bool

func (*SQLStateStore) IsMembership

func (store *SQLStateStore) IsMembership(roomID id.RoomID, userID id.UserID, allowedMemberships ...event.Membership) bool

func (*SQLStateStore) IsRegistered

func (store *SQLStateStore) IsRegistered(userID id.UserID) bool

func (*SQLStateStore) MarkRegistered

func (store *SQLStateStore) MarkRegistered(userID id.UserID)

func (*SQLStateStore) SetMember

func (store *SQLStateStore) SetMember(roomID id.RoomID, userID id.UserID, member *event.MemberEventContent)

func (*SQLStateStore) SetMembership

func (store *SQLStateStore) SetMembership(roomID id.RoomID, userID id.UserID, membership event.Membership)

func (*SQLStateStore) SetPowerLevels

func (store *SQLStateStore) SetPowerLevels(roomID id.RoomID, levels *event.PowerLevelsEventContent)

func (*SQLStateStore) TryGetMember

func (store *SQLStateStore) TryGetMember(roomID id.RoomID, userID id.UserID) (*event.MemberEventContent, bool)

type Scannable

type Scannable interface {
	Scan(...interface{}) error
}

type User

type User struct {
	MXID           id.UserID
	PID            pulsesms.PhoneNumber
	ManagementRoom id.RoomID
	Session        *pulsesms.KeyCredentials
	LastConnection int64
	AccountID      pulsesms.AccountID
	// contains filtered or unexported fields
}

func (*User) CreateUserPortal

func (user *User) CreateUserPortal(newKey PortalKeyWithMeta)

func (*User) GetInCommunityMap

func (user *User) GetInCommunityMap() map[PortalKey]bool

func (*User) GetPortalKeys

func (user *User) GetPortalKeys() []PortalKey

func (*User) Insert

func (user *User) Insert()

func (*User) IsInPortal

func (user *User) IsInPortal(key PortalKey) bool

func (*User) Scan

func (user *User) Scan(row Scannable) *User

func (*User) SetPortalKeys

func (user *User) SetPortalKeys(newKeys []PortalKeyWithMeta) error

func (*User) Update

func (user *User) Update()

func (*User) UpdateLastConnection

func (user *User) UpdateLastConnection()

type UserQuery

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

func (*UserQuery) GetAll

func (uq *UserQuery) GetAll() (users []*User)

func (*UserQuery) GetByMXID

func (uq *UserQuery) GetByMXID(userID id.UserID) *User

func (*UserQuery) GetByPID

func (uq *UserQuery) GetByPID(userID pulsesms.PhoneNumber) *User

func (*UserQuery) New

func (uq *UserQuery) New() *User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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