MCPcopy
hub / github.com/learnhouse/learnhouse / dispatch_webhooks

Function dispatch_webhooks

apps/api/src/services/webhooks/dispatch.py:73–98  ·  view source on GitHub ↗

Public entry point. Schedules webhook delivery as a background task. Args: event_name: The event that occurred (e.g. "course_completed"). org_id: The organization where the event happened. data: Event-specific payload data. webhook_ids: If provided, only del

(
    event_name: str,
    org_id: int,
    data: dict,
    webhook_ids: Optional[List[int]] = None,
)

Source from the content-addressed store, hash-verified

71
72
73async def dispatch_webhooks(
74 event_name: str,
75 org_id: int,
76 data: dict,
77 webhook_ids: Optional[List[int]] = None,
78) -> None:
79 """
80 Public entry point. Schedules webhook delivery as a background task.
81
82 Args:
83 event_name: The event that occurred (e.g. "course_completed").
84 org_id: The organization where the event happened.
85 data: Event-specific payload data.
86 webhook_ids: If provided, only deliver to these specific endpoints
87 (used by the test/ping feature).
88 """
89 validate_event_data(event_name, data)
90 task = asyncio.create_task(
91 _deliver_webhooks(event_name, org_id, data, webhook_ids)
92 )
93 _background_tasks.add(task)
94 task.add_done_callback(_background_tasks.discard)
95 task.add_done_callback(
96 lambda t: logger.error("Webhook delivery batch failed: %s", t.exception())
97 if not t.cancelled() and t.exception() else None
98 )
99
100
101async def _deliver_webhooks(

Callers 15

create_usergroupFunction · 0.90
delete_usergroup_by_idFunction · 0.90
add_users_to_usergroupFunction · 0.90
verify_email_tokenFunction · 0.90
create_userFunction · 0.90
create_discussionFunction · 0.90
pin_discussionFunction · 0.90
lock_discussionFunction · 0.90
create_commentFunction · 0.90
upvote_discussionFunction · 0.90
create_updateFunction · 0.90

Calls 4

validate_event_dataFunction · 0.90
_deliver_webhooksFunction · 0.85
add_done_callbackMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected