MishkaDocument.Resources.Helpers.TenantSiteFilter (Mishka Document v0.0.1)

Copy Markdown View Source

Ash preparation that filters event logs by the actor's site_id.

EventLog stores site_id inside JSONB metadata/data fields rather than as a top-level column, so standard Ash multitenancy doesn't apply. This preparation reads the actor's site_id and applies a fragment filter.

  • Master users (site_id: nil) see all events — no filter applied.
  • Tenant users see only events matching their site_id in metadata or data, AND only events created by system (no actor) or by tenant users (not master users).
  • Anything else, a missing actor included, sees no event.

Summary

Functions

init(opts)

Callback implementation for Ash.Resource.Preparation.init/1.

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.

temporal_safe?(opts)

Callback implementation for Ash.Resource.Preparation.temporal_safe?/1.