(
webhook: AbstractBaseWebhookModel,
data: typing.Mapping, # type: ignore[type-arg]
)
| 132 | giveup_log_level=logging.WARNING, |
| 133 | ) |
| 134 | def _call_webhook( |
| 135 | webhook: AbstractBaseWebhookModel, |
| 136 | data: typing.Mapping, # type: ignore[type-arg] |
| 137 | ) -> requests.models.Response: |
| 138 | headers = {"content-type": "application/json"} |
| 139 | json_data = json.dumps(data, sort_keys=True, cls=DjangoJSONEncoder) |
| 140 | if webhook.secret: |
| 141 | signature = sign_payload(json_data, key=webhook.secret) |
| 142 | headers.update({FLAGSMITH_SIGNATURE_HEADER: signature}) |
| 143 | |
| 144 | try: |
| 145 | res = requests.post( |
| 146 | str(webhook.url), |
| 147 | data=json_data, |
| 148 | headers=headers, |
| 149 | timeout=10, |
| 150 | allow_redirects=False, |
| 151 | ) |
| 152 | res.raise_for_status() |
| 153 | return res |
| 154 | except requests.exceptions.RequestException as exc: |
| 155 | logger.debug("Error calling webhook", exc_info=exc) |
| 156 | raise |
| 157 | |
| 158 | |
| 159 | def call_webhook_with_failure_mail_after_retries( # type: ignore[no-untyped-def] |
no test coverage detected
searching dependent graphs…