Merge branch 'caps-broadcast-presence' into 'master'
Caps: do not broadcast presence on PEP plugin load/unload See merge request poezio/slixmpp!157
This commit is contained in:
commit
3630c3d1cc
@ -11,9 +11,12 @@ class TestUserAvatar(SlixIntegration):
|
|||||||
self.envjid('CI_ACCOUNT1'),
|
self.envjid('CI_ACCOUNT1'),
|
||||||
self.envstr('CI_ACCOUNT1_PASSWORD'),
|
self.envstr('CI_ACCOUNT1_PASSWORD'),
|
||||||
)
|
)
|
||||||
self.register_plugins(['xep_0084'])
|
self.register_plugins(['xep_0084', 'xep_0115'])
|
||||||
self.data = b'coucou coucou'
|
self.data = b'coucou coucou'
|
||||||
await self.connect_clients()
|
await self.connect_clients()
|
||||||
|
await asyncio.gather(
|
||||||
|
self.clients[0]['xep_0115'].update_caps(),
|
||||||
|
)
|
||||||
|
|
||||||
async def _clear_avatar(self):
|
async def _clear_avatar(self):
|
||||||
"""Utility for purging remote state"""
|
"""Utility for purging remote state"""
|
||||||
|
@ -8,6 +8,7 @@ import hashlib
|
|||||||
import base64
|
import base64
|
||||||
|
|
||||||
from asyncio import Future
|
from asyncio import Future
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from slixmpp import __version__
|
from slixmpp import __version__
|
||||||
from slixmpp.stanza import StreamFeatures, Presence, Iq
|
from slixmpp.stanza import StreamFeatures, Presence, Iq
|
||||||
@ -15,10 +16,10 @@ from slixmpp.xmlstream import register_stanza_plugin, JID
|
|||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.util import MemoryCache
|
from slixmpp.util import MemoryCache
|
||||||
from slixmpp import asyncio
|
from slixmpp.exceptions import XMPPError
|
||||||
from slixmpp.exceptions import XMPPError, IqError, IqTimeout
|
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.plugins.xep_0115 import stanza, StaticCaps
|
from slixmpp.plugins.xep_0115 import stanza, StaticCaps
|
||||||
|
from slixmpp.types import OptJidStr
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -285,7 +286,17 @@ class XEP_0115(BasePlugin):
|
|||||||
binary = hash(S.encode('utf8')).digest()
|
binary = hash(S.encode('utf8')).digest()
|
||||||
return base64.b64encode(binary).decode('utf-8')
|
return base64.b64encode(binary).decode('utf-8')
|
||||||
|
|
||||||
async def update_caps(self, jid=None, node=None, preserve=False):
|
async def update_caps(self, jid: OptJidStr = None,
|
||||||
|
node: Optional[str] = None,
|
||||||
|
preserve: bool = False,
|
||||||
|
broadcast: bool = True):
|
||||||
|
"""Update caps for a local JID based on current data.
|
||||||
|
|
||||||
|
:param jid: JID whose info to update
|
||||||
|
:param node: Node to fetch info from
|
||||||
|
:param broadcast: Send a presence after updating.
|
||||||
|
:param preserve: Send presence only to contacts found in the roster.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
info = await self.xmpp['xep_0030'].get_info(jid, node, local=True)
|
info = await self.xmpp['xep_0030'].get_info(jid, node, local=True)
|
||||||
if isinstance(info, Iq):
|
if isinstance(info, Iq):
|
||||||
@ -299,7 +310,7 @@ class XEP_0115(BasePlugin):
|
|||||||
await self.cache_caps(ver, info)
|
await self.cache_caps(ver, info)
|
||||||
await self.assign_verstring(jid, ver)
|
await self.assign_verstring(jid, ver)
|
||||||
|
|
||||||
if self.xmpp.sessionstarted and self.broadcast:
|
if broadcast and self.xmpp.sessionstarted and self.broadcast:
|
||||||
if self.xmpp.is_component or preserve:
|
if self.xmpp.is_component or preserve:
|
||||||
for contact in self.xmpp.roster[jid]:
|
for contact in self.xmpp.roster[jid]:
|
||||||
self.xmpp.roster[jid][contact].send_last_presence()
|
self.xmpp.roster[jid][contact].send_last_presence()
|
||||||
|
@ -61,7 +61,7 @@ class XEP_0163(BasePlugin):
|
|||||||
self.xmpp['xep_0030'].add_feature('%s+notify' % ns,
|
self.xmpp['xep_0030'].add_feature('%s+notify' % ns,
|
||||||
jid=jid)
|
jid=jid)
|
||||||
asyncio.ensure_future(
|
asyncio.ensure_future(
|
||||||
self.xmpp['xep_0115'].update_caps(jid),
|
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
||||||
loop=self.xmpp.loop,
|
loop=self.xmpp.loop,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class XEP_0163(BasePlugin):
|
|||||||
self.xmpp['xep_0030'].del_feature(jid=jid,
|
self.xmpp['xep_0030'].del_feature(jid=jid,
|
||||||
feature='%s+notify' % namespace)
|
feature='%s+notify' % namespace)
|
||||||
asyncio.ensure_future(
|
asyncio.ensure_future(
|
||||||
self.xmpp['xep_0115'].update_caps(jid),
|
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
||||||
loop=self.xmpp.loop,
|
loop=self.xmpp.loop,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user