Skip to content

Commit bcd20c3

Browse files
committed
UnknownEvent: Create UnknownEvent to handle unknown event types to the specification.
1 parent 08defe6 commit bcd20c3

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/main/java/io/github/hikingc/matrixsdk/api/events/ClientEvent.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.annotation.JsonTypeInfo;
5+
import io.github.hikingc.matrixsdk.api.events.server.UnknownEvent;
56
import io.github.hikingc.matrixsdk.api.identifiers.EventID;
67
import io.github.hikingc.matrixsdk.api.identifiers.RoomID;
78
import io.github.hikingc.matrixsdk.api.identifiers.UserID;
@@ -14,9 +15,13 @@
1415
/// @see <a href="https://spec.matrix.org/latest/client-server-api/#room-event-format">The room
1516
/// event format as defined in the specification.</a>
1617
@JsonInclude(JsonInclude.Include.NON_ABSENT)
17-
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
18+
@JsonTypeInfo(
19+
use = JsonTypeInfo.Id.NAME,
20+
include = JsonTypeInfo.As.PROPERTY,
21+
property = "type",
22+
defaultImpl = UnknownEvent.class)
1823
// This interface CANNOT permit anything other than these two.
19-
public sealed interface ClientEvent<T> permits StateEvent, MessageEvent {
24+
public sealed interface ClientEvent<T> permits StateEvent, MessageEvent, UnknownEvent {
2025

2126
/// @return the body of this event, as created by the user which sent it.
2227
T content();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.github.hikingc.matrixsdk.api.events.server;
2+
3+
import io.github.hikingc.matrixsdk.api.events.ClientEvent;
4+
import io.github.hikingc.matrixsdk.api.events.UnsignedData;
5+
import io.github.hikingc.matrixsdk.api.identifiers.EventID;
6+
import io.github.hikingc.matrixsdk.api.identifiers.RoomID;
7+
import io.github.hikingc.matrixsdk.api.identifiers.UserID;
8+
9+
public record UnknownEvent(
10+
Object content,
11+
EventID eventId,
12+
Long originServerTs,
13+
RoomID roomId,
14+
UserID sender,
15+
String type,
16+
UnsignedData unsigned)
17+
implements ClientEvent<Object> {}

0 commit comments

Comments
 (0)