database

package
v0.0.0-...-9af0d73 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Channel PortalKey

	SlackMessageID string
	SlackFileID    string
	MatrixEventID  id.EventID
	SlackThreadID  string
	// contains filtered or unexported fields
}

func (*Attachment) Delete

func (a *Attachment) Delete()

func (*Attachment) Insert

func (a *Attachment) Insert(txn dbutil.Transaction)

func (*Attachment) Scan

func (a *Attachment) Scan(row dbutil.Scannable) *Attachment

type AttachmentQuery

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

func (*AttachmentQuery) GetAllBySlackMessageID

func (aq *AttachmentQuery) GetAllBySlackMessageID(key PortalKey, slackMessageID string) []*Attachment

func (*AttachmentQuery) GetByMatrixID

func (aq *AttachmentQuery) GetByMatrixID(key PortalKey, matrixEventID id.EventID) *Attachment

func (*AttachmentQuery) GetBySlackFileID

func (aq *AttachmentQuery) GetBySlackFileID(key PortalKey, slackMessageID, slackFileID string) *Attachment

func (*AttachmentQuery) GetLast

func (aq *AttachmentQuery) GetLast(key PortalKey) *Attachment

func (*AttachmentQuery) New

func (aq *AttachmentQuery) New() *Attachment

type BackfillQuery

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

func (*BackfillQuery) GetBackfillState

func (bq *BackfillQuery) GetBackfillState(portalKey *PortalKey) (backfillState *BackfillState)

func (*BackfillQuery) GetNextUnfinishedBackfillState

func (bq *BackfillQuery) GetNextUnfinishedBackfillState() (backfillState *BackfillState)

func (*BackfillQuery) NewBackfillState

func (bq *BackfillQuery) NewBackfillState(portalKey *PortalKey) *BackfillState

func (*BackfillQuery) UndispatchAll

func (b *BackfillQuery) UndispatchAll()

Undispatch backfills so they can be retried in case the bridge crashed/was stopped during backfill Sent messages are tracked in the message and portal tables so this shouldn't lead to duplicate backfills

type BackfillState

type BackfillState struct {

	// Fields
	Portal            *PortalKey
	Dispatched        bool
	BackfillComplete  bool
	MessageCount      int
	ImmediateComplete bool
	// contains filtered or unexported fields
}

func (*BackfillState) Scan

func (*BackfillState) SetDispatched

func (b *BackfillState) SetDispatched(d bool)

func (*BackfillState) Upsert

func (b *BackfillState) Upsert()

type ChannelType

type ChannelType int64
const (
	ChannelTypeUnknown ChannelType = iota
	ChannelTypeChannel
	ChannelTypeDM
	ChannelTypeGroupDM
)

func (ChannelType) String

func (ct ChannelType) String() string

type Database

type Database struct {
	*dbutil.Database

	User       *UserQuery
	UserTeam   *UserTeamQuery
	Portal     *PortalQuery
	Puppet     *PuppetQuery
	Message    *MessageQuery
	Reaction   *ReactionQuery
	Attachment *AttachmentQuery
	TeamInfo   *TeamInfoQuery
	Backfill   *BackfillQuery
	Emoji      *EmojiQuery
}

func New

func New(baseDB *dbutil.Database, log maulogger.Logger) *Database

type Emoji

type Emoji struct {
	SlackID   string
	SlackTeam string
	Alias     string
	ImageURL  id.ContentURI
	// contains filtered or unexported fields
}

func (*Emoji) Delete

func (e *Emoji) Delete()

func (*Emoji) Scan

func (e *Emoji) Scan(row dbutil.Scannable) *Emoji

func (*Emoji) Upsert

func (e *Emoji) Upsert(txn dbutil.Transaction)

type EmojiQuery

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

func (*EmojiQuery) GetByMXC

func (eq *EmojiQuery) GetByMXC(mxc id.ContentURI) *Emoji

func (*EmojiQuery) GetBySlackID

func (eq *EmojiQuery) GetBySlackID(slackID string, slackTeam string) *Emoji

func (*EmojiQuery) GetEmojiCount

func (eq *EmojiQuery) GetEmojiCount(slackTeam string) (count int, err error)

func (*EmojiQuery) New

func (eq *EmojiQuery) New() *Emoji

type Message

type Message struct {
	Channel PortalKey

	SlackID  string
	MatrixID id.EventID

	SlackThreadID string

	AuthorID string
	// contains filtered or unexported fields
}

func (*Message) Delete

func (m *Message) Delete()

func (*Message) Insert

func (m *Message) Insert(txn dbutil.Transaction)

func (*Message) Scan

func (m *Message) Scan(row dbutil.Scannable) *Message

type MessageQuery

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

func (*MessageQuery) GetAll

func (mq *MessageQuery) GetAll(key PortalKey) []*Message

func (*MessageQuery) GetByMatrixID

func (mq *MessageQuery) GetByMatrixID(key PortalKey, matrixID id.EventID) *Message

func (*MessageQuery) GetBySlackID

func (mq *MessageQuery) GetBySlackID(key PortalKey, slackID string) *Message

func (*MessageQuery) GetFirst

func (mq *MessageQuery) GetFirst(key PortalKey) *Message

func (*MessageQuery) GetLast

func (mq *MessageQuery) GetLast(key PortalKey) *Message

func (*MessageQuery) GetLastInThread

func (mq *MessageQuery) GetLastInThread(key PortalKey, slackThreadId string) *Message

func (*MessageQuery) New

func (mq *MessageQuery) New() *Message

type Portal

type Portal struct {
	Key  PortalKey
	MXID id.RoomID

	Type     ChannelType
	DMUserID string

	PlainName string
	Name      string
	NameSet   bool
	Topic     string
	TopicSet  bool
	Encrypted bool
	Avatar    string
	AvatarURL id.ContentURI
	AvatarSet bool

	FirstEventID id.EventID
	NextBatchID  id.BatchID
	FirstSlackID string

	InSpace bool
	// contains filtered or unexported fields
}

func (*Portal) Delete

func (p *Portal) Delete()

func (*Portal) DeleteUser

func (p *Portal) DeleteUser(utk UserTeamKey)

func (*Portal) Insert

func (p *Portal) Insert()

func (*Portal) InsertUser

func (p *Portal) InsertUser(utk UserTeamKey)

func (*Portal) Scan

func (p *Portal) Scan(row dbutil.Scannable) *Portal

func (*Portal) Update

func (p *Portal) Update(txn dbutil.Transaction)

type PortalKey

type PortalKey struct {
	TeamID    string
	ChannelID string
}

func NewPortalKey

func NewPortalKey(teamID, channelID string) PortalKey

func (PortalKey) String

func (key PortalKey) String() string

type PortalQuery

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

func (*PortalQuery) FindPrivateChatsWith

func (pq *PortalQuery) FindPrivateChatsWith(id string) []*Portal

func (*PortalQuery) GetAll

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

func (*PortalQuery) GetAllForUserTeam

func (pq *PortalQuery) GetAllForUserTeam(utk UserTeamKey) []*Portal

func (*PortalQuery) GetByID

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

func (*PortalQuery) GetByMXID

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

func (*PortalQuery) New

func (pq *PortalQuery) New() *Portal

type Puppet

type Puppet struct {
	TeamID string
	UserID string

	Name    string
	NameSet bool

	Avatar    string
	AvatarURL id.ContentURI
	AvatarSet bool

	EnablePresence bool

	CustomMXID  id.UserID
	AccessToken string

	NextBatch string

	IsBot bool

	EnableReceipts bool

	ContactInfoSet bool
	// contains filtered or unexported fields
}

func (*Puppet) Insert

func (p *Puppet) Insert()

func (*Puppet) Scan

func (p *Puppet) Scan(row dbutil.Scannable) *Puppet

func (*Puppet) Update

func (p *Puppet) Update()

type PuppetQuery

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

func (*PuppetQuery) Get

func (pq *PuppetQuery) Get(teamID, userID string) *Puppet

func (*PuppetQuery) GetAll

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

func (*PuppetQuery) GetAllForTeam

func (pq *PuppetQuery) GetAllForTeam(teamID string) []*Puppet

func (*PuppetQuery) GetAllWithCustomMXID

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

func (*PuppetQuery) GetByCustomMXID

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

func (*PuppetQuery) New

func (pq *PuppetQuery) New() *Puppet

type Reaction

type Reaction struct {
	Channel PortalKey

	SlackMessageID string
	MatrixEventID  id.EventID

	// The slack ID of who create this reaction
	AuthorID string

	MatrixName string
	MatrixURL  string // Used for custom emoji

	SlackName string // The id or unicode of the emoji for slack
	// contains filtered or unexported fields
}

func (*Reaction) Delete

func (r *Reaction) Delete()

func (*Reaction) Insert

func (r *Reaction) Insert(txn dbutil.Transaction)

func (*Reaction) Scan

func (r *Reaction) Scan(row dbutil.Scannable) *Reaction

func (*Reaction) Update

func (r *Reaction) Update()

type ReactionQuery

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

func (*ReactionQuery) GetAllByMatrixID

func (rq *ReactionQuery) GetAllByMatrixID(key PortalKey, matrixEventID id.EventID) []*Reaction

func (*ReactionQuery) GetByMatrixID

func (rq *ReactionQuery) GetByMatrixID(key PortalKey, matrixEventID id.EventID) *Reaction

func (*ReactionQuery) GetBySlackID

func (rq *ReactionQuery) GetBySlackID(key PortalKey, slackAuthor, slackMessageID, slackName string) *Reaction

func (*ReactionQuery) New

func (rq *ReactionQuery) New() *Reaction

type TeamInfo

type TeamInfo struct {
	TeamID     string
	TeamDomain string
	TeamUrl    string
	TeamName   string
	Avatar     string
	AvatarUrl  id.ContentURI
	SpaceRoom  id.RoomID
	NameSet    bool
	AvatarSet  bool
	// contains filtered or unexported fields
}

func (*TeamInfo) Scan

func (ti *TeamInfo) Scan(row dbutil.Scannable) *TeamInfo

func (*TeamInfo) Upsert

func (ti *TeamInfo) Upsert()

type TeamInfoQuery

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

func (*TeamInfoQuery) GetByMXID

func (tiq *TeamInfoQuery) GetByMXID(mxid id.RoomID) *TeamInfo

func (*TeamInfoQuery) GetBySlackTeam

func (tiq *TeamInfoQuery) GetBySlackTeam(team string) *TeamInfo

func (*TeamInfoQuery) New

func (tiq *TeamInfoQuery) New() *TeamInfo

type User

type User struct {
	MXID           id.UserID
	ManagementRoom id.RoomID
	SpaceRoom      id.RoomID

	TeamsLock sync.Mutex
	Teams     map[string]*UserTeam
	// contains filtered or unexported fields
}

func (*User) GetLoggedInTeams

func (u *User) GetLoggedInTeams() []*UserTeam

func (*User) Insert

func (u *User) Insert()

func (*User) Scan

func (u *User) Scan(row dbutil.Scannable) *User

func (*User) SyncTeams

func (u *User) SyncTeams()

func (*User) TeamLoggedIn

func (u *User) TeamLoggedIn(email, domain string) bool

func (*User) Update

func (u *User) Update()

type UserQuery

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

func (*UserQuery) GetAll

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

func (*UserQuery) GetByMXID

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

func (*UserQuery) GetBySlackID

func (uq *UserQuery) GetBySlackID(teamID, userID string) *User

func (*UserQuery) New

func (uq *UserQuery) New() *User

type UserTeam

type UserTeam struct {
	Key UserTeamKey

	SlackEmail string
	TeamName   string

	Token       string
	CookieToken string

	InSpace bool

	Client *slack.Client
	RTM    *slack.RTM
	// contains filtered or unexported fields
}

func (*UserTeam) GetMXID

func (ut *UserTeam) GetMXID() id.UserID

func (*UserTeam) GetRemoteID

func (ut *UserTeam) GetRemoteID() string

func (*UserTeam) GetRemoteName

func (ut *UserTeam) GetRemoteName() string

func (*UserTeam) IsConnected

func (ut *UserTeam) IsConnected() bool

func (*UserTeam) IsLoggedIn

func (ut *UserTeam) IsLoggedIn() bool

func (*UserTeam) Scan

func (ut *UserTeam) Scan(row dbutil.Scannable) *UserTeam

func (*UserTeam) Upsert

func (ut *UserTeam) Upsert()

type UserTeamKey

type UserTeamKey struct {
	MXID    id.UserID
	SlackID string
	TeamID  string
}

func (UserTeamKey) String

func (utk UserTeamKey) String() string

type UserTeamQuery

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

func (*UserTeamQuery) GetAllByMXIDWithToken

func (utq *UserTeamQuery) GetAllByMXIDWithToken(userID id.UserID) []*UserTeam

func (*UserTeamQuery) GetAllBySlackTeamID

func (utq *UserTeamQuery) GetAllBySlackTeamID(teamID string) []*UserTeam

func (*UserTeamQuery) GetBySlackDomain

func (utq *UserTeamQuery) GetBySlackDomain(userID id.UserID, email, domain string) *UserTeam

func (*UserTeamQuery) GetFirstUserTeamForPortal

func (utq *UserTeamQuery) GetFirstUserTeamForPortal(portal *PortalKey) *UserTeam

func (*UserTeamQuery) New

func (utq *UserTeamQuery) New() *UserTeam

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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