Skip to content

Feat/390 activity feed#548

Open
Sage-senpai wants to merge 118 commits into
StreamFi-x:devfrom
Sage-senpai:feat/390-activity-feed
Open

Feat/390 activity feed#548
Sage-senpai wants to merge 118 commits into
StreamFi-x:devfrom
Sage-senpai:feat/390-activity-feed

Conversation

@Sage-senpai
Copy link
Copy Markdown

Description

Closes #390

Changes proposed

What were you told to do?

Implement a cursor-paginated user activity feed API with two endpoints:

  • GET /api/routes-f/activity — paginated feed of user activity events
  • GET /api/routes-f/activity/daily — aggregated daily summary

What did you do?

Schema & migration

  • Created route_f_activity_events table with columns: id, user_id, type, actor_id, metadata (JSONB), created_at
  • Added composite index on (user_id, created_at DESC) for efficient feed queries
  • Added both app/api/routes-f/activity/_lib/db.ts (lazy DDL) and db/migrations/20260330_add_activity_events.sql

Types (types/activity.ts)

  • ActivityEventType — union of 8 event types (tip_received, tip_sent, new_follower, stream_started, stream_ended, gift_received, gift_sent, recording_ready)
  • ActivityTypeFilter — query param filter values (all, tips, follows, streams, gifts)
  • FILTER_TO_TYPES — maps filter values to DB event types
  • Response interfaces: ActivityFeedResponse, DailySummaryResponse

GET /api/routes-f/activity

  • Requires authenticated session (401 if missing)
  • Query params: limit (1-100, default 20), cursor (ISO timestamp), type (all|tips|follows|streams|gifts)
  • Cursor pagination using created_at < $cursor with fetch limit + 1 trick to detect next page
  • JOINs users table to include actor username/avatar
  • Empty state returns { events: [], next_cursor: null } (not 404)

GET /api/routes-f/activity/daily?date=YYYY-MM-DD

  • Requires authenticated session and valid date param (400 if missing/invalid)
  • Single aggregation query using PostgreSQL FILTER (WHERE ...) clauses
  • Returns: tips_received, tips_received_xlm, followers_gained, stream_duration_s, peak_viewers
  • All fields default to 0/"0" — never null

Upstream side-effect inserts

  • app/api/users/follow/route.ts — inserts new_follower event after successful follow
  • app/api/streams/start/route.ts — inserts stream_started on POST, stream_ended on DELETE (with duration/peak_viewers from session)
  • app/api/routes-f/gifts/route.ts — inserts both gift_received and gift_sent events
  • All inserts wrapped in try/catch to never break the primary operation

Note: Tip events (tip_received/tip_sent) are not yet instrumented — there is no dedicated tip transaction route to hook into (only tips/refresh-total which is a read-only endpoint).

Check List

  • My code follows the code style of this project.
  • This PR does not contain plagiarized content.
  • The title and description of the PR is clear and explains the approach.
  • I am making a pull request against the main branch (left side).
  • My commit messages styles matches our requested structure.
  • My code additions will fail neither code linting checks nor unit test.
  • I am only making changes to files I was requested to.

Screenshots/Videos

N/A — API-only changes. Example responses:

GET /api/routes-f/activity?type=tips&limit=2

{
  "events": [
    {
      "id": "uuid",
      "type": "tip_received",
      "actor": { "username": "alice", "avatar": "/img/alice.png" },
      "metadata": { "amount": "50", "currency": "XLM" },
      "created_at": "2026-03-30T12:00:00.000Z"
    }
  ],
  "next_cursor": null
}

Josue19-08 and others added 30 commits March 24, 2026 23:58
Implement full moderation system including:
- Ban/timeout users with duration options (1m, 5m, 10m, 1h, permanent)
- Delete messages with context menu
- Slow mode (3s, 5s, 10s, 30s intervals)
- Follower-only chat mode
- Link blocking with URL regex detection
- Active bans management panel

Database changes:
- Add chat_bans table with expires_at for timeouts
- Add slow_mode_seconds, follower_only_chat, link_blocking to users table

API endpoints:
- POST /api/streams/chat/ban - ban/timeout users
- DELETE /api/streams/chat/ban/[username] - unban users
- GET /api/streams/chat/ban - list active bans
- PATCH /api/streams/settings - update chat settings
- Updated POST /api/streams/chat with enforcement logic

UI components:
- Right-click context menu on chat messages (stream owner only)
- ChatModerationSettings panel in stream manager
- Ban list with unban functionality
- Settings toggles for follower-only and link blocking

Enforcement:
- Server-side validation for all moderation rules
- 429 responses with Retry-After headers for timeouts
- Clear error messages for banned/timed-out users
- Add mocks for permanent ban check
- Add mocks for timeout check
- Add mocks for slow mode validation
- Update combined lookup to include moderation settings
- Remove slow mode mock when slow_mode_seconds is 0
- Add streamer_id to combined lookup mock
Adds preset tip buttons above chat input to send XLM tips quickly.
Posts a system tip message to chat and shows a stacked tip alert overlay
on the player.

Closes StreamFi-x#368

Made-with: Cursor
Adds paid stream access configuration and a viewer payment gate.
The server verifies USDC payments on Stellar Horizon and stores grants
with tx hash replay protection.

Closes StreamFi-x#375

Made-with: Cursor
Implements the full Transak fiat → crypto on-ramp flow including widget
lifecycle, order persistence, webhook verification, balance auto-refresh,
USDC trustline guidance, Privy custodial wallet UX, and error fallbacks.
)

Streamers can restrict their stream to viewers who hold a specific
Stellar asset. Balance checks run server-side against Horizon with
60-second Redis cache. Dashboard UI lets streamers configure and
verify their asset; AccessGate component blocks non-holders with a
connect-wallet prompt.
…ration

feat: Chat Moderation Tools for Streamers
Keep both StreamAccessSettings (access-control) and ChatModerationSettings
(dev) in stream manager page, and combine index definitions in schema.sql.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l-foundation

Feat/access control foundation
setStreamData was called without accessType and accessConfig, causing
a TS error and silently dropping access-control settings on save.
Use a functional state update to spread existing state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers POST and GET handlers across all three import sources
(twitch, youtube, json). Includes edge cases for:
- invalid source / missing data fields
- user rate limit (24h) and DB errors
- overwrite_existing flag behaviour
- social_links and categories field mapping
- twitch token never persisted to DB
- youtube ssrf guard
- job status polling

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three pre-existing errors unrelated to the import api:
- app/api/users/[username]/route.ts: password_hash destructured
  intentionally to omit it — suppress no-unused-vars
- StreamAccessSettings.tsx: add curly braces to if statements
- view-stream.tsx: add curly brace to if statement; suppress
  no-unused-vars on isCheckingAccess (set but never read)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace chained .replace() calls in decodeHTMLEntities with a
  single-pass regex to prevent double-unescaping (CodeQL high alert)
- Add eslint-disable-next-line on stub functions in lib/stream/access.ts
  where _-prefixed params are intentionally unused pending future issues
- Run prettier on files that had format drift

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(routes-f): data import api for onboarding from other platforms
…ations-system

feat: add realtime notifications system
…on, and background jobs API

- Issue StreamFi-x#405: Shared Zod validation layer (_lib/validate.ts, _lib/schemas.ts) with validateBody/validateQuery helpers; dev-only /validate testing endpoint; import/route.ts refactored to use shared validators
- Issue StreamFi-x#399: Username conflict resolution API (check availability + suggestions, reserved/banned word list, admin dispute resolution with atomic DB transaction)
- Issue StreamFi-x#396: Background jobs API (enqueue, poll status, cancel) with cron processor, exponential backoff retry, 30-day auto-cleanup; DB migration for jobs table
davedumto and others added 27 commits March 29, 2026 07:25
feat(routes-f): add VOD chapter timestamps endpoints
Implements four new route handlers:
- POST/GET /api/routes-f/feedback + PATCH /api/routes-f/feedback/[id]
- GET/POST/DELETE /api/routes-f/maintenance
- POST/GET /api/routes-f/export (async job pattern)
- GET /api/routes-f/audit (admin only)
- lib/audit.ts: fire-and-forget insertAuditLog() helper

Closes StreamFi-x#400, StreamFi-x#398, StreamFi-x#395, StreamFi-x#393
… endpoints

- GET/PATCH /api/routes-f/monetization: per-creator tipping, subscription price, gift cooldown config
- GET/POST /api/routes-f/integrations: connect Discord, YouTube, Twitter/X integrations
- DELETE /api/routes-f/integrations/[platform]: disconnect a specific integration
- GET /api/routes-f/content/rules: public platform moderation rules with defaults
- PATCH /api/routes-f/content/rules: admin-only rules update (id, title, description, severity)
- GET /api/routes-f/credits: user credit balance and expiry
- POST /api/routes-f/credits/redeem: redeem voucher code with expiry and double-redemption guards
- GET/POST /api/routes-f/credits/admin: admin voucher issuance and redemption status listing

All routes follow existing patterns: verifySession, Zod validation, ensureXxxSchema
auto-provisioning, and admin gates via is_admin on users table.
…egrations-content-credits

feat(api): add monetization, integrations, content rules, and credits…
- GET /api/routes-f/creator/bio?username= - public endpoint for creator bio
- PATCH /api/routes-f/creator/bio - authenticated creator updates bio
- Supports bio_text (max 500 chars), social_links (max 5), schedule_text (max 200 chars), banner_url
- Database schema with route_f_creator_bios table
- GET /api/routes-f/stream/recording - list recordings for authenticated creator
- PATCH /api/routes-f/stream/recording/[id] - update recording metadata (title, visibility, thumbnail_url)
- DELETE /api/routes-f/stream/recording/[id] - permanently delete recording (requires confirm: true)
- Visibility options: public, unlisted, private
- Database schema with route_f_stream_recordings table
- Pagination support with cursor-based navigation
- GET /api/routes-f/stream/soundtrack?stream_id= - returns now playing track and playlist
- POST /api/routes-f/stream/soundtrack/play - start a track (track_id, stream_id)
- PUT /api/routes-f/stream/soundtrack/skip - skip to next track
- PUT /api/routes-f/stream/soundtrack/stop - stop playback
- Track catalog sourced from route_f_soundtrack_catalog table
- now_playing visible to viewers via public GET
- Only stream owner can control playback
- Database schema with soundtrack catalog, now_playing, and playlists tables
- GET /api/routes-f/clips/captions?clip_id= - list caption tracks for a clip
- POST /api/routes-f/clips/captions - upload a caption track (clip_id, language, label, vtt_content)
- DELETE /api/routes-f/clips/captions/[id] - remove a caption track
- Language validation: BCP-47 tags (e.g., en, es, fr, en-US)
- WebVTT content validation: must start with WEBVTT and contain at least one cue
- Max 5 caption tracks per clip
- Database schema with route_f_clip_captions table
…lti-endpoints

Feat/routes f multi endpoints
…-routes-f-dev

feat(routes-f): add engagement and recommendation apis
- merge access/check for paid grants, token_gated horizon check, and session wallet
- add quick tip bar, tip alerts, token gated gate, chat moderation hooks
- tipmodal defers confirmation to container; add funds nudge on low xlm

Made-with: Cursor
…m-tipping-chat

feat: live stream tipping via chat (quick-tip buttons)
…routes

implemented frontend and dispute resolution documentation
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

@Sage-senpai is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 30, 2026

@Sage-senpai Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

feat(routes-f): user activity feed api (tips, follows, streams)