xmltab: Remove safeJID().

This commit is contained in:
Emmanuel Gil Peyrot 2020-12-27 00:49:46 +01:00 committed by Link Mauve
parent c7bce6ba97
commit cf58bceb55

View file

@ -10,7 +10,8 @@ log = logging.getLogger(__name__)
import curses
import os
from slixmpp.xmlstream import matcher
from slixmpp import JID, InvalidJID
from slixmpp.xmlstream import matcher, StanzaBase
from slixmpp.xmlstream.tostring import tostring
from slixmpp.xmlstream.stanzabase import ElementBase
from xml.etree import ElementTree as ET
@ -21,7 +22,6 @@ from poezio import text_buffer
from poezio import windows
from poezio.xhtml import clean_text
from poezio.decorators import command_args_parser, refresh_wrapper
from poezio.common import safeJID
class MatchJID:
@ -29,9 +29,9 @@ class MatchJID:
self.jid = jid
self.dest = dest
def match(self, xml):
from_ = safeJID(xml['from'])
to_ = safeJID(xml['to'])
def match(self, xml: StanzaBase):
from_ = xml['from']
to_ = xml['to']
if self.jid.full == self.jid.bare:
from_ = from_.bare
to_ = to_.bare
@ -190,33 +190,36 @@ class XMLTab(Tab):
self.command_filter_reset()
@command_args_parser.raw
def command_filter_to(self, jid):
def command_filter_to(self, jid_str: str):
"""/filter_jid_to <jid>"""
jid_obj = safeJID(jid)
if not jid_obj:
try:
jid = JID(jid_str)
except InvalidJID:
return self.core.information('Invalid JID: %s' % jid, 'Error')
self.update_filters(MatchJID(jid_obj, dest='to'))
self.update_filters(MatchJID(jid, dest='to'))
self.refresh()
@command_args_parser.raw
def command_filter_from(self, jid):
def command_filter_from(self, jid_str: str):
"""/filter_jid_from <jid>"""
jid_obj = safeJID(jid)
if not jid_obj:
try:
jid = JID(jid_str)
except InvalidJID:
return self.core.information('Invalid JID: %s' % jid, 'Error')
self.update_filters(MatchJID(jid_obj, dest='from'))
self.update_filters(MatchJID(jid, dest='from'))
self.refresh()
@command_args_parser.raw
def command_filter_jid(self, jid):
def command_filter_jid(self, jid_str: str):
"""/filter_jid <jid>"""
jid_obj = safeJID(jid)
if not jid_obj:
try:
jid = JID(jid_str)
except InvalidJID:
return self.core.information('Invalid JID: %s' % jid, 'Error')
self.update_filters(MatchJID(jid_obj))
self.update_filters(MatchJID(jid))
self.refresh()
@command_args_parser.quoted(1)