chat

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CashTransactionsName = "Cash Transactions" // Renamed to Cash Payments on client
	CodeTeamName         = "Code Team"
	PaymentsName         = "Payments" // Renamed to Web Payments on client

	// Test chats used for unit/integration testing only
	TestCantMuteName        = "TestCantMute"
	TestCantUnsubscribeName = "TestCantUnsubscribe"
)

Variables

View Source
var (
	InternalChatProperties = map[string]struct {
		TitleLocalizationKey string
		CanMute              bool
		CanUnsubscribe       bool
	}{
		CashTransactionsName: {
			TitleLocalizationKey: localization.ChatTitleCashTransactions,
			CanMute:              true,
			CanUnsubscribe:       false,
		},
		CodeTeamName: {
			TitleLocalizationKey: localization.ChatTitleCodeTeam,
			CanMute:              true,
			CanUnsubscribe:       false,
		},
		PaymentsName: {
			TitleLocalizationKey: localization.ChatTitlePayments,
			CanMute:              true,
			CanUnsubscribe:       false,
		},

		TestCantMuteName: {
			TitleLocalizationKey: "n/a",
			CanMute:              false,
			CanUnsubscribe:       true,
		},
		TestCantUnsubscribeName: {
			TitleLocalizationKey: "n/a",
			CanMute:              true,
			CanUnsubscribe:       false,
		},
	}
)

Functions

func SendCashTransactionsExchangeMessage

func SendCashTransactionsExchangeMessage(ctx context.Context, data code_data.Provider, intentRecord *intent.Record) error

SendCashTransactionsExchangeMessage sends a message to the Cash Transactions chat with exchange data content related to the submitted intent. Intents that don't belong in the Cash Transactions chat will be ignored.

Note: Tests covered in SubmitIntent history tests

todo: How are we handling relationship account flows?

func SendChatMessage

func SendChatMessage(
	ctx context.Context,
	data code_data.Provider,
	chatTitle string,
	chatType chat.ChatType,
	isVerifiedChat bool,
	receiver *common.Account,
	protoMessage *chatpb.ChatMessage,
	isSilentMessage bool,
) (canPushMessage bool, err error)

SendChatMessage sends a chat message to a receiving owner account.

Note: This function is not responsible for push notifications. This method might be called within the context of a DB transaction, which might have unrelated failures. A hint as to whether a push should be sent is provided.

func ToBlockchainMessage

func ToBlockchainMessage(
	signature string,
	sender *common.Account,
	blockchainMessage *thirdparty.BlockchainMessage,
	ts time.Time,
) (*chatpb.ChatMessage, error)

ToBlockchainMessage takes a raw blockchain message and turns it into a protobuf chat message that can be injected into the merchant domain's chat.

func ToReferralBonusMessage

func ToReferralBonusMessage(intentRecord *intent.Record) (*chatpb.ChatMessage, error)

ToReferralBonusMessage turns the intent record into a referral bonus chat message to be inserted into the Code Team chat.

func ToWelcomeBonusMessage

func ToWelcomeBonusMessage(intentRecord *intent.Record) (*chatpb.ChatMessage, error)

ToWelcomeBonusMessage turns the intent record into a welcome bonus chat message to be inserted into the Code Team chat.

Types

type MessageWithOwner added in v1.1.4

type MessageWithOwner struct {
	Owner   *common.Account
	Title   string
	Message *chatpb.ChatMessage
}

func SendMerchantExchangeMessage

func SendMerchantExchangeMessage(ctx context.Context, data code_data.Provider, intentRecord *intent.Record) ([]*MessageWithOwner, error)

SendMerchantExchangeMessage sends a message to the merchant's chat with exchange data content related to the submitted intent. Intents that don't belong in the merchant chat will be ignored. The set of chat messages that should be pushed are returned.

Note: Tests covered in SubmitIntent history tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL