Commit 49282755 authored by Yann Leboulanger's avatar Yann Leboulanger

print in groupchat when the invited contact declines the invitation

parent 130d9525
......@@ -1068,12 +1068,18 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.enc_tag = self.stanza.getTag('x', namespace=xmpp.NS_ENCRYPTED)
self.invite_tag = None
self.decline_tag = None
if not self.enc_tag:
self.invite_tag = self.stanza.getTag('x',
namespace=xmpp.NS_MUC_USER)
if self.invite_tag and not self.invite_tag.getTag('invite'):
self.invite_tag = None
self.decline_tag = self.stanza.getTag('x',
namespace=xmpp.NS_MUC_USER)
if self.decline_tag and not self.decline_tag.getTag('decline'):
self.decline_tag = None
self.thread_id = self.stanza.getThread()
self.mtype = self.stanza.getType()
if not self.mtype or self.mtype not in ('chat', 'groupchat', 'error'):
......@@ -1194,6 +1200,28 @@ class GcInvitationReceivedEvent(nec.NetworkIncomingEvent):
return True
class GcDeclineReceivedEvent(nec.NetworkIncomingEvent):
name = 'gc-decline-received'
base_network_events = []
def generate(self):
self.room_jid = self.msg_obj.fjid
item = self.msg_obj.invite_tag.getTag('decline')
try:
self.jid_from = helpers.parse_jid(item.getAttr('from'))
except helpers.InvalidFormat:
log.warn('Invalid JID: %s, ignoring it' % item.getAttr('from'))
return
jid = gajim.get_jid_without_resource(self.jid_from)
if gajim.config.get_per('accounts', self.conn.name,
'ignore_unknown_contacts') and not gajim.contacts.get_contacts(
self.conn.name, jid):
return
self.reason = item.getTagData('reason')
return True
class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
name = 'decrypted-message-received'
base_network_events = []
......
......@@ -615,6 +615,14 @@ class Interface:
self.instances[account]['gc_config'][obj.jid].\
affiliation_list_received(obj.users_dict)
def handle_event_gc_decline(self, obj):
account = obj.conn.name
gc_control = self.msg_win_mgr.get_gc_control(obj.room_jid, account)
if gc_control:
gc_control.print_conversation(
_('%(jid)s declined the invitation') % {'jid': obj.room_jid},
graphics=False)
def handle_event_gc_invitation(self, obj):
#('GC_INVITATION', (room_jid, jid_from, reason, password, is_continued))
jid = gajim.get_jid_without_resource(obj.jid_from)
......@@ -1497,6 +1505,7 @@ class Interface:
'file-request-received': [self.handle_event_file_request],
'fingerprint-error': [self.handle_event_fingerprint_error],
'gc-invitation-received': [self.handle_event_gc_invitation],
'gc-decline-received': [self.handle_event_gc_decline],
'gc-presence-received': [self.handle_event_gc_presence],
'gc-message-received': [self.handle_event_gc_message],
'gmail-notify': [self.handle_event_gmail_notify],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment