chat

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

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

	// 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,
		},
		KinPurchasesName: {
			TitleLocalizationKey: localization.ChatTitleKinPurchases,
			CanMute:              true,
			CanUnsubscribe:       false,
		},
		PaymentsName: {
			TitleLocalizationKey: localization.ChatTitlePayments,
			CanMute:              true,
			CanUnsubscribe:       false,
		},
		TipsName: {
			TitleLocalizationKey: localization.ChatTitleTips,
			CanMute:              true,
			CanUnsubscribe:       false,
		},

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

Functions

func GetKinPurchasesChatId added in v1.7.4

func GetKinPurchasesChatId(owner *common.Account) chat.ChatId

GetKinPurchasesChatId returns the chat ID for the Kin Purchases chat for a given owner account

func NewUsdcBeingConvertedMessage added in v1.3.0

func NewUsdcBeingConvertedMessage(ts time.Time) (*chatpb.ChatMessage, error)

NewUsdcBeingConvertedMessage generates a new message generated upon initiating a USDC swap to be inserted into the Kin Purchases chat.

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

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 SendCodeTeamMessage added in v1.3.0

func SendCodeTeamMessage(ctx context.Context, data code_data.Provider, receiver *common.Account, chatMessage *chatpb.ChatMessage) (bool, error)

SendCodeTeamMessage sends a message to the Code Team chat.

func SendKinPurchasesMessage added in v1.6.0

func SendKinPurchasesMessage(ctx context.Context, data code_data.Provider, receiver *common.Account, chatMessage *chatpb.ChatMessage) (bool, error)

SendKinPurchasesMessage sends a message to the Kin Purchases chat.

func ToBlockchainMessage

func ToBlockchainMessage(
	signature string,
	sender *common.Account,
	blockchainMessage *thirdparty.NaclBoxBlockchainMessage,
	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 ToKinAvailableForUseMessage added in v1.3.0

func ToKinAvailableForUseMessage(signature string, ts time.Time, purchases ...*transactionpb.ExchangeDataWithoutRate) (*chatpb.ChatMessage, error)

ToKinAvailableForUseMessage turns details of a USDC swap transaction into a chat message to be inserted into the Kin Purchases 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 ToUsdcDepositedMessage added in v1.3.0

func ToUsdcDepositedMessage(signature string, ts time.Time) (*chatpb.ChatMessage, error)

ToUsdcDepositedMessage turns details of a USDC deposit transaction into a chat message to be inserted into the Kin Purchases 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, actionRecords []*action.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

func SendTipsExchangeMessage added in v1.10.0

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

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

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