fix: Dont encrypt reactions
This fixes that server sends notifications for reactions.
This commit is contained in:
parent
d047678971
commit
f1d422b89a
|
|
@ -336,6 +336,12 @@ class Encryption {
|
|||
Future<Map<String, dynamic>> encryptGroupMessagePayload(
|
||||
String roomId, Map<String, dynamic> payload,
|
||||
{String type = EventTypes.Message}) async {
|
||||
final Map<String, dynamic>? mRelatesTo = payload.remove('m.relates_to');
|
||||
// Events which only contain a m.relates_to like reactions don't need to
|
||||
// be encrypted.
|
||||
if (payload.isEmpty && mRelatesTo != null) {
|
||||
return {'m.relates_to': mRelatesTo};
|
||||
}
|
||||
final room = client.getRoomById(roomId);
|
||||
if (room == null || !room.encrypted || !enabled) {
|
||||
return payload;
|
||||
|
|
@ -357,7 +363,6 @@ class Encryption {
|
|||
// we clone the payload as we do not want to remove 'm.relates_to' from the
|
||||
// original payload passed into this function
|
||||
payload = payload.copy();
|
||||
final Map<String, dynamic>? mRelatesTo = payload.remove('m.relates_to');
|
||||
final payloadContent = {
|
||||
'content': payload,
|
||||
'type': type,
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ class Client extends MatrixApi {
|
|||
EventTypes.Message,
|
||||
EventTypes.Encrypted,
|
||||
EventTypes.Sticker,
|
||||
EventTypes.Reaction,
|
||||
]);
|
||||
|
||||
// register all the default commands
|
||||
|
|
|
|||
|
|
@ -769,14 +769,18 @@ class Room {
|
|||
String? txid,
|
||||
}) async {
|
||||
txid ??= client.generateUniqueTransactionId();
|
||||
|
||||
final mustEncrypt = encrypted && client.encryptionEnabled;
|
||||
|
||||
final sendMessageContent = mustEncrypt
|
||||
? await client.encryption!
|
||||
.encryptGroupMessagePayload(id, content, type: type)
|
||||
: content;
|
||||
return await client.sendMessage(
|
||||
id,
|
||||
mustEncrypt ? EventTypes.Encrypted : type,
|
||||
sendMessageContent.containsKey('ciphertext')
|
||||
? EventTypes.Encrypted
|
||||
: type,
|
||||
txid,
|
||||
sendMessageContent,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -277,8 +277,9 @@ void main() {
|
|||
stateKey: '',
|
||||
),
|
||||
);
|
||||
expect(room.lastEvent?.eventId, '123456');
|
||||
expect(room.lastEvent?.type, EventTypes.Reaction);
|
||||
expect(room.lastEvent?.eventId, '5');
|
||||
expect(room.lastEvent?.body, 'edited cdc');
|
||||
expect(room.lastEvent?.status, EventStatus.sent);
|
||||
});
|
||||
test('lastEvent when reply parent edited', () async {
|
||||
room.setState(
|
||||
|
|
|
|||
Loading…
Reference in New Issue