inbox.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package store
  2. import (
  3. "context"
  4. storepb "github.com/usememos/memos/proto/gen/store"
  5. )
  6. // InboxStatus is the status for an inbox.
  7. type InboxStatus string
  8. const (
  9. UNREAD InboxStatus = "UNREAD"
  10. ARCHIVED InboxStatus = "ARCHIVED"
  11. )
  12. func (s InboxStatus) String() string {
  13. return string(s)
  14. }
  15. type Inbox struct {
  16. ID int32
  17. CreatedTs int64
  18. SenderID int32
  19. ReceiverID int32
  20. Status InboxStatus
  21. Message *storepb.InboxMessage
  22. }
  23. type UpdateInbox struct {
  24. ID int32
  25. Status InboxStatus
  26. }
  27. type FindInbox struct {
  28. ID *int32
  29. SenderID *int32
  30. ReceiverID *int32
  31. Status *InboxStatus
  32. }
  33. type DeleteInbox struct {
  34. ID int32
  35. }
  36. func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error) {
  37. return s.driver.CreateInbox(ctx, create)
  38. }
  39. func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error) {
  40. return s.driver.ListInboxes(ctx, find)
  41. }
  42. func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error) {
  43. return s.driver.UpdateInbox(ctx, update)
  44. }
  45. func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error {
  46. return s.driver.DeleteInbox(ctx, delete)
  47. }