Documentation
¶
Index ¶
- Constants
- func GetChatMetadata(appMetadata []byte) *intentpb.ChatMetadata
- func GetContactDmPayment(appMetadata []byte) *intentpb.ChatMetadata_ContactDmPayment
- func GetDmPayment(appMetadata []byte) *intentpb.ChatMetadata_DmPayment
- func GetDmPaymentVerb(appMetadata []byte, createdAt time.Time) messagingpb.CashContent_Verb
- func NewIntegration(accounts account.Store, chats chat.Store, profiles profile.Store, ...) ocp_integration.SubmitIntent
- func NewSendContactDmPaymentMessageTask(intentRecord *ocp_intent.Record) *ocp_task.Record
- func NewSendDmPaymentMessageTask(intentRecord *ocp_intent.Record) *ocp_task.Record
- type Integration
- func (i *Integration) AllowCreation(ctx context.Context, intentRecord *ocp_intent.Record, ...) error
- func (i *Integration) GetTasksToSchedule(ctx context.Context, intentRecord *ocp_intent.Record) ([]*ocp_task.Record, error)
- func (i *Integration) OnSuccess(ctx context.Context, intentRecord *ocp_intent.Record) error
Constants ¶
const ( // TaskTypeSendContactDmPaymentMessage is the task that injects the cash // message into the sender and recipient's DM after a contact DM payment. TaskTypeSendContactDmPaymentMessage uint32 = 1 // TaskTypeSendDmPaymentMessage is the task that injects the cash message // into the sender and recipient's DM after a DM payment. TaskTypeSendDmPaymentMessage uint32 = 2 )
The OCP task system treats the type as an opaque app-owned namespace, so values must be globally unique across the app and stable forever — pending tasks in the DB reference them. Type 0 is reserved as invalid by the base system.
Variables ¶
This section is empty.
Functions ¶
func GetChatMetadata ¶ added in v1.15.0
func GetChatMetadata(appMetadata []byte) *intentpb.ChatMetadata
GetChatMetadata extracts the chat metadata from an intent's additional app metadata, if present. It returns nil when there is no app metadata, the metadata fails to decode, or it is not chat metadata.
This and the accessors below take the blob rather than the intent it came from, because the intent is not the only thing that carries it: a transaction history record passes the same bytes through unmodified, and decodes to the same metadata the intent was submitted with.
func GetContactDmPayment ¶ added in v1.15.0
func GetContactDmPayment(appMetadata []byte) *intentpb.ChatMetadata_ContactDmPayment
GetContactDmPayment extracts the contact DM payment from app metadata, if present. It returns nil when there is no app metadata, the metadata fails to decode, or it is not a contact DM payment.
func GetDmPayment ¶ added in v1.33.0
func GetDmPayment(appMetadata []byte) *intentpb.ChatMetadata_DmPayment
GetDmPayment extracts the DM payment from app metadata, if present. It returns nil when there is no app metadata, the metadata fails to decode, or it is not a DM payment.
func GetDmPaymentVerb ¶ added in v1.26.0
func GetDmPaymentVerb(appMetadata []byte, createdAt time.Time) messagingpb.CashContent_Verb
GetDmPaymentVerb reports how a DM payment created at createdAt should be rendered. A DM payment is a tip only when its action is TIP; SEND and the unset DEFAULT are plain sends, from either location, except for payments created before sendByDefaultCutoff. Everything else, contact DM payments included, is a plain send.
Both the cash message injected into the DM and the sender's activity feed entry render off this, so they cannot disagree about what a payment was. createdAt is the intent's creation time, which OCP sets before validation and copies onto the intent's history records, so every caller passes the same time for the same payment.
func NewIntegration ¶
func NewIntegration( accounts account.Store, chats chat.Store, profiles profile.Store, mintDataProvider *ocp_currency_util.MintDataProvider, teamUserID *commonpb.UserId, ) ocp_integration.SubmitIntent
NewIntegration constructs the intent integration. teamUserID is the Flipcash team account, which the parent resolves once at startup with flipcashteam.GetUserID and passes to the chat store, the chat RuleEvaluator, the chat server and the Sender too; nil names no one.
func NewSendContactDmPaymentMessageTask ¶ added in v1.15.0
func NewSendContactDmPaymentMessageTask(intentRecord *ocp_intent.Record) *ocp_task.Record
NewSendContactDmPaymentMessageTask creates the task that injects the cash message into the sender and recipient's DM after a contact DM payment. Only the intent ID is carried, via the reference ID; the executor reloads the authoritative intent record at execution time.
func NewSendDmPaymentMessageTask ¶ added in v1.33.0
func NewSendDmPaymentMessageTask(intentRecord *ocp_intent.Record) *ocp_task.Record
NewSendDmPaymentMessageTask creates the task that injects the cash message into the sender and recipient's DM after a DM payment. Only the intent ID is carried, via the reference ID; the executor reloads the authoritative intent record at execution time.
Types ¶
type Integration ¶
type Integration struct {
// contains filtered or unexported fields
}
func (*Integration) AllowCreation ¶
func (i *Integration) AllowCreation(ctx context.Context, intentRecord *ocp_intent.Record, metadata *ocp_transactionpb.Metadata, actions []*ocp_transactionpb.Action) error
func (*Integration) GetTasksToSchedule ¶ added in v1.15.0
func (i *Integration) GetTasksToSchedule(ctx context.Context, intentRecord *ocp_intent.Record) ([]*ocp_task.Record, error)
GetTasksToSchedule returns the guaranteed work derived from a submitted intent. A DM payment of either type (contact DM or DM) schedules the cash message injected into the DM between the sender and recipient; execution is handled by task.Executor.
func (*Integration) OnSuccess ¶
func (i *Integration) OnSuccess(ctx context.Context, intentRecord *ocp_intent.Record) error