Skip to content

Commit cfd386c

Browse files
committed
Add RoomState Store interface
1 parent 7a1dbf4 commit cfd386c

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

Sources/MatrixClient/API/Events/Messages/Messages.Codable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum MatrixMessageTypeCodingKeys: String, CodingKey {
1818
case type = "msgtype"
1919
}
2020

21-
extension CodingUserInfoKey {
21+
public extension CodingUserInfoKey {
2222
static var matrixMessageTypes: CodingUserInfoKey {
2323
CodingUserInfoKey(rawValue: "MatrixClient.MessageTypes")!
2424
}

Sources/MatrixClient/API/Events/RoomEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension KeyedDecodingContainer {
3232
}
3333
}
3434

35-
extension CodingUserInfoKey {
35+
public extension CodingUserInfoKey {
3636
/// The key used to determine the types of `MatrixEvent` that can be decoded.
3737
static var matrixEventTypes: CodingUserInfoKey {
3838
CodingUserInfoKey(rawValue: "MatrixClient.EventTypes")!

Sources/MatrixClient/API/Events/State/StateEvent+Codable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum MatrixStateEventTypeCodingKeys: String, CodingKey {
1616
case content
1717
}
1818

19-
extension CodingUserInfoKey {
19+
public extension CodingUserInfoKey {
2020
static var matrixStateEventTypes: CodingUserInfoKey {
2121
CodingUserInfoKey(rawValue: "MatrixClient.StateTypes")!
2222
}

Sources/MatrixCore/MatrixStore.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public protocol MatrixStore {
1414

1515
/// Type for Account Informations.
1616
associatedtype AccountInfo: MatrixStoreAccountInfo
17+
associatedtype RoomState: MatrixStoreRoomState
1718

1819
@available(swift, introduced: 5.5)
1920
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@@ -30,4 +31,28 @@ public protocol MatrixStore {
3031
@available(swift, introduced: 5.5)
3132
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
3233
func deleteAccountInfo(account: AccountInfo) async throws
34+
35+
// MARK: - Room
36+
37+
// MARK: Room State
38+
39+
@available(swift, introduced: 5.5)
40+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
41+
func addRoomState(state: RoomState) async throws
42+
43+
@available(swift, introduced: 5.5)
44+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
45+
func getRoomState(roomId: String) async throws -> [RoomState]
46+
@available(swift, introduced: 5.5)
47+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
48+
func getRoomState(eventId: String) async throws -> RoomState?
49+
@available(swift, introduced: 5.5)
50+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
51+
func getRoomState(roomId: String, stateType: String) async throws -> [RoomState]
52+
@available(swift, introduced: 5.5)
53+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
54+
func getRoomState(roomId: String, stateKey: String) async throws -> [RoomState]
55+
@available(swift, introduced: 5.5)
56+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
57+
func getRoomState(roomId: String, stateType: String, stateKey: String) async throws -> [RoomState]
3358
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// File.swift
3+
//
4+
//
5+
// Created by Finn Behrens on 24.04.22.
6+
//
7+
8+
import Foundation
9+
import MatrixClient
10+
11+
public protocol MatrixStoreRoomState {
12+
var eventId: String { get }
13+
var roomId: String { get }
14+
var stateKey: String { get }
15+
var contentType: String { get }
16+
var content: MatrixStateEventType { get }
17+
}

0 commit comments

Comments
 (0)