Skip to content

Commit fdf470f

Browse files
committed
Add more event types
1 parent 3a6e1a4 commit fdf470f

13 files changed

Lines changed: 173 additions & 29 deletions

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77
///
88
/// @param <C> a Record that represents the `content` of the event.
99
public sealed interface SingletonStateEvent<C extends StateEventContent> extends StateEvent<C>
10-
permits RoomAvatarEvent,
11-
RoomCanonicalAliasEvent,
12-
RoomCreateEvent,
13-
RoomGuestAccessEvent,
14-
RoomHistoryVisibilityEvent,
15-
RoomJoinRulesEvent,
16-
RoomNameEvent,
17-
RoomPinnedEventsEvent,
18-
RoomPowerLevelsEvent,
19-
RoomTopicEvent {
10+
permits RoomAvatarEvent, RoomCanonicalAliasEvent, RoomCreateEvent, RoomEncryptionEvent, RoomGuestAccessEvent, RoomHistoryVisibilityEvent, RoomJoinRulesEvent, RoomNameEvent, RoomPinnedEventsEvent, RoomPowerLevelsEvent, RoomServerACLEvent, RoomTopicEvent {
2011

2112
@Override
2213
default String stateKey() {
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package io.github.hikingc.matrixsdk.api.events;
22

33
import io.github.hikingc.matrixsdk.api.events.matrix.StateEventContent;
4-
import io.github.hikingc.matrixsdk.api.events.server.state.RoomMemberEvent;
5-
import io.github.hikingc.matrixsdk.api.events.server.state.SpaceChildEvent;
6-
import io.github.hikingc.matrixsdk.api.events.server.state.SpaceParentEvent;
4+
import io.github.hikingc.matrixsdk.api.events.server.state.*;
75

86
/// These are events which update the metadata state of the room (e.g. room topic, room membership
97
/// etc.). State is keyed by a tuple of event type and a state_key. State in the room with the same
108
/// key-tuple will be overwritten.
119
///
1210
/// @param <C>
1311
public sealed interface StateEvent<C extends StateEventContent> extends ClientEvent<C>
14-
permits SingletonStateEvent, RoomMemberEvent, SpaceChildEvent, SpaceParentEvent { // Stripped state events are missing from this tree...
12+
permits SingletonStateEvent,
13+
RoomMemberEvent,
14+
RoomThirdPartyEvent,
15+
RoomTombstoneEvent,
16+
SpaceChildEvent,
17+
SpaceParentEvent { // Stripped state events are missing from this tree...
1518

1619
String stateKey();
1720
}

src/main/java/io/github/hikingc/matrixsdk/api/events/matrix/MessageEventContent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
/// Marker interface for input message events.
88
public sealed interface MessageEventContent
9-
permits CallAnswer,
9+
permits Reaction,
10+
Sticker,
11+
CallAnswer,
1012
CallCandidates,
1113
CallInvite,
1214
CallNegotiate,
1315
CallReject,
1416
CallSelectAnswer,
15-
Reaction,
1617
RoomMessage,
17-
RoomRedaction,
18-
Sticker {}
18+
RoomRedaction {}

src/main/java/io/github/hikingc/matrixsdk/api/events/matrix/StateEventContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
/// Marker interface for input state events.
88
public sealed interface StateEventContent
9-
permits RoomAvatar, RoomCanonicalAlias, RoomCreate, RoomGuestAccess, RoomHistoryVisibility, RoomJoinRules, RoomMember, RoomName, RoomPinnedEvents, RoomPowerLevels, RoomTopic, SpaceChild, SpaceParent {}
9+
permits RoomAvatar, RoomCanonicalAlias, RoomCreate, RoomEncryption, RoomGuestAccess, RoomHistoryVisibility, RoomJoinRules, RoomMember, RoomName, RoomPinnedEvents, RoomPowerLevels, RoomTopic, ServerACL, ThirdPartyInvite, Tombstone, SpaceChild, SpaceParent {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.github.hikingc.matrixsdk.api.events.matrix.room;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.github.hikingc.matrixsdk.api.events.matrix.StateEventContent;
5+
import org.jspecify.annotations.NonNull;
6+
7+
public record RoomEncryption(
8+
@NonNull @JsonProperty(required = true) String algorithm,
9+
Integer rotationPeriodMs,
10+
Integer rotationPeriodMsgs)
11+
implements StateEventContent {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.hikingc.matrixsdk.api.events.matrix.room;
2+
3+
import io.github.hikingc.matrixsdk.api.events.matrix.StateEventContent;
4+
5+
import java.util.List;
6+
7+
public record ServerACL(List<String> allow,
8+
Boolean allowIpLiterals,
9+
List<String> deny) implements StateEventContent {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.github.hikingc.matrixsdk.api.events.matrix.room;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.github.hikingc.matrixsdk.api.events.matrix.StateEventContent;
5+
import java.net.URI;
6+
import java.util.List;
7+
import org.jspecify.annotations.NonNull;
8+
9+
public record ThirdPartyInvite(
10+
@NonNull @JsonProperty(required = true) String displayName,
11+
@NonNull @JsonProperty(required = true) URI keyValidityUrl,
12+
@NonNull @JsonProperty(required = true) String publicKey,
13+
List<PublicKeys> publicKeys)
14+
implements StateEventContent {
15+
16+
public record PublicKeys(
17+
String keyValidityUrl, @NonNull @JsonProperty(required = true) String publicKey) {}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.hikingc.matrixsdk.api.events.matrix.room;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.github.hikingc.matrixsdk.api.events.matrix.StateEventContent;
5+
import org.jspecify.annotations.NonNull;
6+
7+
public record Tombstone(
8+
@NonNull @JsonProperty(required = true) String body,
9+
@NonNull @JsonProperty(required = true) String replacementRoom)
10+
implements StateEventContent {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.github.hikingc.matrixsdk.api.events.server.state;
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeName;
4+
import io.github.hikingc.matrixsdk.api.events.SingletonStateEvent;
5+
import io.github.hikingc.matrixsdk.api.events.UnsignedData;
6+
import io.github.hikingc.matrixsdk.api.events.matrix.room.RoomEncryption;
7+
8+
@JsonTypeName("m.room.encryption")
9+
public record RoomEncryptionEvent(
10+
RoomEncryption content,
11+
String eventId,
12+
Long originServerTs,
13+
String roomId,
14+
String sender,
15+
UnsignedData unsigned)
16+
implements SingletonStateEvent<RoomEncryption> {
17+
18+
/// @return the type of the event.
19+
@Override
20+
public String type() {
21+
return "m.room.encryption";
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.github.hikingc.matrixsdk.api.events.server.state;
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeName;
4+
import io.github.hikingc.matrixsdk.api.events.SingletonStateEvent;
5+
import io.github.hikingc.matrixsdk.api.events.UnsignedData;
6+
import io.github.hikingc.matrixsdk.api.events.matrix.room.ServerACL;
7+
8+
@JsonTypeName("m.room.server_acl")
9+
public record RoomServerACLEvent(
10+
ServerACL content,
11+
String eventId,
12+
Long originServerTs,
13+
String roomId,
14+
String sender,
15+
UnsignedData unsigned)
16+
implements SingletonStateEvent<ServerACL> {
17+
18+
/// @return the type of the event.
19+
@Override
20+
public String type() {
21+
return "m.room.server_acl";
22+
}
23+
}

0 commit comments

Comments
 (0)