mirror of https://github.com/zulip/zulip.git
Remove legacy /api/v1/send_message endpoint.
This was the original way to send messages via the Zulip API in the very early days of Zulip, but was replaced by the REST API back in 2013. Fixes: #730.
This commit is contained in:
parent
edfa022bac
commit
03bf8893e2
|
@ -168,8 +168,7 @@ documentation for the third party software in order to learn how to
|
|||
write the integration. But we have a few notes on how to do these:
|
||||
|
||||
* You should always send messages by POSTing to URLs of the form
|
||||
`https://zulip.example.com/v1/messages/`, not the legacy
|
||||
`/api/v1/send_message` message sending API.
|
||||
`https://zulip.example.com/v1/messages/`.
|
||||
|
||||
* We usually build Python script integration with (at least) 2 files:
|
||||
`zulip_foo_config.py`` containing the configuration for the
|
||||
|
|
|
@ -68,13 +68,13 @@ class RateLimitTests(ZulipTestCase):
|
|||
|
||||
def send_api_message(self, email, api_key, content):
|
||||
# type: (text_type, text_type, text_type) -> HttpResponse
|
||||
return self.client_post("/api/v1/send_message", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"client": "test suite",
|
||||
"content": content,
|
||||
"subject": "Test subject",
|
||||
"email": email,
|
||||
"api-key": api_key})
|
||||
return self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"client": "test suite",
|
||||
"content": content,
|
||||
"subject": "Test subject"},
|
||||
**self.api_auth(email))
|
||||
|
||||
def test_headers(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
|
|
|
@ -371,29 +371,28 @@ class StreamMessagesTest(ZulipTestCase):
|
|||
def test_stream_message_mirroring(self):
|
||||
# type: () -> None
|
||||
from zerver.lib.actions import do_change_is_admin
|
||||
user_profile = get_user_profile_by_email("iago@zulip.com")
|
||||
email = "iago@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
|
||||
do_change_is_admin(user_profile, True, 'api_super_user')
|
||||
result = self.client_post("/api/v1/send_message", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"sender": "cordelia@zulip.com",
|
||||
"client": "test suite",
|
||||
"subject": "announcement",
|
||||
"content": "Everyone knows Iago rules",
|
||||
"forged": "true",
|
||||
"email": user_profile.email,
|
||||
"api-key": user_profile.api_key})
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"sender": "cordelia@zulip.com",
|
||||
"client": "test suite",
|
||||
"subject": "announcement",
|
||||
"content": "Everyone knows Iago rules",
|
||||
"forged": "true"},
|
||||
**self.api_auth(email))
|
||||
self.assert_json_success(result)
|
||||
do_change_is_admin(user_profile, False, 'api_super_user')
|
||||
result = self.client_post("/api/v1/send_message", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"sender": "cordelia@zulip.com",
|
||||
"client": "test suite",
|
||||
"subject": "announcement",
|
||||
"content": "Everyone knows Iago rules",
|
||||
"forged": "true",
|
||||
"email": user_profile.email,
|
||||
"api-key": user_profile.api_key})
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"sender": "cordelia@zulip.com",
|
||||
"client": "test suite",
|
||||
"subject": "announcement",
|
||||
"content": "Everyone knows Iago rules",
|
||||
"forged": "true",},
|
||||
**self.api_auth(email))
|
||||
self.assert_json_error(result, "User not authorized for this query")
|
||||
|
||||
@slow('checks all users')
|
||||
|
@ -517,14 +516,12 @@ class MessagePOSTTest(ZulipTestCase):
|
|||
Same as above, but for the API view
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
api_key = self.get_api_key(email)
|
||||
result = self.client_post("/api/v1/send_message", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"client": "test suite",
|
||||
"content": "Test message",
|
||||
"subject": "Test subject",
|
||||
"email": email,
|
||||
"api-key": api_key})
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"to": "Verona",
|
||||
"client": "test suite",
|
||||
"content": "Test message",
|
||||
"subject": "Test subject"},
|
||||
**self.api_auth(email))
|
||||
self.assert_json_success(result)
|
||||
|
||||
def test_api_message_with_default_to(self):
|
||||
|
@ -534,16 +531,14 @@ class MessagePOSTTest(ZulipTestCase):
|
|||
stream for the user_profile.
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
api_key = self.get_api_key(email)
|
||||
user_profile = get_user_profile_by_email("hamlet@zulip.com")
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile.default_sending_stream = get_stream('Verona', user_profile.realm)
|
||||
user_profile.save()
|
||||
result = self.client_post("/api/v1/send_message", {"type": "stream",
|
||||
"client": "test suite",
|
||||
"content": "Test message no to",
|
||||
"subject": "Test subject",
|
||||
"email": email,
|
||||
"api-key": api_key})
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"client": "test suite",
|
||||
"content": "Test message no to",
|
||||
"subject": "Test subject"},
|
||||
**self.api_auth(email))
|
||||
self.assert_json_success(result)
|
||||
|
||||
sent_message = self.get_last_message()
|
||||
|
|
|
@ -78,8 +78,7 @@ class PublicURLTest(ZulipTestCase):
|
|||
"/json/users/me/subscriptions",
|
||||
"/api/v1/users/me/subscriptions",
|
||||
],
|
||||
400: ["/api/v1/send_message",
|
||||
"/api/v1/external/github",
|
||||
400: ["/api/v1/external/github",
|
||||
"/api/v1/fetch_api_key",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -778,12 +778,6 @@ def same_realm_jabber_user(user_profile, email):
|
|||
|
||||
return user_profile.realm.domain == domain
|
||||
|
||||
|
||||
@authenticated_api_view(is_webhook=False)
|
||||
def api_send_message(request, user_profile):
|
||||
# type: (HttpRequest, UserProfile) -> HttpResponse
|
||||
return send_message_backend(request, user_profile)
|
||||
|
||||
# We do not @require_login for send_message_backend, since it is used
|
||||
# both from the API and the web service. Code calling
|
||||
# send_message_backend should either check the API key or check that
|
||||
|
|
|
@ -33,8 +33,4 @@ legacy_urls = [
|
|||
url(r'^json/time_setting$', 'zerver.views.user_settings.json_time_setting'),
|
||||
url(r'^json/left_side_userlist$', 'zerver.views.user_settings.json_left_side_userlist'),
|
||||
url(r'^json/language_setting$', 'zerver.views.user_settings.json_language_setting'),
|
||||
|
||||
# This json format view is used by the LEGACY pre-REST API. It
|
||||
# requires an API key.
|
||||
url(r'^api/v1/send_message$', 'zerver.views.messages.api_send_message'),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue