Commit graph

2416 commits

Author SHA1 Message Date
Anders Kaseorg
25c8123a80 mypy: Move configuration to pyproject.toml, with some modernization.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:25:14 -07:00
Anders Kaseorg
3b4867ad46 simple_lib: Add type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:59:41 -07:00
Anders Kaseorg
01d5106e9a tools: Add type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:59:41 -07:00
Anders Kaseorg
a9e3fe9d0c zulip_trello: Add type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:21:34 -07:00
Anders Kaseorg
40fba154c2 get-google-credentials: Remove Python 2 compatibility.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:19:32 -07:00
Anders Kaseorg
f55d5ea555 Mark Python 3.11 supported.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:00:47 -07:00
Anders Kaseorg
4e360828ba mypy: Enable explicit_package_bases.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 15:58:50 -07:00
Anders Kaseorg
8045cf4e65 pytest: Configure pythonpath.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 15:58:50 -07:00
Anders Kaseorg
183bb933b4 test_run: Patch importlib.import_module last.
importlib.import_module is now used in the implementation of
unittest.mock.patch.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 15:58:50 -07:00
Anders Kaseorg
6b585f8b73 black: Bump target-version to py38.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 15:48:18 -07:00
Anders Kaseorg
8eb3d4e1e2 Upgrade requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:51 -07:00
Anders Kaseorg
2ecabb3260 Fix signal handler types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:51 -07:00
Anders Kaseorg
98e23bdfd4 Remove Python 3.7 support.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:37 -07:00
Anders Kaseorg
a9607dfdf9 Convert type comments to Python ≥ 3.6 variable annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-18 01:04:47 -07:00
Anders Kaseorg
8abca34a05 youtube: Fix for HTTPError stub change.
https://github.com/python/typeshed/pull/10875

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-17 19:03:47 -07:00
Prakhar Pratyush
ccda105d1d bot_server: Support trigger private_message renamed to direct_message.
The JSON payload that Zulip server POST for outgoing webhooks
has 'trigger' as one of the fields.

In https://github.com/zulip/zulip/commit/c4e4737, we renamed
the 'private_message' value to 'direct_message'.

This commit adds support to the botserver for handling
'direct_message' as a trigger value. It still supports
'private_message' for self-hosted server compatibility.
2023-09-21 09:13:40 -07:00
Daniel Teunis
35a8ff8839 zulip-integrations: Add missing dependencies to requirement files.
Adds missing items to the requirement files for the zulip integrations
in `zulip/integrations/*`.
2023-08-11 12:36:11 -07:00
Zixuan James Li
8016ed144c api: Update add_realm_filter to support url_template.
This adds support to adding linkifiers with the new URL template syntax.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-08-11 12:35:46 -07:00
Daniel Teunis
ae142a380d rss-bot: Allow overriding the topic default.
rss-bot selects the topic of its RSS notification messages based on the
topic of the RSS feed. Monitoring a large number of RSS feeds therefore
leads to a large number of topics in the stream. Also, the user has no
option to customize the topic names.

This patch adds a new `--topic` argument that replaces the topic for
all RSS feed notifications with the provided string. If no custom topic
is provided, the bot uses the default behaviour described above.
2023-06-12 12:24:29 -07:00
root
5b2b0617a6 call_on_each_event: Do not pass heartbeat events to clients.
Heartbeat events are intended to be an invisible part of the Zulip
longpolling protocol, not an event that an application should every
process, so it makes sense to exclude them from the events we pass to
this application.

Reproducer: https://github.com/showell/zulip-api-examples/blob/main/heartbeat_bug.py.

See https://chat.zulip.org/#narrow/stream/137-feedback/topic/api.20client.20silent.20failure
for more context.
2023-05-30 17:17:38 -07:00
i-ky
768959d633
rss-bot: Remove unnecessary "sender" in request data.
I've experienced that `rss-bot` works fine when using config file, but fails when `--site`, `--api-key`, and `--user` are provided via command line. The error is the following:
```
{'result': 'error', 'msg': 'Invalid mirrored message', 'code': 'BAD_REQUEST'}
```
Debugging shows that in the latter case `rss-bot` calls `zulip.Client.send_message()` with `"sender"` field in `message_data`. In the former case `"sender"` is `None`. Clearly, it is a bug that `rss-bot`'s behaviour depends on `--user` being provided on the command line.

`"sender"` field in request causes [this exception](e26f9180c1/zerver/views/message_send.py (L227)) on the server side.
Judging by surrounding code, `"sender"` is only expected together with a [specific set of clients](e26f9180c1/zerver/views/message_send.py (L186)). `rss-bot` uses a different one:
1b8f1d6e51/zulip/integrations/rss/rss-bot (L204)
Therefore I think, that providing `"sender"` is totally unnecessary.
2023-05-30 17:03:26 -07:00
Zixuan James Li
1b8f1d6e51 lint: Pin black to avoid inconsistent formatting.
This also runs black to reformat the affected files, which had been
causing failures because of upstream updates.

Ideally, we need a more sophisticated toolchain for managing the
versions of the dependencies instead of just requirements.txt. This
should be due in a possible future cleanup.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Zixuan James Li
63f46f4bbb zephyr: Add missing return type annotation.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Anders Kaseorg
02586f1d34 zephyr_mirror: Port sharding wrapper to asyncio.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-25 16:53:09 -08:00
Anders Kaseorg
7831d979c9 zephyr: Free received notices with ZFreeNotice.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:23:44 -08:00
Anders Kaseorg
c94da617ed Remove Python 3.6; add Python 3.10.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:04:59 -08:00
Tim Abbott
4a3d225a38 mailmap: Add a few entries. 2022-11-16 15:54:34 -08:00
rht
582e9733a9 Slack bridge: Inform user to subscribe their Slack bot. 2022-10-19 15:17:15 -07:00
rht
eef02fbb76 Slack bridge: Implement multiple channels bridges. 2022-10-19 15:17:15 -07:00
Robert Imschweiler
41ec1a9a29 matrix bridge: Improve mime-type detection. 2022-09-22 09:13:19 -07:00
Anders Kaseorg
92120914f8 process_ccache: Adjust supervisor_path to avoid Puppet purging.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
a534446315 zephyr: Remove python-zephyr in favor of ctypes.
Our custom patched version of python-zephyr only worked on Python 2.
Now we don’t need python-zephyr at all.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
56f805a5d7 zephyr_mirror_backend: Fix thread safety problems.
As of commit 5eaac7bfba (#18),
zulip.Client is not thread-safe and especially not fork-safe due to
connections held open by requests.Session.

Delay construction of the Client until after forking off
zulip_to_zephyr.  Replace the fork for each message sent by
zephyr_to_zulip with a threaded queue worker.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Robert Imschweiler
63c259b2bc integrations: Enhanced matrix bridge. 2022-09-08 16:14:23 -07:00
Anders Kaseorg
091511b164 Revert "integrations: Enhanced matrix bridge."
This reverts commit 72ef52d12e (#723).

The test failure on Windows will need to be debugged before this can
be re-merged.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-08-22 21:13:10 -07:00
Robert Imschweiler
72ef52d12e integrations: Enhanced matrix bridge. 2022-08-18 14:21:17 -07:00
rht
b290717bb2 Matrix bridge: Print reminder to subscribe the bots on startup. 2022-07-27 16:23:49 -07:00
rht
31365a8aac bridge_with_matrix: Bump matrix-client 0.2.0 -> 0.4.0. 2022-05-24 14:49:04 -07:00
Anders Kaseorg
d26416a1e7 Release version 0.8.2.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-15 17:44:12 -07:00
Eeshan Garg
e6dff1b5b6 zulip: Fix deprecation warnings for SafeConfigParser and readfp.
SafeConfigParser has been renamed to ConfigParser and the method
SafeConfigParser.readfp() is now named ConfigParser.read_file().
2022-02-28 11:10:53 -08:00
Eeshan Garg
7c3967f777 zulip: Reraise exceptions in do_api_query.
There are cases where the call to an endpoint may result in an
exception the traceback for which is converted into JSON and
returned to the caller. In the case of such an unsuccessful
response, we should just reraise the exception instead of parsing
the response as though it was successful.
2022-02-28 11:10:53 -08:00
Anders Kaseorg
05d591a906 Remove legacy distutils support.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-28 10:35:58 -08:00
neiljp (Neil Pilgrim)
095d5d8f4e api: Fix missing parenthesis in comment for ModifiableMessageFlag. 2022-02-23 16:50:03 -08:00
neiljp (Neil Pilgrim)
ea89e95857 api: Add Literal types for various important message flags.
With some copy-editing by tabbott.
2022-02-23 10:34:12 -08:00
Anders Kaseorg
113f9cb885 converter: Reformat with Black 22.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-09 18:51:30 -08:00
Anders Kaseorg
68128640bf zulip: Fix principals default for remove_subscriptions.
The documented API for DELETE /api/v1/users/me/subscriptions is that
principals should be omitted to remove a subscription for the calling
user.  A call with principals=[] should have a different meaning, but
a server bug currently conflates this with a call omitting principals.
Avoid relying on this bug.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-18 17:01:18 -08:00
Eeshan Garg
70b86614bd tools/provision: Bump required pip version from >=9.0 to >=10.
pip 10 was the first release to support PEP 518. Using pip<10
can lead to errors when installing dependencies.

Thanks to @andersk for suggesting this fix!
2022-01-06 01:54:47 +05:30
Eeshan Garg
74d716289b tools: Delete the release-packages script.
This script has been outdated for a long time now and has been
obsoleted by some recent changes in how packages should be built
and distributed. In general, the release process is now too
complicated to automate, so we are better off just making the
release manually.
2022-01-05 08:11:58 +05:30
neiljp (Neil Pilgrim)
e0f3bd4143 bots: Migrate source file for zulip-bot-shell to similar name. 2021-11-21 21:06:40 -08:00
neiljp (Neil Pilgrim)
cca1b7d679 mypy: Add types to terminal.py. 2021-11-21 21:06:40 -08:00