Commit 2a8d5739 authored by Philipp Hörist's avatar Philipp Hörist

MUC: Identify subject change correctly

Fixes #9491
parent 5af79671
Pipeline #2833 passed with stages
in 3 minutes and 32 seconds
...@@ -432,15 +432,6 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent): ...@@ -432,15 +432,6 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
# message from server # message from server
self.nick = '' self.nick = ''
self.subject = self.stanza.getSubject()
if self.subject is not None:
app.nec.push_incoming_event(
nec.NetworkEvent('gc-subject-received',
nickname=self.msg_obj.resource,
**vars(self.msg_obj)))
return
conditions = self.stanza.getStatusConditions() conditions = self.stanza.getStatusConditions()
if conditions: if conditions:
self.status_code = [] self.status_code = []
......
...@@ -227,7 +227,10 @@ class Message: ...@@ -227,7 +227,10 @@ class Message:
subject = event.stanza.getSubject() subject = event.stanza.getSubject()
groupchat = event.mtype == 'groupchat' groupchat = event.mtype == 'groupchat'
muc_subject = subject and groupchat
# XEP-0045: only a message that contains a <subject/> but no <body/>
# element shall be considered a subject change for MUC purposes.
muc_subject = subject and groupchat and not event.msgtxt
# Determine timestamps # Determine timestamps
if groupchat: if groupchat:
...@@ -284,6 +287,11 @@ class Message: ...@@ -284,6 +287,11 @@ class Message:
event.session, event.fjid, timestamp) event.session, event.fjid, timestamp)
return return
if muc_subject:
app.nec.push_incoming_event(NetworkEvent('gc-subject-received',
**vars(event)))
return
if groupchat: if groupchat:
app.nec.push_incoming_event(GcMessageReceivedEvent( app.nec.push_incoming_event(GcMessageReceivedEvent(
None, None,
......
...@@ -1535,7 +1535,7 @@ class GroupchatControl(ChatControlBase): ...@@ -1535,7 +1535,7 @@ class GroupchatControl(ChatControlBase):
self.draw_banner_text() self.draw_banner_text()
def _nec_gc_subject_received(self, event): def _nec_gc_subject_received(self, event):
if event.conn.name != self.account: if event.account != self.account:
return return
if event.jid != self.room_jid: if event.jid != self.room_jid:
return return
...@@ -1544,7 +1544,7 @@ class GroupchatControl(ChatControlBase): ...@@ -1544,7 +1544,7 @@ class GroupchatControl(ChatControlBase):
return return
self.set_subject(event.subject) self.set_subject(event.subject)
text = _('%(nick)s has set the subject to %(subject)s') % { text = _('%(nick)s has set the subject to %(subject)s') % {
'nick': event.nickname, 'subject': event.subject} 'nick': event.resource, 'subject': event.subject}
if event.delayed: if event.delayed:
date = time.strftime('%d-%m-%Y %H:%M:%S', date = time.strftime('%d-%m-%Y %H:%M:%S',
......
...@@ -2700,10 +2700,10 @@ class RosterWindow: ...@@ -2700,10 +2700,10 @@ class RosterWindow:
def _nec_gc_subject_received(self, obj): def _nec_gc_subject_received(self, obj):
contact = app.contacts.get_contact_with_highest_priority( contact = app.contacts.get_contact_with_highest_priority(
obj.conn.name, obj.jid) obj.account, obj.jid)
if contact: if contact:
contact.status = obj.subject contact.status = obj.subject
self.draw_contact(obj.jid, obj.conn.name) self.draw_contact(obj.jid, obj.account)
def _nec_metacontacts_received(self, obj): def _nec_metacontacts_received(self, obj):
self.redraw_metacontacts(obj.conn.name) self.redraw_metacontacts(obj.conn.name)
......
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