MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / _call_webhook

Function _call_webhook

api/webhooks/webhooks.py:134–156  ·  view source on GitHub ↗
(
    webhook: AbstractBaseWebhookModel,
    data: typing.Mapping,  # type: ignore[type-arg]
)

Source from the content-addressed store, hash-verified

132 giveup_log_level=logging.WARNING,
133)
134def _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
159def call_webhook_with_failure_mail_after_retries( # type: ignore[no-untyped-def]

Callers 1

call_integration_webhookFunction · 0.85

Calls 4

sign_payloadFunction · 0.90
updateMethod · 0.45
postMethod · 0.45
raise_for_statusMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…