database

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserPortalTypeDM     = "dm"
	UserPortalTypeGuild  = "guild"
	UserPortalTypeThread = "thread"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*dbutil.Database

	User     *UserQuery
	Portal   *PortalQuery
	Puppet   *PuppetQuery
	Message  *MessageQuery
	Thread   *ThreadQuery
	Reaction *ReactionQuery
	Guild    *GuildQuery
	Role     *RoleQuery
	File     *FileQuery
}

func New

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

type File

type File struct {
	URL       string
	Encrypted bool
	MXC       id.ContentURI

	ID        string
	EmojiName string

	Size     int
	Width    int
	Height   int
	MimeType string

	DecryptionInfo *attachment.EncryptedFile
	Timestamp      time.Time
	// contains filtered or unexported fields
}

func (*File) Delete

func (f *File) Delete()

func (*File) Insert

func (f *File) Insert(txn dbutil.Execable)

func (*File) Scan

func (f *File) Scan(row dbutil.Scannable) *File

type FileQuery

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

func (*FileQuery) Get

func (fq *FileQuery) Get(url string, encrypted bool) *File

func (*FileQuery) GetEmojiByMXC added in v0.5.0

func (fq *FileQuery) GetEmojiByMXC(mxc id.ContentURI) *File

func (*FileQuery) New

func (fq *FileQuery) New() *File

type Guild

type Guild struct {
	ID        string
	MXID      id.RoomID
	PlainName string
	Name      string
	NameSet   bool
	Avatar    string
	AvatarURL id.ContentURI
	AvatarSet bool

	BridgingMode GuildBridgingMode
	// contains filtered or unexported fields
}

func (*Guild) Delete

func (g *Guild) Delete()

func (*Guild) Insert

func (g *Guild) Insert()

func (*Guild) Scan

func (g *Guild) Scan(row dbutil.Scannable) *Guild

func (*Guild) Update

func (g *Guild) Update()

type GuildBridgingMode added in v0.2.0

type GuildBridgingMode int
const (
	// GuildBridgeNothing tells the bridge to never bridge messages, not even checking if a portal exists.
	GuildBridgeNothing GuildBridgingMode = iota
	// GuildBridgeIfPortalExists tells the bridge to bridge messages in channels that already have portals.
	GuildBridgeIfPortalExists
	// GuildBridgeCreateOnMessage tells the bridge to create portals as soon as a message is received.
	GuildBridgeCreateOnMessage
	// GuildBridgeEverything tells the bridge to proactively create portals on startup and when receiving channel create notifications.
	GuildBridgeEverything

	GuildBridgeInvalid GuildBridgingMode = -1
)

func ParseGuildBridgingMode added in v0.2.0

func ParseGuildBridgingMode(str string) GuildBridgingMode

func (GuildBridgingMode) Description added in v0.2.0

func (gbm GuildBridgingMode) Description() string

func (GuildBridgingMode) String added in v0.2.0

func (gbm GuildBridgingMode) String() string

type GuildQuery

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

func (*GuildQuery) GetAll

func (gq *GuildQuery) GetAll() []*Guild

func (*GuildQuery) GetByID

func (gq *GuildQuery) GetByID(dcid string) *Guild

func (*GuildQuery) GetByMXID

func (gq *GuildQuery) GetByMXID(mxid id.RoomID) *Guild

func (*GuildQuery) New

func (gq *GuildQuery) New() *Guild

type Message

type Message struct {
	DiscordID     string
	AttachmentID  string
	Channel       PortalKey
	SenderID      string
	Timestamp     time.Time
	EditTimestamp time.Time
	ThreadID      string

	MXID       id.EventID
	SenderMXID id.UserID
	// contains filtered or unexported fields
}

func (*Message) Delete

func (m *Message) Delete()

func (*Message) DiscordProtoChannelID

func (m *Message) DiscordProtoChannelID() string

func (*Message) Insert

func (m *Message) Insert()

func (*Message) MassInsertParts added in v0.3.0

func (m *Message) MassInsertParts(msgs []MessagePart)

func (*Message) Scan

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

func (*Message) UpdateEditTimestamp added in v0.4.0

func (m *Message) UpdateEditTimestamp(ts time.Time)

type MessagePart

type MessagePart struct {
	AttachmentID string
	MXID         id.EventID
}

type MessageQuery

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

func (*MessageQuery) DeleteAll

func (mq *MessageQuery) DeleteAll(key PortalKey)

func (*MessageQuery) GetByDiscordID

func (mq *MessageQuery) GetByDiscordID(key PortalKey, discordID string) []*Message

func (*MessageQuery) GetByMXID

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

func (*MessageQuery) GetClosestBefore

func (mq *MessageQuery) GetClosestBefore(key PortalKey, threadID string, ts time.Time) *Message

func (*MessageQuery) GetFirstByDiscordID

func (mq *MessageQuery) GetFirstByDiscordID(key PortalKey, discordID string) *Message

func (*MessageQuery) GetLast added in v0.3.0

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

func (*MessageQuery) GetLastByDiscordID

func (mq *MessageQuery) GetLastByDiscordID(key PortalKey, discordID string) *Message

func (*MessageQuery) GetLastInThread

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

func (*MessageQuery) MassInsert added in v0.3.0

func (mq *MessageQuery) MassInsert(key PortalKey, msgs []Message)

func (*MessageQuery) New

func (mq *MessageQuery) New() *Message

type Portal

type Portal struct {
	Key         PortalKey
	Type        discordgo.ChannelType
	OtherUserID string
	ParentID    string
	GuildID     string

	MXID id.RoomID

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

	FirstEventID id.EventID

	RelayWebhookID     string
	RelayWebhookSecret string
	// contains filtered or unexported fields
}

func (*Portal) Delete

func (p *Portal) Delete()

func (*Portal) Insert

func (p *Portal) Insert()

func (*Portal) Scan

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

func (*Portal) Update

func (p *Portal) Update()

type PortalKey

type PortalKey struct {
	ChannelID string
	Receiver  string
}

func NewPortalKey

func NewPortalKey(channelID, receiver string) PortalKey

func (PortalKey) String

func (key PortalKey) String() string

type PortalQuery

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

func (*PortalQuery) FindPrivateChatBetween added in v0.4.0

func (pq *PortalQuery) FindPrivateChatBetween(id, receiver string) *Portal

func (*PortalQuery) FindPrivateChatsOf

func (pq *PortalQuery) FindPrivateChatsOf(receiver string) []*Portal

func (*PortalQuery) FindPrivateChatsWith

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

func (*PortalQuery) GetAll

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

func (*PortalQuery) GetAllInGuild

func (pq *PortalQuery) GetAllInGuild(guildID string) []*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 {
	ID        string
	Name      string
	NameSet   bool
	Avatar    string
	AvatarURL id.ContentURI
	AvatarSet bool

	ContactInfoSet bool

	GlobalName    string
	Username      string
	Discriminator string
	IsBot         bool
	IsWebhook     bool
	IsApplication bool

	CustomMXID  id.UserID
	AccessToken string
	NextBatch   string
	// 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(id string) *Puppet

func (*PuppetQuery) GetAll

func (pq *PuppetQuery) GetAll() []*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
	MessageID string
	Sender    string
	EmojiName string
	ThreadID  string

	MXID id.EventID

	FirstAttachmentID string
	// contains filtered or unexported fields
}

func (*Reaction) Delete

func (r *Reaction) Delete()

func (*Reaction) DiscordProtoChannelID

func (r *Reaction) DiscordProtoChannelID() string

func (*Reaction) Insert

func (r *Reaction) Insert()

func (*Reaction) Scan

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

type ReactionQuery

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

func (*ReactionQuery) GetAllForMessage

func (rq *ReactionQuery) GetAllForMessage(key PortalKey, discordMessageID string) []*Reaction

func (*ReactionQuery) GetByDiscordID

func (rq *ReactionQuery) GetByDiscordID(key PortalKey, msgID, sender, emojiName string) *Reaction

func (*ReactionQuery) GetByMXID

func (rq *ReactionQuery) GetByMXID(mxid id.EventID) *Reaction

func (*ReactionQuery) New

func (rq *ReactionQuery) New() *Reaction

type Role

type Role struct {
	GuildID string

	discordgo.Role
	// contains filtered or unexported fields
}

func (*Role) Delete

func (r *Role) Delete(txn dbutil.Execable)

func (*Role) Scan

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

func (*Role) Upsert

func (r *Role) Upsert(txn dbutil.Execable)

type RoleQuery

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

func (*RoleQuery) DeleteByID

func (rq *RoleQuery) DeleteByID(guildID, dcid string)

func (*RoleQuery) GetAll

func (rq *RoleQuery) GetAll(guildID string) []*Role

func (*RoleQuery) GetByID

func (rq *RoleQuery) GetByID(guildID, dcid string) *Role

func (*RoleQuery) New

func (rq *RoleQuery) New() *Role

type Thread

type Thread struct {
	ID       string
	ParentID string

	RootDiscordID string
	RootMXID      id.EventID

	CreationNoticeMXID id.EventID
	// contains filtered or unexported fields
}

func (*Thread) Delete

func (t *Thread) Delete()

func (*Thread) Insert

func (t *Thread) Insert()

func (*Thread) Scan

func (t *Thread) Scan(row dbutil.Scannable) *Thread

func (*Thread) Update

func (t *Thread) Update()

type ThreadQuery

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

func (*ThreadQuery) GetByDiscordID

func (tq *ThreadQuery) GetByDiscordID(discordID string) *Thread

func (*ThreadQuery) GetByMatrixRootMsg

func (tq *ThreadQuery) GetByMatrixRootMsg(mxid id.EventID) *Thread

func (*ThreadQuery) GetByMatrixRootOrCreationNoticeMsg

func (tq *ThreadQuery) GetByMatrixRootOrCreationNoticeMsg(mxid id.EventID) *Thread

func (*ThreadQuery) New

func (tq *ThreadQuery) New() *Thread

type User

type User struct {
	MXID           id.UserID
	DiscordID      string
	DiscordToken   string
	ManagementRoom id.RoomID
	SpaceRoom      id.RoomID
	DMSpaceRoom    id.RoomID

	ReadStateVersion int
	// contains filtered or unexported fields
}

func (*User) GetPortals

func (u *User) GetPortals() []UserPortal

func (*User) Insert

func (u *User) Insert()

func (*User) IsInPortal

func (u *User) IsInPortal(discordID string) (isIn bool)

func (*User) IsInSpace

func (u *User) IsInSpace(discordID string) (isIn bool)

func (*User) MarkInPortal

func (u *User) MarkInPortal(portal UserPortal)

func (*User) MarkNotInPortal

func (u *User) MarkNotInPortal(discordID string)

func (*User) PortalHasOtherUsers

func (u *User) PortalHasOtherUsers(discordID string) (hasOtherUsers bool)

func (*User) PrunePortalList

func (u *User) PrunePortalList(beforeTS time.Time) []UserPortal

func (*User) Scan

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

func (*User) Update

func (u *User) Update()

type UserPortal

type UserPortal struct {
	DiscordID string
	Type      string
	Timestamp time.Time
	InSpace   bool
}

func (UserPortal) Scan

func (up UserPortal) Scan(l log.Logger, row dbutil.Scannable) *UserPortal

type UserQuery

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

func (*UserQuery) GetAllWithToken

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

func (*UserQuery) GetByID

func (uq *UserQuery) GetByID(id string) *User

func (*UserQuery) GetByMXID

func (uq *UserQuery) GetByMXID(userID id.UserID) *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