feat(audit): add file view event type to distinguish preview from download by yuuhikaze · Pull Request #2563 · opencloud-eu/opencloud

@yuuhikaze @claude

…nload

Add FileViewed event type alongside FileDownloaded for audit logging:
- Reva: Add events.FileViewed event type with Unmarshal() method
- Reva: Modify events middleware to check intent parameter from gRPC Opaque
  - If intent == 'preview', emit FileViewed event
  - Otherwise, emit FileDownloaded event for backward compatibility
- Reva: Extract intent from HTTP query parameters and headers in GET handler
  - Read intent from ?intent= query param or X-OC-Intent header
  - Add to gRPC request Opaque field as 'oc:intent'
- OpenCloud: Add AuditEventFileViewed type and conversion function
- OpenCloud: Register FileViewed event handler in audit service
- OpenCloud: Update RegisteredEvents() to include FileViewed

This enables distinguishing file views from downloads for compliance tracking
and audit logging purposes. Intent is signaled client-side and propagates
through HTTP headers/query parameters to gRPC Opaque field, where the
events middleware uses it to emit appropriate audit events.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

@yuuhikaze mentioned this pull request

Apr 2, 2026
Add clear comments explaining the event conversion pattern and the purpose
of the new FileViewed event type for audit trail distinction. This improves
code readability and helps maintainers understand the design intent.
Add NOSONAR comment for squid:S3776 (cognitive complexity) to acknowledge
that large switch statements are idiomatic for event type handling.
Document why this pattern is necessary and unavoidable in event systems.