webhook.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package store
  2. import (
  3. "context"
  4. storepb "github.com/usememos/memos/proto/gen/store"
  5. )
  6. type FindWebhook struct {
  7. ID *int32
  8. CreatorID *int32
  9. }
  10. type UpdateWebhook struct {
  11. ID int32
  12. RowStatus *storepb.RowStatus
  13. Name *string
  14. URL *string
  15. }
  16. type DeleteWebhook struct {
  17. ID int32
  18. }
  19. func (s *Store) CreateWebhook(ctx context.Context, create *storepb.Webhook) (*storepb.Webhook, error) {
  20. return s.driver.CreateWebhook(ctx, create)
  21. }
  22. func (s *Store) ListWebhooks(ctx context.Context, find *FindWebhook) ([]*storepb.Webhook, error) {
  23. return s.driver.ListWebhooks(ctx, find)
  24. }
  25. func (s *Store) GetWebhooks(ctx context.Context, find *FindWebhook) (*storepb.Webhook, error) {
  26. list, err := s.ListWebhooks(ctx, find)
  27. if err != nil {
  28. return nil, err
  29. }
  30. if len(list) == 0 {
  31. return nil, nil
  32. }
  33. return list[0], nil
  34. }
  35. func (s *Store) UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*storepb.Webhook, error) {
  36. return s.driver.UpdateWebhook(ctx, update)
  37. }
  38. func (s *Store) DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error {
  39. return s.driver.DeleteWebhook(ctx, delete)
  40. }