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.
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.
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>
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>
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>
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>
The username doesn't include the Matrix homeserver domain name, while
the mxid does. Since we change the usage of the old "username" to
include the domain, it is incorrect to remain saying it as "username."
Without universal_newlines=True or text=True, subprocess.check_output
returns bytes, not str, so it makes no sense to compare its return to
"true". But upstream Git’s behavior only depends on the filename, not
whether the repository is bare; emulate this more closely.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
We uses `pyupgrade --py3-plus` to automatically replace all occurence
of `Text`. But manual fix is required to remove the unused imports. Note
that with this configuration pyupgrade also convert string literals to
.format(...) style, which is manually not included in the commit as well.