Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEventModel ¶
func NewEventModel(dbFilePath string, cbs Callbacks) (dm.EventModel, error)
NewEventModel initializes the dm.EventModel interface with appropriate backend.
Types ¶
type Callbacks ¶ added in v4.7.1
type Callbacks interface { // MessageReceived is called any time a message is received or updated. // // messageUpdate is true if the message already exists and was edited. // conversationUpdate is true if the conversation was created or modified. MessageReceived(uuid uint64, pubKey ed25519.PublicKey, messageUpdate, conversationUpdate bool) // MessageDeleted is called when a message is deleted. MessageDeleted(messageID message.ID) }
Callbacks contains callbacks that are used by this event model implementation.
type Conversation ¶
type Conversation struct { Pubkey []byte `gorm:"primaryKey;not null;autoIncrement:false"` Nickname string `gorm:"not null"` Token uint32 `gorm:"not null"` CodesetVersion uint8 `gorm:"not null"` // Timestamp for when a conversation is blocked. If the conversation has // not been blocked, this will be a zero value. BlockedTimestamp *time.Time `gorm:""` // Have to spell out this relationship because irregular PK name Messages []Message `gorm:"foreignKey:ConversationPubKey;references:Pubkey;constraint:OnDelete:CASCADE"` }
Conversation defines the IndexedDb representation of a single message exchange between two recipients. A Conversation has many Message objects.
func (Conversation) TableName ¶
func (Conversation) TableName() string
TableName overrides the table name used by Message.
type Message ¶
type Message struct { Id int64 `gorm:"primaryKey;autoIncrement:true"` MessageId []byte `gorm:"uniqueIndex;not null"` ConversationPubKey []byte `gorm:"index;not null"` ParentMessageId []byte Timestamp time.Time `gorm:"index;not null"` SenderPubKey []byte `gorm:"index;not null"` CodesetVersion uint8 `gorm:"not null"` Status uint8 `gorm:"not null"` Text []byte `gorm:"not null"` Type uint16 `gorm:"not null"` Round int64 `gorm:"not null"` }
Message defines the IndexedDb representation of a single Message.
A Message belongs to one Conversation. A Message may belong to one Message (Parent).
type MessageReceivedCallback ¶
type MessageReceivedCallback func( uuid uint64, pubKey ed25519.PublicKey, messageUpdate, conversationUpdate bool)
MessageReceivedCallback is called any time a message is received or updated.
messageUpdate is true if the Message already exists and was edited. conversationUpdate is true if the Conversation was created or modified.