Fix displaying MUC subjects with delay tag

Dont print it as "old" conversation, instead add the delay timestamp
at the end of the subject
This commit is contained in:
Philipp Hörist 2018-08-30 19:19:14 +02:00 committed by Philipp Hörist
parent a8534800b0
commit 41a7196620
4 changed files with 20 additions and 34 deletions

View File

@ -25,7 +25,6 @@ from calendar import timegm
import hashlib
import hmac
import logging
import sys
from time import time as time_time
import OpenSSL.crypto
@ -499,13 +498,13 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
# message from server
self.nick = ''
self.has_timestamp = bool(self.stanza.timestamp)
self.subject = self.stanza.getSubject()
if self.subject is not None:
app.nec.push_incoming_event(GcSubjectReceivedEvent(None,
conn=self.conn, msg_event=self))
app.nec.push_incoming_event(
nec.NetworkEvent('gc-subject-received',
nickname=self.msg_obj.resource,
**vars(self.msg_obj)))
return
conditions = self.stanza.getStatusConditions()
@ -566,21 +565,6 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
return True
class GcSubjectReceivedEvent(nec.NetworkIncomingEvent):
name = 'gc-subject-received'
base_network_events = []
def generate(self):
self.conn = self.msg_event.conn
self.stanza = self.msg_event.stanza
self.room_jid = self.msg_event.room_jid
self.nickname = self.msg_event.nickname
self.fjid = self.msg_event.fjid
self.subject = self.msg_event.subject
self.msgtxt = self.msg_event.msgtxt
self.has_timestamp = self.msg_event.has_timestamp
return True
class GcConfigChangedReceivedEvent(nec.NetworkIncomingEvent):
name = 'gc-config-changed-received'
base_network_events = []

View File

@ -1239,7 +1239,7 @@ class GroupchatControl(ChatControlBase):
additional_data=obj.additional_data)
else:
# message from someone
if obj.has_timestamp:
if obj.delayed:
# don't print xhtml if it's an old message.
# Like that xhtml messages are grayed too.
self.print_old_conversation(
@ -1492,20 +1492,22 @@ class GroupchatControl(ChatControlBase):
self.subject = subject
self.draw_banner_text()
def _nec_gc_subject_received(self, obj):
if obj.conn.name != self.account:
def _nec_gc_subject_received(self, event):
if event.conn.name != self.account:
return
if obj.room_jid != self.room_jid:
if event.jid != self.room_jid:
return
self.set_subject(obj.subject)
self.set_subject(event.subject)
text = _('%(nick)s has set the subject to %(subject)s') % {
'nick': obj.nickname, 'subject': obj.subject}
if obj.has_timestamp:
self.print_old_conversation(text)
else:
self.print_conversation(text)
'nick': event.nickname, 'subject': event.subject}
if obj.subject == '':
if event.delayed:
date = time.strftime('%d-%m-%Y %H:%M:%S',
time.localtime(event.timestamp))
text = '%s - %s' % (text, date)
self.print_conversation(text)
if event.subject == '':
self.subject_button.hide()
else:
self.subject_button.show()

View File

@ -383,7 +383,7 @@ class GajimRemote(Server):
# event has not been handled at GUI level
return
self.raise_signal('GCMessage', (obj.conn.name, [obj.fjid, obj.msgtxt,
obj.timestamp, obj.has_timestamp, obj.xhtml_msgtxt, obj.status_code,
obj.timestamp, obj.delayed, obj.xhtml_msgtxt, obj.status_code,
obj.displaymarking, obj.captcha_form, obj.needs_highlight]))
def on_our_status(self, obj):

View File

@ -2694,10 +2694,10 @@ class RosterWindow:
def _nec_gc_subject_received(self, obj):
contact = app.contacts.get_contact_with_highest_priority(
obj.conn.name, obj.room_jid)
obj.conn.name, obj.jid)
if contact:
contact.status = obj.subject
self.draw_contact(obj.room_jid, obj.conn.name)
self.draw_contact(obj.jid, obj.conn.name)
def _nec_metacontacts_received(self, obj):
self.redraw_metacontacts(obj.conn.name)