Skip to content

[CHA-5933] feat: add scheduled messages support - #221

Open
nijeesh-stream wants to merge 2 commits into
masterfrom
feature/cha-5933-scheduled-messages
Open

nijeesh-stream wants to merge 2 commits into
masterfrom
feature/cha-5933-scheduled-messages

Conversation

@nijeesh-stream

Copy link
Copy Markdown
Contributor

TLDR

Adds server-side support for Chat scheduled messages: schedule a message for a user, then edit it, cancel it, send it right away, or list a user's scheduled messages. Backend endpoints are behind a per-app flag and not yet released; merge after backend CHA-5924 ships. Risk is low: the change only adds new methods, and existing calls are untouched.

Linear: https://linear.app/stream/issue/CHA-5933

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

New methods, mirroring the reminders / drafts layout:

Method API
Channel#schedule_message(message, user_id, scheduled_at, **options) POST /channels/{type}/{id}/message with scheduled_at; the response carries scheduled_message
Client#update_scheduled_message(id, message:, scheduled_at:) PATCH /scheduled_messages/{id}
Client#delete_scheduled_message(id) DELETE /scheduled_messages/{id}
Client#send_scheduled_message_now(id) POST /scheduled_messages/{id}/send_now
Client#query_scheduled_messages(user_id, filter:, sort:, **options) POST /scheduled_messages/query (filter.cid, filter.status, limit, next)

scheduled_at accepts DateTime, Time or an RFC 3339 string, normalized like remind_at. Docs: new docs/messages/scheduled_messages.md, plus the scheduled_message.sent / scheduled_message.failed webhook events in docs/webhooks/webhook_events.md. CHANGELOG is left to the release tooling.

Not added: include_scheduled_messages on GetOrCreateChannel (the backend ignores it for server-side calls), app settings (the chat_scheduled_messages_* flags aren't exposed through the app settings API), and a permission constant (the SDK has no list of v2 permission actions).

Tests

  • spec/scheduled_messages_spec.rb: checks the request shape against a stubbed Faraday adapter. It needs no credentials and always runs.
  • spec/client_spec.rb → scheduled messages: live round trip (schedule, query, update, send now, delete). It skips when the app has the feature off (scheduled messages are not enabled) or the backend ignores scheduled_at, so CI stays green until the flag is on for the CI app.
  • Local results: the live specs pass (5/5) against a local backend built from the backend branch feature/cha-5924-scheduled-messages-channel-state, using an app with the flag on. They skip as expected against an app with the flag off. Rubocop and srb tc are clean (no new Sorbet errors).

🤖 Generated with Claude Code

Add Channel#schedule_message (SendMessage with scheduled_at) and
Client#update_scheduled_message, #delete_scheduled_message,
#send_scheduled_message_now and #query_scheduled_messages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nijeesh-stream

Copy link
Copy Markdown
Contributor Author

CI note: the 💎 Ruby 3.4 failure is unrelated to this PR. Its lint step runs srb tc, which reports 2 errors from the vendored sorbet/rbi/hidden-definitions/hidden.rbi:9107 (extend ::URI::Escape, which no longer resolves). The docs-only PR #220 fails the same way, and srb tc on master shows the same 2 errors locally. Ruby 3.0 and 3.1 pass. The live scheduled-message specs are pending there because the CI app's backend doesn't return scheduled_message yet.

🤖 Generated with Claude Code

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.

1 participant