xmltab: Remove safeJID().
This commit is contained in:
parent
c7bce6ba97
commit
cf58bceb55
1 changed files with 20 additions and 17 deletions
|
@ -10,7 +10,8 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import curses
|
import curses
|
||||||
import os
|
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.tostring import tostring
|
||||||
from slixmpp.xmlstream.stanzabase import ElementBase
|
from slixmpp.xmlstream.stanzabase import ElementBase
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
|
@ -21,7 +22,6 @@ from poezio import text_buffer
|
||||||
from poezio import windows
|
from poezio import windows
|
||||||
from poezio.xhtml import clean_text
|
from poezio.xhtml import clean_text
|
||||||
from poezio.decorators import command_args_parser, refresh_wrapper
|
from poezio.decorators import command_args_parser, refresh_wrapper
|
||||||
from poezio.common import safeJID
|
|
||||||
|
|
||||||
|
|
||||||
class MatchJID:
|
class MatchJID:
|
||||||
|
@ -29,9 +29,9 @@ class MatchJID:
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
self.dest = dest
|
self.dest = dest
|
||||||
|
|
||||||
def match(self, xml):
|
def match(self, xml: StanzaBase):
|
||||||
from_ = safeJID(xml['from'])
|
from_ = xml['from']
|
||||||
to_ = safeJID(xml['to'])
|
to_ = xml['to']
|
||||||
if self.jid.full == self.jid.bare:
|
if self.jid.full == self.jid.bare:
|
||||||
from_ = from_.bare
|
from_ = from_.bare
|
||||||
to_ = to_.bare
|
to_ = to_.bare
|
||||||
|
@ -190,33 +190,36 @@ class XMLTab(Tab):
|
||||||
self.command_filter_reset()
|
self.command_filter_reset()
|
||||||
|
|
||||||
@command_args_parser.raw
|
@command_args_parser.raw
|
||||||
def command_filter_to(self, jid):
|
def command_filter_to(self, jid_str: str):
|
||||||
"""/filter_jid_to <jid>"""
|
"""/filter_jid_to <jid>"""
|
||||||
jid_obj = safeJID(jid)
|
try:
|
||||||
if not jid_obj:
|
jid = JID(jid_str)
|
||||||
|
except InvalidJID:
|
||||||
return self.core.information('Invalid JID: %s' % jid, 'Error')
|
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()
|
self.refresh()
|
||||||
|
|
||||||
@command_args_parser.raw
|
@command_args_parser.raw
|
||||||
def command_filter_from(self, jid):
|
def command_filter_from(self, jid_str: str):
|
||||||
"""/filter_jid_from <jid>"""
|
"""/filter_jid_from <jid>"""
|
||||||
jid_obj = safeJID(jid)
|
try:
|
||||||
if not jid_obj:
|
jid = JID(jid_str)
|
||||||
|
except InvalidJID:
|
||||||
return self.core.information('Invalid JID: %s' % jid, 'Error')
|
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()
|
self.refresh()
|
||||||
|
|
||||||
@command_args_parser.raw
|
@command_args_parser.raw
|
||||||
def command_filter_jid(self, jid):
|
def command_filter_jid(self, jid_str: str):
|
||||||
"""/filter_jid <jid>"""
|
"""/filter_jid <jid>"""
|
||||||
jid_obj = safeJID(jid)
|
try:
|
||||||
if not jid_obj:
|
jid = JID(jid_str)
|
||||||
|
except InvalidJID:
|
||||||
return self.core.information('Invalid JID: %s' % jid, 'Error')
|
return self.core.information('Invalid JID: %s' % jid, 'Error')
|
||||||
|
|
||||||
self.update_filters(MatchJID(jid_obj))
|
self.update_filters(MatchJID(jid))
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
@command_args_parser.quoted(1)
|
@command_args_parser.quoted(1)
|
||||||
|
|
Loading…
Reference in a new issue