-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
message-type: Add support for "direct" as value for type
parameter.
#25154
message-type: Add support for "direct" as value for type
parameter.
#25154
Conversation
Hello @zulip/server-api members, this pull request was labeled with the "area: api" label, so you may want to check it out! |
zerver/lib/message.py
Outdated
@@ -173,6 +173,9 @@ class SendMessageRequest: | |||
disable_external_notifications: bool = False | |||
|
|||
|
|||
# Used to check for valid string values for message `type` parameters. | |||
VALID_MESSAGE_TYPES = ["direct", "private", "stream"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if there was another place in the backend code where it would be better to define this constant so that it can be shared by both zerver/views/message-send.py
and zerver/views/typing.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose Message.API_RECIPIENT_TYPES
is the other place I'd consider, but that might be confusing. I think we should call these "recipient types", not "message types", because we have considered making "message type" be a phase reserved for special types of messages, like polls and certain types of special Notification Bot messages.
(And the API_
is designed to hint the fact that huddle
exists as a concept only in the internal data model, not in the API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I moved this to Message.API_RECIPIENT_TYPES
and added a comment. I used the comments for other API_
constants in models.py
as a jumping off point for that comment, but it may need some revision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! One drive-by nit.
zerver/openapi/zulip.yaml
Outdated
Send a stream or a private message. | ||
Send a [stream](/help/streams-and-topics) or | ||
a [direct](/help/direct-messages) message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, and I see this is a pre-existing issue, but since we're looking at this sentence: this wording parses much more strongly for me as "send a stream, or send a direct message" than as "send a stream message, or send a direct message".
Probably better to just say "Send a stream message or a direct message".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Updated in current version.
Yeah, we should do that after doing a |
Refactors instances of `message_type_name` and `message_type` that are referring to API message type value ("stream" or "private") to use `recipient_type_name` instead. Prep commit for adding "direct" as a value for endpoints with a `type` parameter to indicate whether the message is a stream or direct message.
For endpoints with a `type` parameter to indicate whether the message is a stream or direct message, `POST /typing` and `POST /messages`, adds support for passing "direct" as the preferred value for direct messages, group and 1-on-1. Maintains support for "private" as a deprecated value to indicate direct messages. Fixes zulip#24960.
577aa1f
to
2f3532b
Compare
Updates:
Notes:
Screenshots: |
Sounds good -- we actually haven't finished implementing typing notifications for stream messages in the web frontend yet. |
zerver/views/message_send.py
Outdated
@@ -210,12 +210,14 @@ def send_message_backend( | |||
tz_guess: Optional[str] = REQ("tz_guess", default=None, documentation_pending=True), | |||
time: Optional[float] = REQ(default=None, converter=to_float, documentation_pending=True), | |||
) -> HttpResponse: | |||
recipient_type_name = message_type_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done a bit more cleanly be using the first positional argument to REQ
, to not have set message_type_name
at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, but it gets replaced in the next commit anyway, yeah this is pretty reasonable as an intermediate state before we redo the internals plumbing to support "direct"
rather than "private"
.
Merged, huge thanks for doing this migration @laurynmm! |
For endpoints with a
type
parameter to indicate whether the message is a stream or direct message,POST /typing
andPOST /messages
, adds support for passing"direct"
as a value for direct messages.Maintains support for
"private"
as a deprecated alias for direct messages.Fixes #24960.
Notes:
POST /messages
documentation:type
parameter that was inPOST /typing
to also be inPOST /messages
.message_type_name
now refer to these parameters passed to the view functions from clients. Seegit-grep
below.POST /messages
, we use "private" for themessage_type
string that's then used for the various function calls.POST /typing
, we use "direct" for the default and updatedmessage_type
string.git-grep of `message_type_name` after changes
Questions:
message_type
is set in both view functions, but these might not be something we plan on doing?Screenshots and screen captures:
API changelog update
Send a message
Current documentation
Main endpoint description and usage examples
Parameters and response
Set typing status
Current documentation
Main endpoint description
Usage examples
Parameters and response
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: