Commit Graph

38 Commits

Author SHA1 Message Date
abdullahm1 a0fb4feebf integrations: Replace use of 'subject' to 'topic'.
Fixes #25974
2023-07-17 10:35:51 -07:00
Anders Kaseorg 73c4da7974 ruff: Fix N818 exception name should be named with an Error suffix.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-17 16:52:00 -08:00
Anders Kaseorg dc33a0ae67 markdown: Rewrite include plugin without markdown-include.
markdown-include is GPL licensed.

Also, rewrite it as a block processor, so that it works correctly
inside indented blocks.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-06-26 17:36:31 -07:00
Anders Kaseorg f05fa9937b gci: Fix get_body_based_on_event type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-05-12 18:04:44 -07:00
Christopher Chong 83178a474f gci: Strengthen types using WildValue. 2022-05-10 13:50:20 -07:00
Lauryn Menard 3be622ffa7 backend: Add request as parameter to json_success.
Adds request as a parameter to json_success as a refactor towards
making `ignored_parameters_unsupported` functionality available
for all API endpoints.

Also, removes any data parameters that are an empty dict or
a dict with the generic success response values.
2022-02-04 15:16:56 -08:00
PIG208 5359d20a13 webhooks: Add support to event filtering system for webhooks.
This add support to event filtering system for most webhooks that
require trivial changes to adapt this feature.
2021-07-24 15:10:09 -07:00
PIG208 5ecbfecd77 webhook: Rename FIXTURE_DIR_NAME to WEBHOOK_DIR_NAME.
Since FIXTURE_DIR_NAME is the name of the folder that contains the view
and tests modules of the webhook and another folder called "fixtures" that
store the fixtures, it is more appropriate to call it WEBHOOK_DIR_NAME,
especially when we want to refer to the view module using this variable.
2021-06-29 17:01:54 -07:00
Anders Kaseorg 6e4c3e41dc python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Anders Kaseorg 11741543da python: Reformat with Black, except quotes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Anders Kaseorg 72d6ff3c3b docs: Fix more capitalization issues.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-23 11:46:55 -07:00
Alex Vandiver cf6ebb9c8d webhooks: Rename api_key_only_webhook_view to webhook_view.
There are no other types of webhook views; this is more concise.
2020-09-10 17:47:21 -07:00
Steve Howell 388053db6b webhook tests: Rename main helper to check_webhook.
Almost all webhook tests use this helper, except a few
webhooks that write to private streams.

Being concise is important here, and the name
`self.send_and_test_stream_message` always confused
me, since it sounds you're sending a stream message,
and it leaves out the webhook piece.

We should consider renaming `send_and_test_private_message`
to something like `check_webhook_private`, but I couldn't
decide on a great name, and it's very rarely used.  So
for now I just made sure the docstrings of the two
sibling functions reference each other.
2020-08-24 12:34:46 -07:00
Anders Kaseorg 69730a78cc python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:

import re
import sys

last_filename = None
last_row = None
lines = []

for msg in sys.stdin:
    m = re.match(
        r"\x1b\[35mflake8    \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
    )
    if m:
        filename, row_str, col_str, err = m.groups()
        row, col = int(row_str), int(col_str)

        if filename == last_filename:
            assert last_row != row
        else:
            if last_filename is not None:
                with open(last_filename, "w") as f:
                    f.writelines(lines)

            with open(filename) as f:
                lines = f.readlines()
            last_filename = filename
        last_row = row

        line = lines[row - 1]
        if err in ["C812", "C815"]:
            lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
        elif err in ["C819"]:
            assert line[col - 2] == ","
            lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")

if last_filename is not None:
    with open(last_filename, "w") as f:
        f.writelines(lines)

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-06-11 16:04:12 -07:00
Anders Kaseorg 8dd83228e7 python: Convert "".format to Python 3.6 f-strings.
Generated by pyupgrade --py36-plus --keep-percent-format, but with the
NamedTuple changes reverted (see commit
ba7906a3c6, #15132).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-08 15:31:20 -07:00
Anders Kaseorg c734bbd95d python: Modernize legacy Python 2 syntax with pyupgrade.
Generated by `pyupgrade --py3-plus --keep-percent-format` on all our
Python code except `zthumbor` and `zulip-ec2-configure-interfaces`,
followed by manual indentation fixes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-09 16:43:22 -07:00
Tim Abbott c10cc24ee8 python: Sort webhooks imports with isort. 2020-01-14 13:07:47 -08:00
Anders Kaseorg 39ac378220 webhooks: Remove unused imports.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:05:20 -08:00
Steve Howell 1fff890b71 webhooks: Change *_SUBJECT_TEMPLATE to *_TOPIC_TEMPLATE. 2018-11-12 15:47:11 -08:00
Steve Howell ced4d81856 Sweep tests for expected_subject -> expected_topic.
This is all in the webhooks tests, including some
docs for how to write those tests.
2018-11-12 15:47:11 -08:00
Aditya Bansal 64ddfc6ac0 zerver/webhooks: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
Eeshan Garg a4979410f9 webhooks: Migrate most integrations to use check_send_webhook_message.
This commit migrates all of our webhooks to use
check_send_webhook_message, except the following:

beeminder: Rishi wanted to wait on this one.
teamcity: This one is slightly more work.

yo: This one is PM-only. I am still trying to decide whether we
    should have a force_private argument or something in
    check_send_webhook_message.

facebook: No point in migrating this, will be removed as part of
          #8433.

slack: Slightly more work too with the `channel_to_topics` feature.
       Warrants a longer discussion.
2018-03-16 19:23:50 -02:30
Eeshan Garg b6fc33e1da webhooks/gci: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg 4d410a5eb7 webhooks/gci: Update text.
This commit modifies the text to:

* Use number 1 for all steps and let Markdown take care of the rest.
* Removes the line that says this webhook is "experimental". It isn't
  anymore.
2018-02-24 06:21:02 -05:00
Eeshan Garg 457c5a7735 webhooks/gci: Support 'outoftime' event.
This commit adds support for the 'outoftime' event. Such an event
is triggered when the task deadline for a particular task has
passed.
2018-01-16 15:57:35 -08:00
Eeshan Garg 18c3bec667 webhooks/gci: Support "unassign" event type.
This commit adds support for the "unassign" event type, the
payloads for which are generated when a mentor unassigns a student
from a task.
2018-01-02 16:42:00 -05:00
Eeshan Garg 2c7f4d2187 webhooks/gci: Support "extend" event type.
This commit adds support for events of type "extend", the payloads
for which are generated when a mentor extends the deadline for a
task.
2018-01-02 16:42:00 -05:00
Eeshan Garg 21008a49b9 webhooks/gci: Support approve-pending-pc event type.
This event is generated when a mentor approves a task but
GCI is still waiting on a student's parental consent.
2017-12-18 10:00:20 -08:00
Xavier Cooney 1262d14d39 mypy: Use Python 3 syntax in gci/view.py. 2017-12-08 18:34:26 -08:00
Tim Abbott d5bb45db60 webhooks/gci: Fix missing mypy annotation. 2017-11-28 14:08:44 -08:00
Sampriti Panda bea653fabc webhooks/gci: Improve message formatting.
* Use Student Name instead of Task Name in subject.
* Use Task Instance URL instead of Task Definition URL (and workaround
  for a bug in the API).
2017-11-28 13:53:42 -08:00
Tim Abbott 73a668e7ae python: Sort imports in webhooks. 2017-11-15 15:43:10 -08:00
rht 969cc506d2 zerver/webhooks: Use python 3 syntax for typing.
Tweaked by tabbott to fix various line-wrapping issues.
2017-11-04 19:40:32 -07:00
Eeshan Garg aaaed74c3d webhooks: Import REQ, has_request_variables from zerver.lib.request.
We now import REQ and has_request_variables from zerver.lib.request,
which is where these methods are defined.

Fixes #7195.
2017-11-02 14:40:55 -07:00
Eeshan Garg 20f3e9b779 webhooks/gci: Support 'needswork' event_type.
This commit adds support for payloads that are generated when a
mentor submits a task for more work.
2017-11-02 16:46:11 -02:30
Eeshan Garg 9969a3a40b webhooks/gci: Replace 'type' -> 'event_type', 'uuid' -> 'id'. 2017-11-02 16:39:48 -02:30
Eeshan Garg fb17481a7f webhooks/gci: Support claim, comment, submit, approve event types. 2017-10-16 22:01:19 -07:00
Eeshan Garg 71eee35bce webhooks: Add a Google Code-in integration. 2017-10-09 09:04:39 -07:00