diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py
index ee21ccb131b1be83e089e4084036002f04fb8993..f8a0c0303d0191badd23392aee2439c32e028ae4 100644
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -1278,8 +1278,12 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
         # We do this because of MUC History messages
         type_ = self.stanza.getType()
         if type_ == 'groupchat' or self.self_message or self.muc_pm:
+            if type_ == 'groupchat':
+                archive_jid = self.stanza.getFrom().getStripped()
+            else:
+                archive_jid = self.conn.get_own_jid()
             if app.logger.find_stanza_id(account,
-                                         self.stanza.getFrom().getStripped(),
+                                         archive_jid,
                                          self.unique_id,
                                          groupchat=type_ == 'groupchat'):
                 return
diff --git a/gajim/common/logger.py b/gajim/common/logger.py
index 09dcd2dae3a07777a43175604edb7d795b518baf..485236de825668f6684125f00bd66f83ffe7fa5a 100644
--- a/gajim/common/logger.py
+++ b/gajim/common/logger.py
@@ -1201,7 +1201,7 @@ class Logger:
 
         if result is not None:
             log.info('Found duplicated message, stanza-id: %s, origin-id: %s, '
-                     'archive-jid: %s, account: %s', stanza_id, origin_id, archive_id, account_id)
+                     'archive-jid: %s, account: %s', stanza_id, origin_id, archive_jid, account_id)
             return True
         return False