This commit is contained in:
parent
671d18d2ba
commit
28a4f4121e
2 changed files with 148 additions and 0 deletions
57
web/shared/Note.go
Normal file
57
web/shared/Note.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package webshared
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/shared"
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
)
|
||||
|
||||
type Note struct {
|
||||
// ---- Section public data
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
ServerId uint `json:"server_id"`
|
||||
RawContent string `json:"raw_content"`
|
||||
ContentWarning *string `json:"content_warning"`
|
||||
RepliesToId *string `json:"replies_to_id"`
|
||||
QuotesId *string `json:"quotes_id"`
|
||||
AccessLevel uint8 `json:"access_level"`
|
||||
}
|
||||
|
||||
// Compile time interface implementation enforcement
|
||||
var _ shared.Clonable = &Note{}
|
||||
var _ shared.Sanitisable = &Note{}
|
||||
|
||||
func (note *Note) Sanitize() {
|
||||
}
|
||||
|
||||
func (note *Note) Clone() shared.Clonable {
|
||||
tmp := *note
|
||||
return &tmp
|
||||
}
|
||||
|
||||
func (n *Note) FromModel(m *models.Note) {
|
||||
n.ID = m.ID
|
||||
n.CreatedAt = m.CreatedAt
|
||||
n.CreatorId = m.CreatorId
|
||||
n.ServerId = m.OriginId
|
||||
n.RawContent = m.RawContent
|
||||
if m.ContentWarning.Valid {
|
||||
n.ContentWarning = &m.ContentWarning.String
|
||||
} else {
|
||||
n.ContentWarning = nil
|
||||
}
|
||||
if m.RepliesTo.Valid {
|
||||
n.RepliesToId = &m.RepliesTo.String
|
||||
} else {
|
||||
n.RepliesToId = nil
|
||||
}
|
||||
if m.Quotes.Valid {
|
||||
n.QuotesId = &m.Quotes.String
|
||||
} else {
|
||||
n.QuotesId = nil
|
||||
}
|
||||
n.AccessLevel = uint8(m.AccessLevel)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue