got even further in database proper interface prototyping
This commit is contained in:
+41
-29
@@ -11,7 +11,7 @@ type DB interface {
|
||||
Users() Users
|
||||
Subscriptions() Subscriptions
|
||||
Files() Files
|
||||
Email() Email
|
||||
Emails() Emails
|
||||
Messages() Messages
|
||||
Posts() Posts
|
||||
Reactions() Reactions
|
||||
@@ -34,7 +34,7 @@ type User struct {
|
||||
Bio string `json:"bio" gob:"3"`
|
||||
PublicKey []byte `json:"publicKey" gob:"4"`
|
||||
Avatar uuid.UUID `json:"avatar" gob:"5"`
|
||||
Subscribers int `json:"subscribers" gob:"-"` // count managed by subscriptions module
|
||||
Subscribers int `json:"subscribers" gob:"-"`
|
||||
}
|
||||
|
||||
type Subscriptions interface {
|
||||
@@ -59,27 +59,26 @@ type Files interface {
|
||||
Size(id uuid.UUID) (int64, error)
|
||||
}
|
||||
|
||||
type Email interface {
|
||||
Put(user string, letter Letter) (uid string, err error)
|
||||
Get(user, uid string) (Letter, error)
|
||||
type Emails interface {
|
||||
Put(user string, letter Letter) (id uuid.UUID, err error)
|
||||
Get(user string, id uuid.UUID) (Letter, error)
|
||||
List(user string, limit, offset int) ([]Letter, error)
|
||||
MarkSeen(user, uid string) error
|
||||
Delete(user, uid string) error
|
||||
Attachment(user, uid, id string) (Attachment, error)
|
||||
MarkSeen(user string, id uuid.UUID) error
|
||||
Delete(user string, id uuid.UUID) error
|
||||
}
|
||||
|
||||
type Letter struct {
|
||||
UID string `json:"uid" gob:"-"`
|
||||
ID uuid.UUID `json:"id" gob:"-"`
|
||||
From string `json:"from" gob:"1"`
|
||||
Subject string `json:"subject" gob:"2"`
|
||||
Date time.Time `json:"date" gob:"-"`
|
||||
Body []byte `json:"body" gob:"-"`
|
||||
Seen bool `json:"bool" gob:"3"`
|
||||
Seen bool `json:"seen" gob:"3"`
|
||||
Attachments []Attachment `json:"attachments" gob:"4"`
|
||||
}
|
||||
|
||||
type Attachment struct {
|
||||
ID string `json:"id" gob:"1"`
|
||||
ID uuid.UUID `json:"id" gob:"1"`
|
||||
Filename string `json:"filename" gob:"2"`
|
||||
Size int64 `json:"size" gob:"3"`
|
||||
MimeType string `json:"mimeType" gob:"4"`
|
||||
@@ -87,42 +86,55 @@ type Attachment struct {
|
||||
}
|
||||
|
||||
type Messages interface {
|
||||
Put(msg Message) (uid string, err error)
|
||||
Get(uid string) (Message, error)
|
||||
Put(msg Message) (id uuid.UUID, err error)
|
||||
Get(id uuid.UUID) (Message, error)
|
||||
List(user string, limit, offset int) ([]Message, error)
|
||||
Delete(uid string) error
|
||||
Delete(id uuid.UUID) error
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
UID string `json:"uid" gob:"-"`
|
||||
ID uuid.UUID `json:"id" gob:"-"`
|
||||
From string `json:"from" gob:"1"`
|
||||
To string `json:"to" gob:"2"`
|
||||
Date time.Time `json:"date" gob:"-"`
|
||||
Payload []byte `json:"payload" gob:"3"`
|
||||
Sig []byte `json:"-" gob:"4"`
|
||||
}
|
||||
|
||||
type Posts interface {
|
||||
Create(post Post) (uid string, err error)
|
||||
Get(uid string) (Post, error)
|
||||
Create(post Post) (id uuid.UUID, err error)
|
||||
Get(id uuid.UUID) (Post, error)
|
||||
List(user string, limit, offset int) ([]Post, error)
|
||||
Update(uid string, post Post) error
|
||||
Delete(uid string) error
|
||||
Update(id uuid.UUID, post Post) error
|
||||
Delete(id uuid.UUID) error
|
||||
}
|
||||
|
||||
type Post struct {
|
||||
UID string `json:"uid" gob:"-"`
|
||||
Author string `json:"author" gob:"1"`
|
||||
Title string `json:"title" gob:"2"`
|
||||
Body string `json:"body" gob:"3"`
|
||||
Date time.Time `json:"date" gob:"-"`
|
||||
Tags []string `json:"tags" gob:"4"`
|
||||
Attachments []Attachment `json:"attachments" gob:"5"`
|
||||
Signature []byte `json:"signature" gob:"6"`
|
||||
ID uuid.UUID `json:"id" gob:"-"`
|
||||
Author string `json:"author" gob:"1"`
|
||||
Title string `json:"title" gob:"2"`
|
||||
Body string `json:"body" gob:"-"`
|
||||
Date time.Time `json:"date" gob:"-"`
|
||||
Tags []string `json:"tags" gob:"3"`
|
||||
Attachment []Attachment `json:"attachment" gob:"4"`
|
||||
Sig []byte `json:"-" gob:"5"`
|
||||
}
|
||||
|
||||
type Reactions interface {
|
||||
SetAllowed(typ, id string, emojis []string) error
|
||||
ListAllowed(typ, id string) ([]string, error)
|
||||
SetAllowed(typ string, id uuid.UUID, emojis []string) error
|
||||
ListAllowed(typ string, id uuid.UUID) ([]string, error)
|
||||
|
||||
AddReaction(typ string, id uuid.UUID, domain, emoji string, sig []byte) error
|
||||
RemoveReaction(typ string, id uuid.UUID, domain, emoji string) error
|
||||
|
||||
IncrementPerDomain(typ string, id uuid.UUID, domain, emoji string) error
|
||||
DecrementPerDomain(typ string, id uuid.UUID, domain, emoji string) error
|
||||
ListReactions(typ string, id uuid.UUID) ([]ReactionCounter, error)
|
||||
}
|
||||
|
||||
type ReactionCounter struct {
|
||||
Emoji string `json:"emoji"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type Comments interface {
|
||||
|
||||
@@ -63,7 +63,7 @@ func (d *DB) Files() database.Files {
|
||||
return d.files
|
||||
}
|
||||
|
||||
func (d *DB) Email() database.Email {
|
||||
func (d *DB) Email() database.Emails {
|
||||
return d.email
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user