diff --git a/mautrix_facebook/portal.py b/mautrix_facebook/portal.py index d34b3a3f..a670721e 100644 --- a/mautrix_facebook/portal.py +++ b/mautrix_facebook/portal.py @@ -793,9 +793,9 @@ async def _handle_facebook_message(self, source: 'u.User', sender: 'p.Puppet', # Check in-memory queues for duplicates if oti in self._oti_dedup: dbm = self._oti_dedup.pop(oti) + self._dedup.appendleft(msg_id) self.log.debug(f"Got message ID {msg_id} for offline threading ID {oti} / {dbm.mxid}" " (in dedup queue)") - self._dedup.appendleft(msg_id) dbm.fbid = msg_id dbm.timestamp = timestamp await dbm.update() @@ -804,6 +804,8 @@ async def _handle_facebook_message(self, source: 'u.User', sender: 'p.Puppet', self.log.trace("Not handling message %s, found ID in dedup queue", msg_id) return + self._dedup.appendleft(msg_id) + # Check database for duplicates dbm = await DBMessage.get_by_fbid_or_oti(msg_id, oti, self.fb_receiver, sender.fbid) if dbm: @@ -818,7 +820,6 @@ async def _handle_facebook_message(self, source: 'u.User', sender: 'p.Puppet', return self.log.debug(f"Handling Facebook event {msg_id} (/{oti})") - self._dedup.appendleft(msg_id) if not self.mxid: mxid = await self.create_matrix_room(source) if not mxid: