core (xmpp): Don't use Tx-XMPP deprecated attributes:
Some deprecated attribute from `Tx-XMPP` (`Wokkel`) were still used. This patch also remove some legacy `inlineCallbacks`.
This commit is contained in:
parent
78d72304d5
commit
eaa49911a6
3 changed files with 19 additions and 15 deletions
|
|
@ -1189,7 +1189,7 @@ class LiberviaBackend(service.Service):
|
|||
|
||||
def _roster_resync(self, profile_key):
|
||||
client = self.get_client(profile_key)
|
||||
return client.roster.resync()
|
||||
return defer.ensureDeferred(client.roster.resync())
|
||||
|
||||
## Discovery ##
|
||||
# discovery methods are shortcuts to self.memory.disco
|
||||
|
|
|
|||
|
|
@ -1192,7 +1192,7 @@ class SatXMPPClient(SatXMPPEntity, core_types.SatXMPPClient, wokkel_client.XMPPC
|
|||
)
|
||||
|
||||
def _finish_connection(self, __):
|
||||
d = self.roster.request_roster()
|
||||
d = defer.ensureDeferred(self.roster.request_roster())
|
||||
d.addCallback(lambda __: super(SatXMPPClient, self)._finish_connection(__))
|
||||
|
||||
|
||||
|
|
@ -1745,26 +1745,24 @@ class LiberviaRosterProtocol(xmppim.RosterClientProtocol):
|
|||
roster_item_elt = roster_item.toElement().toXml()
|
||||
roster_cache[roster_jid_s] = roster_item_elt
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def resync(self):
|
||||
async def resync(self):
|
||||
"""Ask full roster to resync database
|
||||
|
||||
this should not be necessary, but may be used if user suspsect roster
|
||||
to be somehow corrupted
|
||||
"""
|
||||
roster_cache = self.roster_cache
|
||||
yield roster_cache.clear()
|
||||
await roster_cache.clear()
|
||||
self._jids.clear()
|
||||
self._groups.clear()
|
||||
yield self.request_roster()
|
||||
await self.request_roster()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def request_roster(self):
|
||||
async def request_roster(self):
|
||||
"""Ask the server for Roster list"""
|
||||
if self.versioning:
|
||||
log.info(_("our server support roster versioning, we use it"))
|
||||
roster_cache = self.roster_cache
|
||||
yield roster_cache.load()
|
||||
await roster_cache.load()
|
||||
try:
|
||||
version = roster_cache[ROSTER_VER_KEY]
|
||||
except KeyError:
|
||||
|
|
@ -1787,7 +1785,7 @@ class LiberviaRosterProtocol(xmppim.RosterClientProtocol):
|
|||
version = None
|
||||
|
||||
log.debug("requesting roster")
|
||||
roster = yield self.getRoster(version=version)
|
||||
roster = await self.getRoster(version=version)
|
||||
if roster is None:
|
||||
log.debug(
|
||||
"empty roster result received, we'll get roster item with roster "
|
||||
|
|
@ -1798,18 +1796,22 @@ class LiberviaRosterProtocol(xmppim.RosterClientProtocol):
|
|||
self._groups.clear()
|
||||
self._jids = roster
|
||||
for item in roster.values():
|
||||
if not item.subscriptionTo and not item.subscriptionFrom and not item.ask:
|
||||
if (
|
||||
not item.subscriptionTo
|
||||
and not item.subscriptionFrom
|
||||
and not item.pendingOut
|
||||
):
|
||||
# XXX: current behaviour: we don't want contact in our roster list
|
||||
# if there is no presence subscription
|
||||
# may change in the future
|
||||
log.info(
|
||||
"Removing contact {} from roster because there is no presence "
|
||||
"subscription".format(item.jid)
|
||||
"subscription".format(item.entity)
|
||||
)
|
||||
self.removeItem(item.entity) # FIXME: to be checked
|
||||
else:
|
||||
self._register_item(item)
|
||||
yield self._cache_roster(roster.version)
|
||||
await self._cache_roster(roster.version)
|
||||
|
||||
if not self.got_roster.called:
|
||||
# got_roster may already be called if we use resync()
|
||||
|
|
@ -1831,7 +1833,9 @@ class LiberviaRosterProtocol(xmppim.RosterClientProtocol):
|
|||
item_attr = {
|
||||
"to": str(item.subscriptionTo),
|
||||
"from": str(item.subscriptionFrom),
|
||||
"ask": str(item.ask),
|
||||
# FIXME: `ask` was the former name used in Wokkel, now `pendingOut` is used.
|
||||
# Should we rename it too?
|
||||
"ask": str(item.pendingOut),
|
||||
}
|
||||
if item.name:
|
||||
item_attr["name"] = item.name
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ class XEP_0198(object):
|
|||
# we call the trigger who will send the <enable/> element
|
||||
d.addCallback(lambda __: self._xml_init_trigger(client))
|
||||
# then we have to re-request the roster, as changes may have occured
|
||||
d.addCallback(lambda __: client.roster.request_roster())
|
||||
d.addCallback(lambda __: defer.ensureDeferred(client.roster.request_roster()))
|
||||
# we add got_roster to be sure to have roster before sending initial presence
|
||||
d.addCallback(lambda __: client.roster.got_roster)
|
||||
if plg_0313 is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue