fix: Requested users are not stored
Fake Matrix Events for storing need more paramters to actually get stored. This fixes it by creating a fake event ID which should be unique.
This commit is contained in:
parent
5a72287d41
commit
62a04b52d4
|
|
@ -18,9 +18,11 @@
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:html_unescape/html_unescape.dart';
|
import 'package:html_unescape/html_unescape.dart';
|
||||||
|
import 'package:matrix/src/utils/crypto/crypto.dart';
|
||||||
import 'package:matrix/src/utils/space_child.dart';
|
import 'package:matrix/src/utils/space_child.dart';
|
||||||
|
|
||||||
import '../matrix.dart';
|
import '../matrix.dart';
|
||||||
|
|
@ -1254,20 +1256,20 @@ class Room {
|
||||||
bool ignoreErrors = false,
|
bool ignoreErrors = false,
|
||||||
bool requestProfile = true,
|
bool requestProfile = true,
|
||||||
}) async {
|
}) async {
|
||||||
|
// Checks if the user is really missing
|
||||||
final stateUser = getState(EventTypes.RoomMember, mxID);
|
final stateUser = getState(EventTypes.RoomMember, mxID);
|
||||||
if (stateUser != null) {
|
if (stateUser != null) {
|
||||||
return stateUser.asUser;
|
return stateUser.asUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// it may be in the database
|
||||||
// it may be in the database
|
final dbuser = await client.database?.getUser(mxID, this);
|
||||||
final user = await client.database?.getUser(mxID, this);
|
if (dbuser != null) {
|
||||||
if (user != null) {
|
setState(dbuser);
|
||||||
setState(user);
|
onUpdate.add(id);
|
||||||
onUpdate.add(id);
|
return dbuser;
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_requestingMatrixIds.add(mxID)) return null;
|
if (!_requestingMatrixIds.add(mxID)) return null;
|
||||||
Map<String, dynamic>? resp;
|
Map<String, dynamic>? resp;
|
||||||
try {
|
try {
|
||||||
|
|
@ -1317,9 +1319,22 @@ class Room {
|
||||||
'content': resp,
|
'content': resp,
|
||||||
'state_key': mxID,
|
'state_key': mxID,
|
||||||
};
|
};
|
||||||
|
final fakeEventId = String.fromCharCodes(
|
||||||
|
await sha256(
|
||||||
|
Uint8List.fromList(
|
||||||
|
(id + mxID + client.generateUniqueTransactionId()).codeUnits),
|
||||||
|
),
|
||||||
|
);
|
||||||
await client.database?.storeEventUpdate(
|
await client.database?.storeEventUpdate(
|
||||||
EventUpdate(
|
EventUpdate(
|
||||||
content: content,
|
content: MatrixEvent(
|
||||||
|
type: EventTypes.RoomMember,
|
||||||
|
content: resp!,
|
||||||
|
stateKey: mxID,
|
||||||
|
originServerTs: DateTime.now(),
|
||||||
|
senderId: mxID,
|
||||||
|
eventId: fakeEventId,
|
||||||
|
).toJson(),
|
||||||
roomID: id,
|
roomID: id,
|
||||||
type: EventUpdateType.state,
|
type: EventUpdateType.state,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue