Skip to content

feat: let streamers notify their followers when they go live - #687

Closed
ashkesarmaa wants to merge 2 commits into
dev-null-sh:productionfrom
ashkesarmaa:feat/notify-followers-on-live
Closed

ashkesarmaa wants to merge 2 commits into
dev-null-sh:productionfrom
ashkesarmaa:feat/notify-followers-on-live

Conversation

@ashkesarmaa

Copy link
Copy Markdown
Contributor

Problem

When someone goes live, their followers have no way to find out unless they happen to visit the profile or see the live marker on the avatar. The go-live modal also asks for the stream length with a plain 1–12 hours dropdown.

Change

  • The go-live modal has a Notify followers switch, on by default. With it on, every follower gets an "is live" notification that links to the streamer's profile, where the stream is shown.
  • Followers who muted the streamer don't get it. A block already ends any follow, so nobody across a block gets it either.
  • The notification only lives as long as the stream: ending the stream, or the stream running out, removes it. While the scheduler hasn't cleared an expired stream yet, NotificationBuilder::relevant() already hides it.
  • The hours dropdown is now a slider, with the chosen length shown next to the label in a fixed-width slot.
  • Going live and ending a stream share a new per-user live rate limit of 10 an hour, so going live over and over can't spam followers.

Implementation

  • New NotificationType::WentLive and a CreateLiveNotifications action, called from UpdateUserLive when notify is true. It reads follower ids straight from follows in chunks and inserts one notification per follower with the key went_live:{user}, so a repeated call never duplicates one.
  • DeleteUserLive (used by both the End stream action and EndLiveStreams) deletes the user's went-live notifications in the same transaction.
  • UpdateUserLiveRequest accepts an optional notify boolean. Leaving it out means no notifications.
  • The settings toggles in Remotes, Pastéis mode and Operations → Features were the same hand-copied switch markup. They now share components/ui/switch.tsx, which the go-live modal uses too.
  • In the inbox, notifications without a commit (follows and now live streams) link to the actor's profile and show no excerpt, based on commit === null instead of a list of types.

Data

  • Why it's stored: each follower needs their own unread state for the notification, so it has to be a row per follower, like every other notification.
  • Who can see it: only the follower who received it.
  • When it's deleted: when the stream ends or runs out, and with either account.

Tests

  • CreateLiveNotificationsTest: notifies every follower, is idempotent, skips followers who muted the streamer.
  • UserLiveControllerTest: notifies only when asked, rejects a non-boolean notify.
  • EndLiveStreamsTest: removes the notifications of streams that ran out and keeps those of running streams.
  • NotificationBuilderTest: keeps live notifications while the stream runs, hides them once it runs out, deletes them with the actor, hides them from muters.
  • NotificationInboxTest: the inbox shows a live notification.
  • RateLimitTest: the new live limit.

The go-live modal now has a "Notify followers" switch (on by default)
and a slider for the stream length instead of the hours dropdown.

With the switch on, every follower gets an "is live" notification that
links to the streamer's profile. Followers who muted the streamer are
skipped, and the notifications disappear when the stream ends.

The settings toggles now share one Switch component.
Going live can notify every follower, so going live and ending the
stream over and over could spam them. Each user can now go live or end
a stream 10 times an hour.
@nunomaduro

Copy link
Copy Markdown
Member

hey man, thank you so much for the effort on this one 🤌🏻

i don't want to do this for now.. maybe in the future

thank you though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants