Merge branch 'room-fix-requesthistoryquery' into 'master'
[Room] Fix the requestHistory query. See merge request famedly/famedlysdk!25
This commit is contained in:
commit
a05068d156
|
@ -106,7 +106,7 @@ class Room {
|
||||||
this.avatar,
|
this.avatar,
|
||||||
this.notificationCount,
|
this.notificationCount,
|
||||||
this.highlightCount,
|
this.highlightCount,
|
||||||
this.prev_batch,
|
this.prev_batch = "",
|
||||||
this.draft,
|
this.draft,
|
||||||
this.unread,
|
this.unread,
|
||||||
this.fullyRead,
|
this.fullyRead,
|
||||||
|
@ -295,8 +295,8 @@ class Room {
|
||||||
Future<void> requestHistory({int historyCount = 100}) async {
|
Future<void> requestHistory({int historyCount = 100}) async {
|
||||||
final dynamic resp = await client.connection.jsonRequest(
|
final dynamic resp = await client.connection.jsonRequest(
|
||||||
type: "GET",
|
type: "GET",
|
||||||
action: "/client/r0/rooms/$id/messages",
|
action:
|
||||||
data: {"from": prev_batch, "dir": "b", "limit": historyCount});
|
"/client/r0/rooms/$id/messages?from=${prev_batch}&dir=b&limit=$historyCount");
|
||||||
|
|
||||||
if (resp is ErrorResponse) return;
|
if (resp is ErrorResponse) return;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,11 @@ class FakeMatrixApi extends MockClient {
|
||||||
FakeMatrixApi()
|
FakeMatrixApi()
|
||||||
: super((request) async {
|
: super((request) async {
|
||||||
// Collect data from Request
|
// Collect data from Request
|
||||||
final String action = request.url.path.split("/_matrix")[1];
|
String action =
|
||||||
|
request.url.path.split("/_matrix")[1] + "?" + request.url.query;
|
||||||
|
if (action.endsWith("?")) action = action.replaceAll("?", "");
|
||||||
final String method = request.method;
|
final String method = request.method;
|
||||||
|
print("Got action: $action");
|
||||||
final dynamic data =
|
final dynamic data =
|
||||||
method == "GET" ? request.url.queryParameters : request.body;
|
method == "GET" ? request.url.queryParameters : request.body;
|
||||||
var res = {};
|
var res = {};
|
||||||
|
@ -76,64 +79,65 @@ class FakeMatrixApi extends MockClient {
|
||||||
"origin_server_ts": 1432735824653,
|
"origin_server_ts": 1432735824653,
|
||||||
"unsigned": {"age": 1234}
|
"unsigned": {"age": 1234}
|
||||||
},
|
},
|
||||||
"/client/r0/rooms/!1234:example.com/messages": (var req) => {
|
"/client/r0/rooms/!1234:example.com/messages?from=1234&dir=b&limit=100":
|
||||||
"start": "t47429-4392820_219380_26003_2265",
|
(var req) => {
|
||||||
"end": "t47409-4357353_219380_26003_2265",
|
"start": "t47429-4392820_219380_26003_2265",
|
||||||
"chunk": [
|
"end": "t47409-4357353_219380_26003_2265",
|
||||||
{
|
"chunk": [
|
||||||
"content": {
|
{
|
||||||
"body": "This is an example text message",
|
"content": {
|
||||||
"msgtype": "m.text",
|
"body": "This is an example text message",
|
||||||
"format": "org.matrix.custom.html",
|
"msgtype": "m.text",
|
||||||
"formatted_body": "<b>This is an example text message</b>"
|
"format": "org.matrix.custom.html",
|
||||||
},
|
"formatted_body": "<b>This is an example text message</b>"
|
||||||
"type": "m.room.message",
|
|
||||||
"event_id": "3143273582443PhrSn:example.org",
|
|
||||||
"room_id": "!1234:example.com",
|
|
||||||
"sender": "@example:example.org",
|
|
||||||
"origin_server_ts": 1432735824653,
|
|
||||||
"unsigned": {"age": 1234}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": {"name": "The room name"},
|
|
||||||
"type": "m.room.name",
|
|
||||||
"event_id": "2143273582443PhrSn:example.org",
|
|
||||||
"room_id": "!1234:example.com",
|
|
||||||
"sender": "@example:example.org",
|
|
||||||
"origin_server_ts": 1432735824653,
|
|
||||||
"unsigned": {"age": 1234},
|
|
||||||
"state_key": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": {
|
|
||||||
"body": "Gangnam Style",
|
|
||||||
"url": "mxc://example.org/a526eYUSFFxlgbQYZmo442",
|
|
||||||
"info": {
|
|
||||||
"thumbnail_url":
|
|
||||||
"mxc://example.org/FHyPlCeYUSFFxlgbQYZmoEoe",
|
|
||||||
"thumbnail_info": {
|
|
||||||
"mimetype": "image/jpeg",
|
|
||||||
"size": 46144,
|
|
||||||
"w": 300,
|
|
||||||
"h": 300
|
|
||||||
},
|
},
|
||||||
"w": 480,
|
"type": "m.room.message",
|
||||||
"h": 320,
|
"event_id": "3143273582443PhrSn:example.org",
|
||||||
"duration": 2140786,
|
"room_id": "!1234:example.com",
|
||||||
"size": 1563685,
|
"sender": "@example:example.org",
|
||||||
"mimetype": "video/mp4"
|
"origin_server_ts": 1432735824653,
|
||||||
|
"unsigned": {"age": 1234}
|
||||||
},
|
},
|
||||||
"msgtype": "m.video"
|
{
|
||||||
},
|
"content": {"name": "The room name"},
|
||||||
"type": "m.room.message",
|
"type": "m.room.name",
|
||||||
"event_id": "1143273582443PhrSn:example.org",
|
"event_id": "2143273582443PhrSn:example.org",
|
||||||
"room_id": "!1234:example.com",
|
"room_id": "!1234:example.com",
|
||||||
"sender": "@example:example.org",
|
"sender": "@example:example.org",
|
||||||
"origin_server_ts": 1432735824653,
|
"origin_server_ts": 1432735824653,
|
||||||
"unsigned": {"age": 1234}
|
"unsigned": {"age": 1234},
|
||||||
}
|
"state_key": ""
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
|
"content": {
|
||||||
|
"body": "Gangnam Style",
|
||||||
|
"url": "mxc://example.org/a526eYUSFFxlgbQYZmo442",
|
||||||
|
"info": {
|
||||||
|
"thumbnail_url":
|
||||||
|
"mxc://example.org/FHyPlCeYUSFFxlgbQYZmoEoe",
|
||||||
|
"thumbnail_info": {
|
||||||
|
"mimetype": "image/jpeg",
|
||||||
|
"size": 46144,
|
||||||
|
"w": 300,
|
||||||
|
"h": 300
|
||||||
|
},
|
||||||
|
"w": 480,
|
||||||
|
"h": 320,
|
||||||
|
"duration": 2140786,
|
||||||
|
"size": 1563685,
|
||||||
|
"mimetype": "video/mp4"
|
||||||
|
},
|
||||||
|
"msgtype": "m.video"
|
||||||
|
},
|
||||||
|
"type": "m.room.message",
|
||||||
|
"event_id": "1143273582443PhrSn:example.org",
|
||||||
|
"room_id": "!1234:example.com",
|
||||||
|
"sender": "@example:example.org",
|
||||||
|
"origin_server_ts": 1432735824653,
|
||||||
|
"unsigned": {"age": 1234}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"/client/versions": (var req) => {
|
"/client/versions": (var req) => {
|
||||||
"versions": ["r0.0.1", "r0.1.0", "r0.2.0", "r0.3.0", "r0.4.0"],
|
"versions": ["r0.0.1", "r0.1.0", "r0.2.0", "r0.3.0", "r0.4.0"],
|
||||||
"unstable_features": {"m.lazy_load_members": true},
|
"unstable_features": {"m.lazy_load_members": true},
|
||||||
|
@ -306,134 +310,140 @@ class FakeMatrixApi extends MockClient {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/client/r0/sync": (var req) => {
|
"/client/r0/sync?filters=%7B%22room%22:%7B%22include_leave%22:true,%22state%22:%7B%22lazy_load_members%22:1%7D%7D":
|
||||||
"next_batch": Random().nextDouble().toString(),
|
(var req) => {
|
||||||
"presence": {
|
"next_batch": Random().nextDouble().toString(),
|
||||||
"events": [
|
"presence": {
|
||||||
{
|
"events": [
|
||||||
"sender": "@alice:example.com",
|
{
|
||||||
"type": "m.presence",
|
"sender": "@alice:example.com",
|
||||||
"content": {"presence": "online"}
|
"type": "m.presence",
|
||||||
}
|
"content": {"presence": "online"}
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
"account_data": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"type": "org.example.custom.config",
|
|
||||||
"content": {"custom_config_key": "custom_config_value"}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"to_device": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"sender": "@alice:example.com",
|
|
||||||
"type": "m.new_device",
|
|
||||||
"content": {
|
|
||||||
"device_id": "XYZABCDE",
|
|
||||||
"rooms": ["!726s6s6q:example.com"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"rooms": {
|
|
||||||
"join": {
|
|
||||||
"!726s6s6q:example.com": {
|
|
||||||
"unread_notifications": {
|
|
||||||
"highlight_count": 2,
|
|
||||||
"notification_count": 2,
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"sender": "@alice:example.com",
|
|
||||||
"type": "m.room.member",
|
|
||||||
"state_key": "@alice:example.com",
|
|
||||||
"content": {"membership": "join"},
|
|
||||||
"origin_server_ts": 1417731086795,
|
|
||||||
"event_id": "66697273743031:example.com"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"timeline": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"sender": "@bob:example.com",
|
|
||||||
"type": "m.room.member",
|
|
||||||
"state_key": "@bob:example.com",
|
|
||||||
"content": {"membership": "join"},
|
|
||||||
"prev_content": {"membership": "invite"},
|
|
||||||
"origin_server_ts": 1417731086795,
|
|
||||||
"event_id": "7365636s6r6432:example.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sender": "@alice:example.com",
|
|
||||||
"type": "m.room.message",
|
|
||||||
"txn_id": "1234",
|
|
||||||
"content": {"body": "I am a fish", "msgtype": "m.text"},
|
|
||||||
"origin_server_ts": 1417731086797,
|
|
||||||
"event_id": "74686972643033:example.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"limited": true,
|
|
||||||
"prev_batch": "t34-23535_0_0"
|
|
||||||
},
|
|
||||||
"ephemeral": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"type": "m.typing",
|
|
||||||
"content": {
|
|
||||||
"user_ids": ["@alice:example.com"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"account_data": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"type": "m.tag",
|
|
||||||
"content": {
|
|
||||||
"tags": {
|
|
||||||
"work": {"order": 1}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "org.example.custom.room.config",
|
|
||||||
"content": {"custom_config_key": "custom_config_value"}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"invite": {
|
|
||||||
"!696r7674:example.com": {
|
|
||||||
"invite_state": {
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"sender": "@alice:example.com",
|
|
||||||
"type": "m.room.name",
|
|
||||||
"state_key": "",
|
|
||||||
"content": {"name": "My Room Name"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sender": "@alice:example.com",
|
|
||||||
"type": "m.room.member",
|
|
||||||
"state_key": "@bob:example.com",
|
|
||||||
"content": {"membership": "invite"}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"leave": {
|
|
||||||
"!5345234234:example.com": {
|
|
||||||
"timeline": {"events": []}
|
|
||||||
},
|
},
|
||||||
|
"account_data": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"type": "org.example.custom.config",
|
||||||
|
"content": {"custom_config_key": "custom_config_value"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"to_device": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"sender": "@alice:example.com",
|
||||||
|
"type": "m.new_device",
|
||||||
|
"content": {
|
||||||
|
"device_id": "XYZABCDE",
|
||||||
|
"rooms": ["!726s6s6q:example.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rooms": {
|
||||||
|
"join": {
|
||||||
|
"!726s6s6q:example.com": {
|
||||||
|
"unread_notifications": {
|
||||||
|
"highlight_count": 2,
|
||||||
|
"notification_count": 2,
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"sender": "@alice:example.com",
|
||||||
|
"type": "m.room.member",
|
||||||
|
"state_key": "@alice:example.com",
|
||||||
|
"content": {"membership": "join"},
|
||||||
|
"origin_server_ts": 1417731086795,
|
||||||
|
"event_id": "66697273743031:example.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timeline": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"sender": "@bob:example.com",
|
||||||
|
"type": "m.room.member",
|
||||||
|
"state_key": "@bob:example.com",
|
||||||
|
"content": {"membership": "join"},
|
||||||
|
"prev_content": {"membership": "invite"},
|
||||||
|
"origin_server_ts": 1417731086795,
|
||||||
|
"event_id": "7365636s6r6432:example.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sender": "@alice:example.com",
|
||||||
|
"type": "m.room.message",
|
||||||
|
"txn_id": "1234",
|
||||||
|
"content": {
|
||||||
|
"body": "I am a fish",
|
||||||
|
"msgtype": "m.text"
|
||||||
|
},
|
||||||
|
"origin_server_ts": 1417731086797,
|
||||||
|
"event_id": "74686972643033:example.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"limited": true,
|
||||||
|
"prev_batch": "t34-23535_0_0"
|
||||||
|
},
|
||||||
|
"ephemeral": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"type": "m.typing",
|
||||||
|
"content": {
|
||||||
|
"user_ids": ["@alice:example.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"account_data": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"type": "m.tag",
|
||||||
|
"content": {
|
||||||
|
"tags": {
|
||||||
|
"work": {"order": 1}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "org.example.custom.room.config",
|
||||||
|
"content": {
|
||||||
|
"custom_config_key": "custom_config_value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"invite": {
|
||||||
|
"!696r7674:example.com": {
|
||||||
|
"invite_state": {
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"sender": "@alice:example.com",
|
||||||
|
"type": "m.room.name",
|
||||||
|
"state_key": "",
|
||||||
|
"content": {"name": "My Room Name"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sender": "@alice:example.com",
|
||||||
|
"type": "m.room.member",
|
||||||
|
"state_key": "@bob:example.com",
|
||||||
|
"content": {"membership": "invite"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"leave": {
|
||||||
|
"!5345234234:example.com": {
|
||||||
|
"timeline": {"events": []}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"POST": {
|
"POST": {
|
||||||
"/client/r0/login": (var req) => {
|
"/client/r0/login": (var req) => {
|
||||||
|
|
|
@ -41,7 +41,7 @@ void main() {
|
||||||
client.connection.httpClient = FakeMatrixApi();
|
client.connection.httpClient = FakeMatrixApi();
|
||||||
client.homeserver = "https://fakeServer.notExisting";
|
client.homeserver = "https://fakeServer.notExisting";
|
||||||
|
|
||||||
Room room = Room(id: roomID, client: client);
|
Room room = Room(id: roomID, client: client, prev_batch: "1234");
|
||||||
Timeline timeline = Timeline(
|
Timeline timeline = Timeline(
|
||||||
room: room,
|
room: room,
|
||||||
events: [],
|
events: [],
|
||||||
|
|
Loading…
Reference in a new issue