From 93683a8c54df61f1964d43f565cf38a9f8b8d611 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Tue, 8 Nov 2011 20:23:48 +0100
Subject: [PATCH] prevent traceback in trigger plugin.

---
 plugins/triggers/manifest.ini | 2 +-
 plugins/triggers/triggers.py  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/plugins/triggers/manifest.ini b/plugins/triggers/manifest.ini
index a31225bb5e..173bd102d0 100644
--- a/plugins/triggers/manifest.ini
+++ b/plugins/triggers/manifest.ini
@@ -1,7 +1,7 @@
 [info]
 name: Triggers
 short_name: triggers
-version: 0.0.2
+version: 0.0.3
 description: Configure Gajim's behaviour for each contact
 authors: Yann Leboulanger <asterix@lagaule.org>
 homepage: http://trac.gajim.org/wiki/
diff --git a/plugins/triggers/triggers.py b/plugins/triggers/triggers.py
index 813ae6ea54..1cfdd9769d 100644
--- a/plugins/triggers/triggers.py
+++ b/plugins/triggers/triggers.py
@@ -48,8 +48,10 @@ class Triggers(GajimPlugin):
         if rule['recipient_type'] == 'contact' and obj.jid not in \
         rule_recipients:
             return False
-        contact_groups = gajim.contacts.get_first_contact_from_jid(
-            obj.conn.name, obj.jid).groups
+        contact = gajim.contacts.get_first_contact_from_jid(obj.conn.name, obj.jid)
+        if not contact:  # PM?
+            return False
+        contact_groups = contact.groups
         group_found = False
         for group in contact_groups:
             if group in rule_recipients:
-- 
GitLab