storage

package
v4.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: BSD-2-Clause, BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventModel

func NewEventModel(dbFilePath string, encryption cryptoChannel.Cipher,
	msgCb MessageReceivedCallback, deleteCb DeletedMessageCallback,
	muteCb MuteCallback) (channels.EventModel, error)

NewEventModel initializes the channels.EventModel interface with appropriate backend.

Types

type Channel

type Channel struct {
	Id          []byte `gorm:"primaryKey;not null;autoIncrement:false"`
	Name        string `gorm:"not null"`
	Description string `gorm:"not null"`

	Messages []Message `gorm:"constraint:OnDelete:CASCADE"`
}

Channel defines the IndexedDb representation of a single Channel.

A Channel has many Message.

type DeletedMessageCallback

type DeletedMessageCallback func(messageID message.ID)

DeletedMessageCallback is called any time a message is deleted.

type Message

type Message struct {
	Id              uint64        `gorm:"primaryKey;autoIncrement:true"`
	Nickname        string        `gorm:"not null"`
	MessageId       []byte        `gorm:"uniqueIndex;not null"`
	ChannelId       []byte        `gorm:"index;not null"`
	ParentMessageId []byte        `gorm:"index"`
	Timestamp       time.Time     `gorm:"index;not null"`
	Lease           time.Duration `gorm:"not null"`
	Status          uint8         `gorm:"not null"`
	Text            []byte        `gorm:"not null"`
	Type            uint16        `gorm:"not null"`
	Round           uint64        `gorm:"not null"`

	// Pointer to enforce zero-value reading in ORM.
	Hidden *bool `gorm:"not null"`
	Pinned *bool `gorm:"index;not null"`

	// User cryptographic Identity struct -- could be pulled out
	Pubkey         []byte `gorm:"not null"`
	DmToken        uint32 `gorm:"not null"`
	CodesetVersion uint8  `gorm:"not null"`
}

Message defines the IndexedDb representation of a single Message.

A Message belongs to one Channel.

A Message may (informally) belong to one Message (Parent).

The user's nickname can change each message, but the rest does not. We still duplicate all of it for each entry to simplify code for now.

type MessageReceivedCallback

type MessageReceivedCallback func(uuid uint64, channelID *id.ID, update bool)

MessageReceivedCallback is called any time a message is received or updated.

update is true if the row is old and was edited.

type MuteCallback

type MuteCallback func(channelID *id.ID, pubKey ed25519.PublicKey, unmute bool)

MuteCallback is a callback provided for the MuteUser method of the impl.

Jump to

Keyboard shortcuts

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