The message ID necessarily has to be an integer, and if no casting is
made it was being considered a string, causing problems when running
the example.
There were some issues running bots due to SSL issues.
Adding the extra_require requests[security] adds 3
additional packages that deal with these issues.
The root issue here is that we had been using `None` as a way of
encoding `event_types` as being an argument to not pass to the server
in the API codebase, but the marshalling to send this over the wire
didn't handle that possibility correctly.
This was incorrectly "fixed" in
409bb587429ec4dcb1220a8ed85ec1618ffde0ed; the root cause of the issue
was the refactor to the new approach for registering API endpoints.
This commit makes a bunch of improvements:
1. Use format() for string formatting instead of the old style.
2. Stop returning stuff where we don't have to.
3. URL generation should not be done by the script, especially
since our eventual goal is for the Zulip server to automatically
generate a webhook URL. So the user should be able to supply
the URL in the config file. Plus, this makes it easier to test
the script with non-Zulip URLs (such as RequestBin).
4. Removed unnecessary arguments.
Having a default parameter as '[]' may not be an issue with the current
implementation, but general practice is to default to None and assign
a default list subsequently.
This removes the use of RuntimeError, and replaces it with a custom
error class called ZulipError. In a few places, we use a subclass to
make it easier for code to interact with the error type.
Previously, remove_subscriptions called the
PATCH /api/v1/users/me/subscriptions endpoint, which is more like
an ad-hoc endpoint for bulk adding/removing subscriptions for the
user that makes the request. However, making a DELETE request
allows an admin to pass in the `principals` argument to unsubscribe
other users from streams as well, which is more consistent with how
add_subscriptions works.
The zulip and zulip_botserver packages specify mock as a runtime
dependency, which is only needed for testing during development.
So, it made more sense to move it to requirements.txt so that
it can be installed by ./tools/provision during development.
mypy with strict-optional led to examination of res.get('result')
calls potentially raising TypeError ('error' in None).
Server code indicates this is safe, and other nearby code assumes
presence of fields in 'res' also.
Rename the function channelmessage2zerver_message to channelmessage2zerver_message_for_one_stream.
Compress the converted data with tar instead of zip.
Add changes in zerver_userprofile mapping and zerver_realm mappings.
Do the manage.py import from a directory instead.
The API has aggressive retry logic for connecting to a
server, which may make sense for situation where you have
connection blips or server restarts.
When you're first connecting to the API, however, connection
failures are almost certainly a sign of misconfiguration, so
now we fail fast.
The bot lib takes advantage of this API change by catching the
ZulipError exception and exiting gracefully.
When invoked with search terms, twitter bot looks for these terms
in the content of a message to find out if they match. However,
Twitter can return messages that don't directly contain a search term.
This commit adds the tweeter user handle and expanded urls to the
places to look for a search term.
This parameter was intended to control whether we give a long timeout
and related behavior, but it was accidentally not being passed into
the second layer of the library from the first.
While we're fixing it, make it actually limit the length of a timeout
to something reasonable.
The only problem with this resulting code is that setup_path_on_import
only works if the Python versions are the same, so you need to run
this with Python 3 in that case.
We try to resolve that for use on Zulip servers with
zulip/zulip:47c5aae5b242fb6d2f5e860602e0fc0af68419bb; since that's the
main case where the code path runs, that should be good enough.
These were quite messy code, and now that almost nobody is running
their own zephyr mirroring script (vs. using webathena), making the
zephyr mirroring script deployable outside the package isn't super
valuable.