mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
32 lines
674 B
Go
32 lines
674 B
Go
package disclosure
|
|
|
|
import (
|
|
"github.com/hanzoai/commerce/util/crypto/sha256"
|
|
"github.com/hanzoai/commerce/util/webhook"
|
|
)
|
|
|
|
// Hooks
|
|
|
|
func (d *Disclosure) BeforeUpdate(prev *Disclosure) error {
|
|
d.Hash = sha256.Hash(d.Publication + d.Type + d.Receiver + d.CreatedAt.String())
|
|
|
|
return nil
|
|
}
|
|
|
|
func (d *Disclosure) AfterCreate() error {
|
|
webhook.Emit(d.Context(), d.Namespace(), "disclosure.created", d)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (d *Disclosure) AfterUpdate(prev *Disclosure) error {
|
|
webhook.Emit(d.Context(), d.Namespace(), "user.updated", d)
|
|
return nil
|
|
}
|
|
|
|
func (d *Disclosure) AfterDelete() error {
|
|
webhook.Emit(d.Context(), d.Namespace(), "user.deleted", d)
|
|
|
|
return nil
|
|
}
|