Fix Signal emoji sync
This commit is contained in:
@@ -221,3 +221,101 @@ class SignalInboundReplyLinkTests(TransactionTestCase):
|
||||
any(str(row.get("emoji") or "") == "❤️" for row in reactions),
|
||||
"Expected Signal heart reaction to be applied to anchor receipt payload.",
|
||||
)
|
||||
|
||||
def test_process_raw_inbound_event_applies_sync_reaction_using_destination_fallback(self):
|
||||
fake_ur = Mock()
|
||||
fake_ur.message_received = AsyncMock(return_value=None)
|
||||
fake_ur.xmpp = Mock()
|
||||
fake_ur.xmpp.client = Mock()
|
||||
fake_ur.xmpp.client.apply_external_reaction = AsyncMock(return_value=None)
|
||||
client = SignalClient.__new__(SignalClient)
|
||||
client.service = "signal"
|
||||
client.ur = fake_ur
|
||||
client.log = Mock()
|
||||
client.client = Mock()
|
||||
# Emulate sync event from our own linked device.
|
||||
client.client.bot_uuid = "f5f53a90-8b8c-4f0c-9520-8f13aab0b219"
|
||||
client.client.phone_number = "+15550009999"
|
||||
client._resolve_signal_identifiers = AsyncMock(return_value=[self.identifier])
|
||||
client._auto_link_single_user_signal_identifier = AsyncMock(return_value=[])
|
||||
|
||||
payload = {
|
||||
"envelope": {
|
||||
"sourceNumber": "+15550009999",
|
||||
"sourceUuid": "f5f53a90-8b8c-4f0c-9520-8f13aab0b219",
|
||||
"destinationNumber": "+15550002000",
|
||||
"timestamp": 1772545465000,
|
||||
"syncMessage": {
|
||||
"sentMessage": {
|
||||
"destinationNumber": "+15550002000",
|
||||
"message": {
|
||||
"reaction": {
|
||||
"emoji": "🔥",
|
||||
"targetSentTimestamp": 1772545458187,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
async_to_sync(client._process_raw_inbound_event)(json.dumps(payload))
|
||||
|
||||
self.anchor.refresh_from_db()
|
||||
reactions = list((self.anchor.receipt_payload or {}).get("reactions") or [])
|
||||
self.assertTrue(
|
||||
any(str(row.get("emoji") or "") == "🔥" for row in reactions),
|
||||
"Expected sync reaction to be applied via destination-number fallback resolution.",
|
||||
)
|
||||
|
||||
|
||||
class SignalRuntimeCommandWritebackTests(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create_user(
|
||||
username="signal-runtime-writeback-user",
|
||||
email="signal-runtime-writeback@example.com",
|
||||
password="x",
|
||||
)
|
||||
self.person = Person.objects.create(user=self.user, name="Signal Runtime")
|
||||
self.identifier = PersonIdentifier.objects.create(
|
||||
user=self.user,
|
||||
person=self.person,
|
||||
service="signal",
|
||||
identifier="+15550003000",
|
||||
)
|
||||
self.session = ChatSession.objects.create(user=self.user, identifier=self.identifier)
|
||||
self.message = Message.objects.create(
|
||||
user=self.user,
|
||||
session=self.session,
|
||||
sender_uuid="",
|
||||
custom_author="USER",
|
||||
text="queued signal send",
|
||||
ts=1772545467000,
|
||||
delivered_ts=None,
|
||||
source_service="web",
|
||||
source_message_id="1772545467000",
|
||||
source_chat_id="+15550003000",
|
||||
)
|
||||
|
||||
def test_execute_runtime_send_updates_legacy_message_ids(self):
|
||||
client = SignalClient.__new__(SignalClient)
|
||||
client.service = "signal"
|
||||
client.log = Mock()
|
||||
command = {
|
||||
"id": "cmd-1",
|
||||
"action": "send_message_raw",
|
||||
"payload": {
|
||||
"recipient": "+15550003000",
|
||||
"text": "queued signal send",
|
||||
"attachments": [],
|
||||
"metadata": {"legacy_message_id": str(self.message.id)},
|
||||
},
|
||||
}
|
||||
with patch(
|
||||
"core.clients.signal.signalapi.send_message_raw",
|
||||
new=AsyncMock(return_value=1772545467999),
|
||||
):
|
||||
async_to_sync(client._execute_runtime_command)(command)
|
||||
|
||||
self.message.refresh_from_db()
|
||||
self.assertEqual(1772545467999, int(self.message.delivered_ts or 0))
|
||||
self.assertEqual("1772545467999", str(self.message.source_message_id or ""))
|
||||
|
||||
Reference in New Issue
Block a user