✨ Basically move messages to events
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
package models
|
||||
|
||||
// Account profiles basically fetched from Hydrogen.Identity
|
||||
// But cache at here for better usage
|
||||
// At the same time this model can make relations between local models
|
||||
// But cached at here for better usage
|
||||
// At the same time, this model can make relations between local models
|
||||
type Account struct {
|
||||
BaseModel
|
||||
|
||||
|
@ -14,7 +14,7 @@ type Channel struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Members []ChannelMember `json:"members"`
|
||||
Messages []Message `json:"messages"`
|
||||
Messages []Event `json:"messages"`
|
||||
Calls []Call `json:"calls"`
|
||||
Type ChannelType `json:"type"`
|
||||
Account Account `json:"account"`
|
||||
@ -44,6 +44,6 @@ type ChannelMember struct {
|
||||
Notify NotifyLevel `json:"notify"`
|
||||
PowerLevel int `json:"power_level"`
|
||||
|
||||
Calls []Call `json:"calls" gorm:"foreignKey:FounderID"`
|
||||
Messages []Message `json:"messages" gorm:"foreignKey:SenderID"`
|
||||
Calls []Call `json:"calls" gorm:"foreignKey:FounderID"`
|
||||
Events []Event `json:"events" gorm:"foreignKey:SenderID"`
|
||||
}
|
||||
|
33
pkg/internal/models/events.go
Normal file
33
pkg/internal/models/events.go
Normal file
@ -0,0 +1,33 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/datatypes"
|
||||
|
||||
const (
|
||||
EventMessageNew = "messages.new"
|
||||
EventMessageEdit = "messages.edit"
|
||||
EventMessageDelete = "messages.delete"
|
||||
EventSystemChanges = "system.changes"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
BaseModel
|
||||
|
||||
Uuid string `json:"uuid"`
|
||||
Body datatypes.JSONMap `json:"body"`
|
||||
Type string `json:"type"`
|
||||
Channel Channel `json:"channel"`
|
||||
Sender ChannelMember `json:"sender"`
|
||||
ChannelID uint `json:"channel_id"`
|
||||
SenderID uint `json:"sender_id"`
|
||||
}
|
||||
|
||||
// Event Payloads
|
||||
|
||||
type EventMessageBody struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
Algorithm string `json:"algorithm,omitempty"`
|
||||
Attachments []uint `json:"attachments,omitempty"`
|
||||
QuoteEvent uint `json:"quote_event,omitempty"`
|
||||
RelatedEvent uint `json:"related_event,omitempty"`
|
||||
RelatedUsers []uint `json:"related_users,omitempty"`
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/datatypes"
|
||||
|
||||
const (
|
||||
MessageTextType = "m.text"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
BaseModel
|
||||
|
||||
Uuid string `json:"uuid"`
|
||||
Content datatypes.JSONMap `json:"content"`
|
||||
Type string `json:"type"`
|
||||
Attachments datatypes.JSONSlice[uint] `json:"attachments"`
|
||||
Channel Channel `json:"channel"`
|
||||
Sender ChannelMember `json:"sender"`
|
||||
ReplyID *uint `json:"reply_id"`
|
||||
ReplyTo *Message `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
||||
ChannelID uint `json:"channel_id"`
|
||||
SenderID uint `json:"sender_id"`
|
||||
}
|
Reference in New Issue
Block a user