Commit 61873094 authored by Philipp Hörist's avatar Philipp Hörist

Refactor parsing nickname

parent 3ffa37f2
......@@ -29,7 +29,6 @@ from gajim.common.const import KindConstant
from gajim.common.modules.base import BaseModule
from gajim.common.modules.util import get_eme_message
from gajim.common.modules.security_labels import parse_securitylabel
from gajim.common.modules.user_nickname import parse_nickname
from gajim.common.modules.misc import parse_correction
from gajim.common.modules.misc import parse_oob
from gajim.common.modules.misc import parse_xhtml
......@@ -175,6 +174,7 @@ class Message(BaseModule):
'gc_control': gc_control,
'attention': properties.attention,
'xhtml': parse_xhtml(properties),
'user_nick': properties.nickname,
}
app.nec.push_incoming_event(NetworkEvent('update-client-info',
......@@ -210,7 +210,6 @@ class Message(BaseModule):
'msg_log_id': None,
'subject': subject,
'displaymarking': parse_securitylabel(event.stanza),
'user_nick': '' if event.sent else parse_nickname(event.stanza),
}
for name, value in event_attr.items():
......
......@@ -57,12 +57,5 @@ class UserNickname(BaseModule):
nickname=nick))
def parse_nickname(stanza: nbxmpp.Node) -> str:
nick = stanza.getTag('nick', namespace=nbxmpp.NS_NICK)
if nick is None:
return ''
return nick.getData()
def get_instance(*args: Any, **kwargs: Any) -> Tuple[UserNickname, str]:
return UserNickname(*args, **kwargs), 'UserNickname'
......@@ -31,7 +31,6 @@ from gajim.common.i18n import _
from gajim.common.helpers import AdditionalDataDict
from gajim.common.nec import NetworkIncomingEvent, NetworkEvent
from gajim.common.const import KindConstant
from gajim.common.modules.user_nickname import parse_nickname
from gajim.common.modules.util import get_eme_message
from gajim.common.modules.misc import parse_correction
from gajim.common.modules.misc import parse_oob
......@@ -121,6 +120,7 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'gc_control': None,
'attention': properties.attention,
'xhtml': parse_xhtml(properties),
'user_nick': properties.nickname,
}
event = ZeroconfMessageReceivedEvent(None, **event_attr)
......@@ -144,7 +144,6 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'msg_log_id': None,
'subject': None,
'displaymarking': None,
'user_nick': parse_nickname(event.stanza),
'stanza_id': event.unique_id
}
......
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