Skip to content

chats: add (temporary) plumbing for tip notifications. #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 71 commits into
base: two-way-chats
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0348502
Fix Twitter user info update worker when username is changed (#173)
jeffyanta Aug 23, 2024
0714a15
Add auto-reply to Twitter registration tweets (#174)
jeffyanta Sep 9, 2024
8401d3e
Handle the case where a Twitter user is suspended in the info update …
jeffyanta Sep 9, 2024
80b6dd1
Update Twitter connection reply text (#176)
jeffyanta Sep 10, 2024
e7031b5
update intent DB models to support pay-for-chat intents (#186)
mfycheng Sep 17, 2024
c55e811
PoC in memory two way messaging
jeffyanta May 15, 2024
081cbf3
Move chat event stream notification into an async worker
jeffyanta May 17, 2024
f112a51
Ensure chat event streams are cleaned up after being closed
jeffyanta May 17, 2024
9a8c990
Add support for thank you messages
jeffyanta May 21, 2024
6db76d3
Rename struct
jeffyanta May 21, 2024
9bbf3ac
Fill out missing log message
jeffyanta May 21, 2024
39b257e
Add basic push support for user messages
jeffyanta May 22, 2024
540f868
Use separate context for pushing user chat messages
jeffyanta May 22, 2024
8185b9e
Move existing chat stuff to v1 in prep for v2
jeffyanta Jun 7, 2024
2ef1e02
Add skeleton for v2 gRPC chat service
jeffyanta Jun 7, 2024
23a9aa0
Define chat v2 models
jeffyanta Jun 7, 2024
3035a8f
Implement RPCs that operate on chat member state
jeffyanta Jun 7, 2024
577f4cc
Implement StreamChatEvents with integration of pointer events
jeffyanta Jun 7, 2024
8585a38
Implement GetMessages RPC
jeffyanta Jun 7, 2024
24e8218
Add reminder to add a flush on StreamChatEvents
jeffyanta Jun 7, 2024
b6d0756
Add a flush on StreamChatEvents stream open
jeffyanta Jun 10, 2024
451b155
Fix todo comment
jeffyanta Jun 10, 2024
c6d5b88
Add missing query parameters to flush
jeffyanta Jun 10, 2024
e29f899
Implement the SendMessage RPC without consideration for other chat fe…
jeffyanta Jun 10, 2024
db4877c
Skeleton for minimal memory PoC chat v2 data store
jeffyanta Jun 10, 2024
e300533
Implement chat v2 memory data store (WIP)
jeffyanta Jun 10, 2024
f1f2568
Implement remaining chat memory store defined methods
jeffyanta Jun 11, 2024
f6edb85
Add missing result codes and update/comment on flush
jeffyanta Jun 11, 2024
ac1fe57
Flush pointers on chat event stream open
jeffyanta Jun 11, 2024
35597d3
Address todos relating to copying pointer values in chat store
jeffyanta Jun 11, 2024
da25935
Fix result codes in GetMessages
jeffyanta Jun 11, 2024
24268d6
Setup a temporary mock chat for testing
jeffyanta Jun 11, 2024
f828411
Fix message ID sorting
jeffyanta Jun 12, 2024
e8e873f
flushMessages doesn't need a cursor value for the DB query
jeffyanta Jun 12, 2024
932a60e
Implement GetChats RPC limited to anonymous chat membership
jeffyanta Jun 13, 2024
712a1f2
Remove addressed todo
jeffyanta Jun 13, 2024
47df628
Have chat v2 store indicate if pointer was advanced
jeffyanta Jun 13, 2024
3e22628
Fix unread count to not count messages sent by the reader
jeffyanta Jun 13, 2024
8a4c36e
Fix build with refactor changes to chat protos
jeffyanta Jun 17, 2024
a3c5bdc
Initial implementation of StartChat that always starts a new chat
jeffyanta Jun 18, 2024
bd59f14
Initial implementation of the RevealIdentity RPC
jeffyanta Jun 18, 2024
bbe23e9
More refactors of chat stuff
jeffyanta Jun 19, 2024
3f35885
Incorporate small tweaks to chat APIs
jeffyanta Jun 20, 2024
cdef223
PoC in memory two way messaging
jeffyanta May 15, 2024
e0766f4
Add support for thank you messages
jeffyanta May 21, 2024
c2aff7b
Add missing result codes and update/comment on flush
jeffyanta Jun 11, 2024
202e51c
Implement GetChats RPC limited to anonymous chat membership
jeffyanta Jun 13, 2024
e49e233
Fix build with refactor changes to chat protos
jeffyanta Jun 17, 2024
9f25c48
Initial implementation of StartChat that always starts a new chat
jeffyanta Jun 18, 2024
55c9cf7
Initial implementation of the RevealIdentity RPC
jeffyanta Jun 18, 2024
516a502
More refactors of chat stuff
jeffyanta Jun 19, 2024
8b22872
Incorporate small tweaks to chat APIs
jeffyanta Jun 20, 2024
afb13a0
chats: add (temporary) plumbing for tip notifications.
mfycheng Jul 8, 2024
179e98f
chatv/2: expose server for use as a notifier
mfycheng Jul 8, 2024
386695c
chat/v2: fix Notify message signature
mfycheng Jul 8, 2024
47a49a6
chat: add debug logging
mfycheng Jul 10, 2024
da34815
chat: don't execute v2 member add in tx.
mfycheng Jul 15, 2024
ca8fcf4
chat/v2: add handling for notifiaction chats
mfycheng Jul 15, 2024
91956a6
chat/v2: send two way chat notifications.
mfycheng Jul 21, 2024
e78b028
chat/v2: don't send push to sender
mfycheng Jul 22, 2024
f751569
chat/v2: add chat_id to push header, debug logs
mfycheng Jul 24, 2024
0dd205a
chat/v2: remove tip hooks, sketch out latest rpcs
mfycheng Sep 4, 2024
e4c7860
chat,user: pipe back FriendChatId in user, debug checks on StartChat
mfycheng Sep 17, 2024
21d8784
chat: fix build
mfycheng Sep 17, 2024
2aa7ad8
chat: don't overwrite initial ChatRecord on dupe check.
mfycheng Sep 18, 2024
0ef896a
chat: fix existing chat condition
mfycheng Sep 18, 2024
7267672
chat: hack to bypass member validation
mfycheng Sep 18, 2024
1398a23
chat: return profilepic urls
mfycheng Sep 18, 2024
cf233cb
chat overhaul, needs a new branch
mfycheng Sep 30, 2024
0bd5d15
chat: add is_self back to chat metadata
mfycheng Oct 3, 2024
1241ef9
chat/v2: add dual stream implementation (local server)
mfycheng Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ require (
firebase.google.com/go/v4 v4.8.0
github.com/aws/aws-sdk-go-v2 v0.17.0
github.com/bits-and-blooms/bloom/v3 v3.1.0
github.com/code-payments/code-protobuf-api v1.16.6
github.com/code-payments/code-protobuf-api v1.19.0
github.com/dghubble/oauth1 v0.7.3
github.com/emirpasic/gods v1.12.0
github.com/envoyproxy/protoc-gen-validate v1.0.4
github.com/golang-jwt/jwt/v5 v5.0.0
Expand Down Expand Up @@ -41,6 +42,7 @@ require (
golang.org/x/crypto v0.21.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/net v0.22.0
golang.org/x/sync v0.7.0
golang.org/x/text v0.14.0
golang.org/x/time v0.5.0
google.golang.org/api v0.170.0
Expand Down Expand Up @@ -119,7 +121,6 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/appengine/v2 v2.0.1 // indirect
Expand All @@ -130,3 +131,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/code-payments/code-protobuf-api => github.com/mfycheng/code-protobuf-api v0.0.0-20241010162320-5dac31db232d
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/code-payments/code-protobuf-api v1.16.6 h1:QCot0U+4Ar5SdSX4v955FORMsd3Qcf0ZgkoqlGJZzu0=
github.com/code-payments/code-protobuf-api v1.16.6/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand All @@ -141,6 +139,8 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dghubble/oauth1 v0.7.3 h1:EkEM/zMDMp3zOsX2DC/ZQ2vnEX3ELK0/l9kb+vs4ptE=
github.com/dghubble/oauth1 v0.7.3/go.mod h1:oxTe+az9NSMIucDPDCCtzJGsPhciJV33xocHfcR2sVY=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/cli v20.10.7+incompatible h1:pv/3NqibQKphWZiAskMzdz8w0PRbtTaEB+f6NwdU7Is=
Expand Down Expand Up @@ -423,6 +423,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mfycheng/code-protobuf-api v0.0.0-20241010162320-5dac31db232d h1:pOwndvvkUvWXzoiJIIo5wiPT/IP67J5AJqF4sLPdKcY=
github.com/mfycheng/code-protobuf-api v0.0.0-20241010162320-5dac31db232d/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down
6 changes: 3 additions & 3 deletions pkg/code/async/geyser/external_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/account"
"github.com/code-payments/code-server/pkg/code/data/balance"
"github.com/code-payments/code-server/pkg/code/data/chat"
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
"github.com/code-payments/code-server/pkg/code/data/deposit"
"github.com/code-payments/code-server/pkg/code/data/fulfillment"
"github.com/code-payments/code-server/pkg/code/data/intent"
Expand Down Expand Up @@ -299,7 +299,7 @@ func processPotentialExternalDeposit(ctx context.Context, conf *conf, data code_
chatMessage,
)
}
case chat.ErrMessageAlreadyExists:
case chat_v1.ErrMessageAlreadyExists:
default:
return errors.Wrap(err, "error sending chat message")
}
Expand Down Expand Up @@ -772,7 +772,7 @@ func delayedUsdcDepositProcessing(
chatMessage,
)
}
case chat.ErrMessageAlreadyExists:
case chat_v1.ErrMessageAlreadyExists:
default:
return
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/code/async/geyser/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/code-payments/code-server/pkg/code/common"
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/account"
"github.com/code-payments/code-server/pkg/code/data/chat"
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
"github.com/code-payments/code-server/pkg/code/push"
"github.com/code-payments/code-server/pkg/code/thirdparty"
"github.com/code-payments/code-server/pkg/database/query"
Expand Down Expand Up @@ -165,17 +165,17 @@ func processPotentialBlockchainMessage(ctx context.Context, data code_data.Provi
return errors.Wrap(err, "error creating proto message")
}

canPush, err := chat_util.SendChatMessage(
canPush, err := chat_util.SendNotificationChatMessageV1(
ctx,
data,
asciiBaseDomain,
chat.ChatTypeExternalApp,
chat_v1.ChatTypeExternalApp,
true,
recipientOwner,
chatMessage,
false,
)
if err != nil && err != chat.ErrMessageAlreadyExists {
if err != nil && err != chat_v1.ErrMessageAlreadyExists {
return errors.Wrap(err, "error persisting chat message")
}

Expand Down
63 changes: 62 additions & 1 deletion pkg/code/async/user/twitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"context"
"crypto/ed25519"
"database/sql"
"fmt"
"strings"
"time"

"github.com/google/uuid"
"github.com/mr-tron/base58"
"github.com/newrelic/go-agent/v3/newrelic"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

commonpb "github.com/code-payments/code-protobuf-api/generated/go/common/v1"
userpb "github.com/code-payments/code-protobuf-api/generated/go/user/v1"
Expand Down Expand Up @@ -103,6 +105,8 @@ func (p *service) twitterUserInfoUpdateWorker(serviceCtx context.Context, interv
}

func (p *service) processNewTwitterRegistrations(ctx context.Context) error {
log := p.log.WithField("method", "processNewTwitterRegistrations")

tweets, err := p.findNewRegistrationTweets(ctx)
if err != nil {
return errors.Wrap(err, "error finding new registration tweets")
Expand All @@ -113,6 +117,11 @@ func (p *service) processNewTwitterRegistrations(ctx context.Context) error {
return errors.Errorf("author missing in tweet %s", tweet.ID)
}

log := log.WithFields(logrus.Fields{
"tweet": tweet.ID,
"username": tweet.AdditionalMetadata.Author,
})

// Attempt to find a verified tip account from the registration tweet
tipAccount, registrationNonce, err := p.findVerifiedTipAccountRegisteredInTweet(ctx, tweet)
switch err {
Expand Down Expand Up @@ -140,7 +149,21 @@ func (p *service) processNewTwitterRegistrations(ctx context.Context) error {

switch err {
case nil:
go push_util.SendTwitterAccountConnectedPushNotification(ctx, p.data, p.pusher, tipAccount)
// todo: all of these success handlers are fire and forget best-effort delivery

go func() {
err := push_util.SendTwitterAccountConnectedPushNotification(ctx, p.data, p.pusher, tipAccount)
if err != nil {
log.WithError(err).Warn("failure sending success push")
}
}()

go func() {
err := p.sendRegistrationSuccessReply(ctx, tweet.ID, tweet.AdditionalMetadata.Author.Username)
if err != nil {
log.WithError(err).Warn("failure sending success reply")
}
}()
case twitter.ErrDuplicateTipAddress:
err = p.data.ExecuteInTx(ctx, sql.LevelDefault, func(ctx context.Context) error {
err = p.data.MarkTwitterNonceAsUsed(ctx, tweet.ID, *registrationNonce)
Expand Down Expand Up @@ -171,6 +194,14 @@ func (p *service) processNewTwitterRegistrations(ctx context.Context) error {
func (p *service) refreshTwitterUserInfo(ctx context.Context, username string) error {
user, err := p.twitterClient.GetUserByUsername(ctx, username)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "could not find user with username") || strings.Contains(strings.ToLower(err.Error()), "user has been suspended") {
err = p.onTwitterUsernameNotFound(ctx, username)
if err != nil {
return errors.Wrap(err, "error updating cached user state")
}
return nil
}

return errors.Wrap(err, "error getting user info from twitter")
}

Expand Down Expand Up @@ -334,6 +365,36 @@ func (p *service) findVerifiedTipAccountRegisteredInTweet(ctx context.Context, t
return nil, nil, errTwitterRegistrationNotFound
}

func (p *service) sendRegistrationSuccessReply(ctx context.Context, regristrationTweetId, username string) error {
// todo: localize this
message := fmt.Sprintf(
"@%s your X account is now connected. Share this link to receive tips: https://tipcard.getcode.com/x/%s",
username,
username,
)
_, err := p.twitterClient.SendReply(ctx, regristrationTweetId, message)
return err
}

func (p *service) onTwitterUsernameNotFound(ctx context.Context, username string) error {
record, err := p.data.GetTwitterUserByUsername(ctx, username)
switch err {
case nil:
case twitter.ErrUserNotFound:
return nil
default:
return errors.Wrap(err, "error getting cached twitter user")
}

record.LastUpdatedAt = time.Now()

err = p.data.SaveTwitterUser(ctx, record)
if err != nil {
return errors.Wrap(err, "error updating cached twitter user")
}
return nil
}

func toProtoVerifiedType(value string) userpb.TwitterUser_VerifiedType {
switch value {
case "blue":
Expand Down
6 changes: 6 additions & 0 deletions pkg/code/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
KinPurchasesName = "Kin Purchases"
PaymentsName = "Payments" // Renamed to Web Payments on client
TipsName = "Tips"
TwoWayChatName = "Two Way Chat"

// Test chats used for unit/integration testing only
TestCantMuteName = "TestCantMute"
Expand Down Expand Up @@ -45,6 +46,11 @@ var (
CanMute: true,
CanUnsubscribe: false,
},
TwoWayChatName: {
TitleLocalizationKey: localization.ChatTitleTwoWay,
CanMute: true,
CanUnsubscribe: false,
},

TestCantMuteName: {
TitleLocalizationKey: "n/a",
Expand Down
12 changes: 6 additions & 6 deletions pkg/code/chat/message_cash_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/code-payments/code-server/pkg/code/common"
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/chat"
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
"github.com/code-payments/code-server/pkg/code/data/intent"
)

Expand Down Expand Up @@ -93,9 +93,9 @@ func SendCashTransactionsExchangeMessage(ctx context.Context, data code_data.Pro
return errors.Wrap(err, "error getting original gift card issued intent")
}

chatId := chat.GetChatId(CashTransactionsName, giftCardIssuedIntentRecord.InitiatorOwnerAccount, true)
chatId := chat_v1.GetChatId(CashTransactionsName, giftCardIssuedIntentRecord.InitiatorOwnerAccount, true)

err = data.DeleteChatMessage(ctx, chatId, giftCardIssuedIntentRecord.IntentId)
err = data.DeleteChatMessageV1(ctx, chatId, giftCardIssuedIntentRecord.IntentId)
if err != nil {
return errors.Wrap(err, "error deleting chat message")
}
Expand Down Expand Up @@ -148,17 +148,17 @@ func SendCashTransactionsExchangeMessage(ctx context.Context, data code_data.Pro
return errors.Wrap(err, "error creating proto chat message")
}

_, err = SendChatMessage(
_, err = SendNotificationChatMessageV1(
ctx,
data,
CashTransactionsName,
chat.ChatTypeInternal,
chat_v1.ChatTypeInternal,
true,
receiver,
protoMessage,
true,
)
if err != nil && err != chat.ErrMessageAlreadyExists {
if err != nil && err != chat_v1.ErrMessageAlreadyExists {
return errors.Wrap(err, "error persisting chat message")
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/code/chat/message_code_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import (

"github.com/code-payments/code-server/pkg/code/common"
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/chat"
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
"github.com/code-payments/code-server/pkg/code/data/intent"
"github.com/code-payments/code-server/pkg/code/localization"
)

// SendCodeTeamMessage sends a message to the Code Team chat.
func SendCodeTeamMessage(ctx context.Context, data code_data.Provider, receiver *common.Account, chatMessage *chatpb.ChatMessage) (bool, error) {
return SendChatMessage(
return SendNotificationChatMessageV1(
ctx,
data,
CodeTeamName,
chat.ChatTypeInternal,
chat_v1.ChatTypeInternal,
true,
receiver,
chatMessage,
Expand Down Expand Up @@ -48,8 +48,8 @@ func newIncentiveMessage(localizedTextKey string, intentRecord *intent.Record) (

content := []*chatpb.Content{
{
Type: &chatpb.Content_Localized{
Localized: &chatpb.LocalizedContent{
Type: &chatpb.Content_ServerLocalized{
ServerLocalized: &chatpb.ServerLocalizedContent{
KeyOrText: localizedTextKey,
},
},
Expand Down
22 changes: 11 additions & 11 deletions pkg/code/chat/message_kin_purchases.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import (

"github.com/code-payments/code-server/pkg/code/common"
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/chat"
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
"github.com/code-payments/code-server/pkg/code/localization"
)

// GetKinPurchasesChatId returns the chat ID for the Kin Purchases chat for a
// given owner account
func GetKinPurchasesChatId(owner *common.Account) chat.ChatId {
return chat.GetChatId(KinPurchasesName, owner.PublicKey().ToBase58(), true)
func GetKinPurchasesChatId(owner *common.Account) chat_v1.ChatId {
return chat_v1.GetChatId(KinPurchasesName, owner.PublicKey().ToBase58(), true)
}

// SendKinPurchasesMessage sends a message to the Kin Purchases chat.
func SendKinPurchasesMessage(ctx context.Context, data code_data.Provider, receiver *common.Account, chatMessage *chatpb.ChatMessage) (bool, error) {
return SendChatMessage(
return SendNotificationChatMessageV1(
ctx,
data,
KinPurchasesName,
chat.ChatTypeInternal,
chat_v1.ChatTypeInternal,
true,
receiver,
chatMessage,
Expand All @@ -40,8 +40,8 @@ func SendKinPurchasesMessage(ctx context.Context, data code_data.Provider, recei
func ToUsdcDepositedMessage(signature string, ts time.Time) (*chatpb.ChatMessage, error) {
content := []*chatpb.Content{
{
Type: &chatpb.Content_Localized{
Localized: &chatpb.LocalizedContent{
Type: &chatpb.Content_ServerLocalized{
ServerLocalized: &chatpb.ServerLocalizedContent{
KeyOrText: localization.ChatMessageUsdcDeposited,
},
},
Expand All @@ -60,8 +60,8 @@ func NewUsdcBeingConvertedMessage(ts time.Time) (*chatpb.ChatMessage, error) {

content := []*chatpb.Content{
{
Type: &chatpb.Content_Localized{
Localized: &chatpb.LocalizedContent{
Type: &chatpb.Content_ServerLocalized{
ServerLocalized: &chatpb.ServerLocalizedContent{
KeyOrText: localization.ChatMessageUsdcBeingConverted,
},
},
Expand All @@ -79,8 +79,8 @@ func ToKinAvailableForUseMessage(signature string, ts time.Time, purchases ...*t

content := []*chatpb.Content{
{
Type: &chatpb.Content_Localized{
Localized: &chatpb.LocalizedContent{
Type: &chatpb.Content_ServerLocalized{
ServerLocalized: &chatpb.ServerLocalizedContent{
KeyOrText: localization.ChatMessageKinAvailableForUse,
},
},
Expand Down
Loading