urls: Add new endpoint to create scheduled messages.

This will help us remove scheduled message and reminder logic
from `/messages` code path.

Removes `deliver_at`/`defer_until` and `tz_guess` parameters. And
adds the `scheduled_delivery_timestamp` instead. Also updates the
scheduled message dicts to return `scheduled_delivery_timestamp`.

Also, revises some text in `/delete-scheduled-message` endpoint
and in the `ScheduledMessage` schema in the API documentation.
This commit is contained in:
Aman Agrawal
2023-04-20 02:26:41 +00:00
committed by Tim Abbott
parent 7739703111
commit d60d6e9115
6 changed files with 315 additions and 254 deletions

View File

@@ -136,7 +136,11 @@ from zerver.views.report import (
report_send_times,
report_unnarrow_times,
)
from zerver.views.scheduled_messages import delete_scheduled_messages, fetch_scheduled_messages
from zerver.views.scheduled_messages import (
delete_scheduled_messages,
fetch_scheduled_messages,
scheduled_messages_backend,
)
from zerver.views.sentry import sentry_tunnel
from zerver.views.storage import get_storage, remove_storage, update_storage
from zerver.views.streams import (
@@ -323,7 +327,7 @@ v1_api_and_json_patterns = [
rest_path("drafts", GET=fetch_drafts, POST=create_drafts),
rest_path("drafts/<int:draft_id>", PATCH=edit_draft, DELETE=delete_draft),
# New scheduled messages are created via send_message_backend.
rest_path("scheduled_messages", GET=fetch_scheduled_messages),
rest_path("scheduled_messages", GET=fetch_scheduled_messages, POST=scheduled_messages_backend),
rest_path("scheduled_messages/<int:scheduled_message_id>", DELETE=delete_scheduled_messages),
# messages -> zerver.views.message*
# GET returns messages, possibly filtered, POST sends a message