Repository: pretix/pretix

Issue:
Webhooks - pretix.event.checkin, triggered on both Entry and Exit scans
### Problem and impact

The web hook pretix.event.checkin triggers on both a Pretix Scan 'Entry' scan and a Pretix Scan 'Exit' scan.

I haven't been able to find a description of intended behaviour in the docs or a previous issue entry addressing the issue. 
Given that their is a pretix.event.checkin.reverted trigger and that the received webhook data, always presents the action as 'pretix.event.checkin' with no other entry to differentiate as an Entry or Exit scan, I am assuming that this is not the intended behaviour. 

### Expected behaviour

Trigger webhook pretix.event.checkin when an Entry scan is added
Trigger webhook pretix.event.checkin.reverted when an Exit scan is added.

### Steps to reproduce

Self-hosted Pretix, version: 2024.1.0
Setup a webhook with only pretix.event.checkin ticked.
Scan a ticket as entering event, webhook should be triggered.
Scan the ticket as exiting the event, and the webhook will again be triggered.

### Screenshots

_No response_

### Link

_No response_

### Browser (software, desktop or mobile?) and version

_No response_

### Operating system, dependency versions

_No response_

### Version

2024.1.0


Discussion:
This is in fact the intended behavior, reverted is something very different to an exit (reverted deletes a checkin log entry, exit is just another checkin log entry of a different type).
Understood, and thank you for your quick reply and clarification of expected behaviour. 

With this in mind and I appreciate I am now posing a question rather than an issue, (so please redirect me if appropriate). Is there a way to create a custom webhook that only fires on an entry or an exit scan? Or to include the type of scan in the array sent by the webhook? 
I think since we already include the check-in list in the webhook body it would make sense to include the checkin type as well, yes.

Resolving patch:
diff --git a/src/pretix/api/webhooks.py b/src/pretix/api/webhooks.py
--- a/src/pretix/api/webhooks.py
+++ b/src/pretix/api/webhooks.py
@@ -176,7 +176,7 @@ def build_payload(self, logentry: LogEntry):
         }
 
 
-class ParametrizedOrderPositionWebhookEvent(ParametrizedOrderWebhookEvent):
+class ParametrizedOrderPositionCheckinWebhookEvent(ParametrizedOrderWebhookEvent):
 
     def build_payload(self, logentry: LogEntry):
         d = super().build_payload(logentry)
@@ -185,6 +185,7 @@ def build_payload(self, logentry: LogEntry):
         d['orderposition_id'] = logentry.parsed_data.get('position')
         d['orderposition_positionid'] = logentry.parsed_data.get('positionid')
         d['checkin_list'] = logentry.parsed_data.get('list')
+        d['type'] = logentry.parsed_data.get('type')
         d['first_checkin'] = logentry.parsed_data.get('first_checkin')
         return d
 
@@ -296,11 +297,11 @@ def register_default_webhook_events(sender, **kwargs):
             'pretix.event.order.denied',
             _('Order denied'),
         ),
-        ParametrizedOrderPositionWebhookEvent(
+        ParametrizedOrderPositionCheckinWebhookEvent(
             'pretix.event.checkin',
             _('Ticket checked in'),
         ),
-        ParametrizedOrderPositionWebhookEvent(
+        ParametrizedOrderPositionCheckinWebhookEvent(
             'pretix.event.checkin.reverted',
             _('Ticket check-in reverted'),
         ),


Test patch: