inbox.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // Pagination
  33. Limit *int
  34. Offset *int
  35. }
  36. type DeleteInbox struct {
  37. ID int32
  38. }
  39. func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error) {
  40. return s.driver.CreateInbox(ctx, create)
  41. }
  42. func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error) {
  43. return s.driver.ListInboxes(ctx, find)
  44. }
  45. func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error) {
  46. return s.driver.UpdateInbox(ctx, update)
  47. }
  48. func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error {
  49. return s.driver.DeleteInbox(ctx, delete)
  50. }