Skip to content

Conversation

@stereosteve
Copy link
Contributor

@stereosteve stereosteve commented Aug 12, 2024

Description

Adds "chat blast" RPC. And some function around turning blasts into 1:1 messages when a dm thread exists between sender and recipient.

Also includes PAY-3202

@changeset-bot
Copy link

changeset-bot bot commented Aug 12, 2024

⚠️ No Changeset found

Latest commit: 839fba9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

values
($1, $2, $3, $4, $5)
on conflict do nothing
`, params.ChatID+blast.BlastID, params.ChatID, blast.FromUserID, ts, blast.BlastID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatID + BlastID seems ok but making a note as it's different from our existing message IDs which are just ULIDs.

update chat c
set
last_message_at = latest.created_at,
last_message = coalesce(latest.ciphertext, '~' || latest.plaintext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that we'll have to use the is_encrypted boolean here too.

create table if not exists chat_blast (
blast_id text primary key,
from_user_id int not null,
audience text not null, -- todo sql enum I guess?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think enum

Copy link
Contributor

@dharit-tan dharit-tan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! mind updating the PR desc to include the getNewBlasts endpoint too?

Copy link
Contributor

@rickyrombo rickyrombo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we'll want to do is make chat create's go through despite permissions if there's a chat blast from that user - something we don't have currently

chat_message.chat_id,
chat_message.user_id,
chat_message.created_at,
COALESCE(chat_message.ciphertext, '~' || chat_blast.plaintext) as ciphertext, -- todo: separate out ciphertext + plaintext... make ciphertext nullable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking the todo w/ a CR comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat_message.created_at,
COALESCE(chat_message.ciphertext, '~' || chat_blast.plaintext) as ciphertext, -- todo: separate out ciphertext + plaintext... make ciphertext nullable

to_json(array(select row_to_json(r) from chat_message_reactions r where chat_message.message_id = r.message_id)) AS reactions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting... why the switch?

also for consistency maybe capitalize the SQL keywords?


// first find any blasts that should seed this chat ...
// todo: do we have to do this in both directions?
// todo: do we have to do this for all audiences too?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

// todo: do we have to do this in both directions?
// todo: do we have to do this for all audiences too?
// if it is related to an `audience_track_id` we won't have that here...
// so maybe the client can pass a separate param like `seed_blast_ids` to seed the thread context.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this matters - the blast itself will have the context

// todo: do we have to do this for all audiences too?
// if it is related to an `audience_track_id` we won't have that here...
// so maybe the client can pass a separate param like `seed_blast_ids` to seed the thread context.
// todo: should mark hidden for blaster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking the todo with a PR comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// todo: should mark hidden for blaster
blasts, err := queries.GetNewBlasts(tx, context.Background(), queries.ChatMembershipParams{
UserID: userId,
ChatID: params.ChatID, // ideally we'd just filter by chat ID which would get "both sides"... but the user id is required for the sql query... so maybe we make it so you can query by two user IDs or something...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to the "both directions done blasted" thing

@dharit-tan dharit-tan changed the title Chat blast lazy [PAY-3300] Chat blast lazy Aug 13, 2024
@stereosteve stereosteve changed the title [PAY-3300] Chat blast lazy [PAY-3300] Chat blast: lazy create thread Aug 13, 2024
@stereosteve stereosteve enabled auto-merge (squash) August 13, 2024 17:01
@stereosteve stereosteve merged commit 54a5a78 into main Aug 13, 2024
@stereosteve stereosteve deleted the chat-blast-lazy branch August 13, 2024 17:30
audius-infra pushed a commit that referenced this pull request Aug 14, 2024
[1072f5a] [PAY-3106][PAY-2914] Use SDK to withdraw USDC (#9419) Marcus Pasell
[54a5a78] [PAY-3300] Chat blast: lazy create thread (#9424) Steve Perkins
[ca71d76] [C-4910] Audius-query-ify comments state management (#9423) JD Francis
[3026411] Fix comment reactions pkey (#9433) Isaac Solo
[13276d2] Format Solana Relay listens endpoint (#9429) Marcus Pasell
audius-infra pushed a commit that referenced this pull request Aug 17, 2024
[d712b07] [C-4939] Add comment action menu popup (#9472) JD Francis
[641c9c1] [C-4940] Add comment badges (desktop web) (#9475) JD Francis
[aca7b5c] [PAY-3315][PAY-3316][PAY-3323] Staking bridge (#9408) Saliou Diallo
[bdc139a] [C-4828] Add timestamp features to comments (#9455) JD Francis
[3457aeb] [QA-1504] Fix payout wallet set default (#9467) Raymond Jacobson
[8c127d0] Add comment replies pagination (#9435) Isaac Solo
[c5e250e] [C-4929] Add SendIcon component to harmony and harmony native (#9422) Kyle Shanks
[a17b30e] Hook up client blast params to sdk (#9466) Reed
[11bf6e3] Don't decrypt plaintext chat.last_message (#9470) Reed
[bcaebb0] fix TS error (#9468) JD Francis
[bb802b7] Optimistic add chat blasts (#9463) Reed
[b5de040] Fix bad claimable challenge state due to nullable max_steps (#9461) Randy Schott
[d4c34c3] Fix comment delete in audius-query (#9462) JD Francis
[95380d8] [C-4800] Scaffolding for mobile comments (#9449) Sebastian Klingler
[fbb4256] [PAY-2917] Migrate user endpoints to SDK, round 3 (#9432) Randy Schott
[2c1679a] [PAY-3307] Upgrade chat blasts to chats in sdk (V2) (#9453) Reed
[279a9b2] More explicit audience columns for chat blast. (#9454) Steve Perkins
[acb857e] Fix bug in profile page 404 (#9456) Raymond Jacobson
[c382e82] Don't decrypt plaintext messages (#9448) Reed
[172f172] [QA-1495] Fix 404 for users (#9451) Raymond Jacobson
[82ab743] [PAY-3227] Unfurl tracks in composer (#9434) Raymond Jacobson
[363af71] Compose Solana Client in SDK (#9441) Marcus Pasell
[83260f6] Create ChatBlast from web (#9447) Andrew Mendelsohn
[19e3bdf] [PAY-3341] Add is_plaintext field for chat message (#9442) Steve Perkins
[e25c679] Rename Targeted Message to Chat Blast (#9443) Reed
[fc0604c] [C-4964] Comment header changes (#9444) JD Francis
[f9e4525] [PAY-3310] Chat blast function in sdk (#9436) Reed
[910b655] Move comments context to common (#9440) JD Francis
[bb5eaa1] [C-4910] Comments replys & deletes fixes (#9437) JD Francis
[1072f5a] [PAY-3106][PAY-2914] Use SDK to withdraw USDC (#9419) Marcus Pasell
[1b7bd47] Add social signup feature flag (#9439) Sebastian Klingler
[4130f42] Fix duplicate error name in sentry (#9430) Marcus Pasell
[54a5a78] [PAY-3300] Chat blast: lazy create thread (#9424) Steve Perkins
[ca71d76] [C-4910] Audius-query-ify comments state management (#9423) JD Francis
[20a55e9] [PAY-2917][QA-1466] Migrate more users endpoints (#9308) Randy Schott
[ab38869] [QA-1434] Fix hanging uploads due to errors on mobile (#9420) Randy Schott
[f6ab71c] Add buy button metrics (#9428) Isaac Solo
[06ee8a1] Fix pagination args (#9425) Isaac Solo
[b91437a] [QA-1501] Fix mobile search input (#9426) Sebastian Klingler
[a3c15fd] [C-4932] Add CommentBody component to harmony and harmony-native (#9415) Kyle Shanks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants