Handle MeshCoreOne's emoji reactions

MeshCoreOne is a companion app that supports emoji reactions, using a
different message format than ours.

This commit adds support for parsing and displaying reactions received
in the MeshCoreOne format.

Their format is described here:
 https://github.com/Avi0n/MeshCoreOne/blob/main/docs/Reactions.md

Here's an example:

👍@[entropy]
b3je6qf7

Major differences compared to MeshCore-Open's reaction messages:
- includes the emoji, rather than an index code
- includes the name of who sent the message it refers to
- the hash does not depend on the sender name
This commit is contained in:
Seth Golub committed 2026-08-30 14:34:38 -07:00
1 parent e6cea37e77
commit 97f20eaec0
4 files changed
+141 -6

No files matched your search

+58
View File
@@ -340,6 +340,64 @@ void main() {
});
});
group('MeshCoreOne Reactions', () {
test('regex for matching emoji char', () {
// This is more a test of expectations than of app code, but it was
// a good place to get this sorted out cleanly, and I leave it for
// anyone interested in understanding the regex in the parsing.
final regex = RegExp(r'^(.{1,4})$');
expect(regex.firstMatch('🥳'), isNotNull);
expect(regex.firstMatch('😀'), isNotNull);
expect(regex.firstMatch('\u{1F642}'), isNotNull);
expect(regex.firstMatch('\u{1f44c}\u{1f3ff}'), isNotNull);
});
test('parse MeshCoreOne reaction', () {
final emoji = '🥳';
final senderName = 'entropy 📓';
final hash = 'b3je6qf7';
final info = ReactionHelper.parseReactionMC1(
'$emoji@[$senderName]\n$hash',
);
expect(info, isNotNull);
expect(info!.targetHash, equals('$hash:$senderName'));
expect(info.emoji, equals(emoji));
});
test('parse MeshCoreOne reaction - main entry', () {
final emoji = '🥳';
final senderName = 'entropy 📓';
final hash = 'b3je6qf7';
final info = ReactionHelper.parseReaction(
'$emoji@[$senderName]\n$hash',
);
expect(info, isNotNull);
expect(info!.targetHash, equals('$hash:$senderName'));
expect(info.emoji, equals(emoji));
});
test('parse MeshCoreOne reaction for DM chats', () {
final emoji = '🥳';
final hash = 'b3je6qf7';
final info = ReactionHelper.parseReaction('$emoji\n$hash');
expect(info, isNotNull);
expect(info!.targetHash, equals('$hash:'));
expect(info.emoji, equals(emoji));
});
test('compute MeshCoreOne reaction hash', () {
const timestamp = 1234567890;
const senderName = 'Alice';
const messageText = 'Hello world!';
final hash = ReactionHelper.computeReactionHashMC1(
timestamp,
senderName,
messageText,
);
expect(hash, equals('tyvbkb33'));
});
});
group('full reaction flow', () {
test('should encode and decode reaction correctly', () {
// Simulate sending a reaction