async-matrixSourceAsyncMatrixApplicationServiceEvent

class Event

Represents a Matrix event received via the Application Service API.

Provides typed accessors for all envelope fields plus schema-driven validation using the official Matrix spec YAML schemas.

event = Event.new(raw_hash) event.type # => "m.room.message" event.sender # => "@alice:example.org" event.content.body # => "hello" event.valid? # => true event.valid! # => true (or raises Schema::ValidationError)

Definitions

def schema

The JSONSchemer::Schema for this event's type, or nil if unknown.

def valid?

Validate this event against its schema. Returns true if valid or if no schema exists (lenient).

def valid!

Validate this event against its schema. Raises Schema::ValidationError with detailed errors on failure. Returns true if valid or if no schema exists.

Implementation

def valid!
	errors = Schema.validate(@raw)
	unless errors.empty?
		raise Schema::ValidationError.new(
			errors,
			event_type: @type,
			event_id: @event_id
		)
	end
	true
end

def content_properties

Content property names defined by the schema for this event type.

def state_event?

Is this a state event? (has a state_key)