sendReaction method
Implementation
Future<void> sendReaction(
String messageHash, {
required String symbol,
}) async {
final messageEvent = await _db.events
.id<MessageEventModel>(messageHash)
.get();
if (messageEvent == null) {
throw StateError('Missing message event for reaction');
}
final secretKey = await openSecretKey(messageEvent);
if (secretKey == null) {
throw StateError('Missing message secret key for reaction');
}
final ciphertext = await _encryption.encryptSecret(secretKey, symbol);
final event = await _client.events.publish(
MessageReactionEventBodyModel(hash: messageHash, ciphertext: ciphertext),
);
final peerKeys = messageEvent.body.peers;
final devices = await _db.devices.online.get();
for (final device in devices) {
if (!device.isCurrent && peerKeys.contains(device.peerKey)) {
await _client.events.relayDevice(device.signingKey, event);
}
}
}