Merge pull request #2124 from famedly/krille/sync-for-unknown-room-in-push-helper
refactor: Sync for unknown room in push helper and catch timeout exce…
This commit is contained in:
commit
27bb592f59
|
|
@ -1790,12 +1790,19 @@ class Client extends MatrixApi {
|
||||||
if (eventId == null || roomId == null) return null;
|
if (eventId == null || roomId == null) return null;
|
||||||
|
|
||||||
// Create the room object:
|
// Create the room object:
|
||||||
final room = getRoomById(roomId) ??
|
var room =
|
||||||
await database.getSingleRoom(this, roomId) ??
|
getRoomById(roomId) ?? await database.getSingleRoom(this, roomId);
|
||||||
|
if (room == null) {
|
||||||
|
await oneShotSync()
|
||||||
|
.timeout(timeoutForServerRequests)
|
||||||
|
.catchError((_) => null);
|
||||||
|
room = getRoomById(roomId) ??
|
||||||
Room(
|
Room(
|
||||||
id: roomId,
|
id: roomId,
|
||||||
client: this,
|
client: this,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final roomName = notification.roomName;
|
final roomName = notification.roomName;
|
||||||
final roomAlias = notification.roomAlias;
|
final roomAlias = notification.roomAlias;
|
||||||
if (roomName != null) {
|
if (roomName != null) {
|
||||||
|
|
@ -1840,9 +1847,7 @@ class Client extends MatrixApi {
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
matrixEvent ??= await database
|
matrixEvent ??= await database.getEventById(eventId, room);
|
||||||
.getEventById(eventId, room)
|
|
||||||
.timeout(timeoutForServerRequests);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
matrixEvent ??= await getOneRoomEvent(roomId, eventId)
|
matrixEvent ??= await getOneRoomEvent(roomId, eventId)
|
||||||
|
|
@ -1869,9 +1874,8 @@ class Client extends MatrixApi {
|
||||||
if (room.fullyRead == matrixEvent.eventId) {
|
if (room.fullyRead == matrixEvent.eventId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final readMarkerEvent = await database
|
final readMarkerEvent = await database.getEventById(room.fullyRead, room);
|
||||||
.getEventById(room.fullyRead, room)
|
|
||||||
.timeout(timeoutForServerRequests);
|
|
||||||
if (readMarkerEvent != null &&
|
if (readMarkerEvent != null &&
|
||||||
readMarkerEvent.originServerTs.isAfter(
|
readMarkerEvent.originServerTs.isAfter(
|
||||||
matrixEvent.originServerTs
|
matrixEvent.originServerTs
|
||||||
|
|
@ -1910,7 +1914,10 @@ class Client extends MatrixApi {
|
||||||
var decrypted = await encryption.decryptRoomEvent(event);
|
var decrypted = await encryption.decryptRoomEvent(event);
|
||||||
if (decrypted.messageType == MessageTypes.BadEncrypted &&
|
if (decrypted.messageType == MessageTypes.BadEncrypted &&
|
||||||
prevBatch != null) {
|
prevBatch != null) {
|
||||||
await oneShotSync();
|
await oneShotSync()
|
||||||
|
.timeout(timeoutForServerRequests)
|
||||||
|
.catchError((_) => null);
|
||||||
|
|
||||||
decrypted = await encryption.decryptRoomEvent(event);
|
decrypted = await encryption.decryptRoomEvent(event);
|
||||||
}
|
}
|
||||||
event = decrypted;
|
event = decrypted;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ void main() {
|
||||||
group('client path', () {
|
group('client path', () {
|
||||||
late Client clientOnPath;
|
late Client clientOnPath;
|
||||||
|
|
||||||
final dbPath = join(Directory.current.path, 'test.sqlite');
|
final dbPath = join(Directory.current.path, 'client_path_test.sqlite');
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue