slidge 0.2.7.post1__py3-none-any.whl → 0.2.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
slidge/__init__.py CHANGED
@@ -6,6 +6,7 @@ Contains importable classes for a minimal function :term:`Legacy Module`.
6
6
 
7
7
  import sys
8
8
  import warnings
9
+ from importlib.metadata import PackageNotFoundError, version
9
10
 
10
11
  from . import slixfix # noqa: F401
11
12
  from .command import FormField, SearchResult # noqa: F401
@@ -37,8 +38,15 @@ def formatwarning(message, category, filename, lineno, line=""):
37
38
 
38
39
  warnings.formatwarning = formatwarning
39
40
 
41
+ try:
42
+ __version__ = version("slidge")
43
+ except PackageNotFoundError:
44
+ # package is not installed
45
+ __version__ = "dev"
46
+
40
47
 
41
48
  __all__ = [
49
+ "__version__",
42
50
  "BaseGateway",
43
51
  "BaseSession",
44
52
  # For backwards compatibility, these names are still importable from the
slidge/command/admin.py CHANGED
@@ -60,8 +60,6 @@ class SlidgeInfo(AdminCommand):
60
60
  ACCESS = CommandAccess.ANY
61
61
 
62
62
  async def run(self, _session, _ifrom, *_):
63
- from slidge.__version__ import __version__
64
-
65
63
  start = self.xmpp.datetime_started # type:ignore
66
64
  uptime = datetime.now() - start
67
65
 
@@ -100,8 +98,10 @@ class SlidgeInfo(AdminCommand):
100
98
  legacy_module = importlib.import_module(config.LEGACY_MODULE)
101
99
  version = getattr(legacy_module, "__version__", "No version")
102
100
 
101
+ import slidge
102
+
103
103
  return (
104
- f"{self.xmpp.COMPONENT_NAME} (slidge core {__version__},"
104
+ f"{self.xmpp.COMPONENT_NAME} (slidge core {slidge.__version__},"
105
105
  f" {config.LEGACY_MODULE} {version})\n"
106
106
  f"Up since {start:%Y-%m-%d %H:%M} ({ago} ago)"
107
107
  )
slidge/contact/contact.py CHANGED
@@ -218,7 +218,7 @@ class LegacyContact(
218
218
  self.log.name = f"{self.user_jid.bare}:contact:{self}"
219
219
 
220
220
  def __repr__(self):
221
- return f"<Contact #{self.contact_pk} '{self.name}' ({self.legacy_id} - {self.jid.local})'>"
221
+ return f"<Contact #{self.contact_pk} '{self.name}' ({self.legacy_id} - {self.jid.user})'>"
222
222
 
223
223
  def __ensure_pk(self):
224
224
  if self.contact_pk is not None:
@@ -617,7 +617,7 @@ class LegacyContact(
617
617
  contact = cls(
618
618
  session,
619
619
  cls.xmpp.LEGACY_CONTACT_ID_TYPE(stored.legacy_id),
620
- stored.jid.username, # type: ignore
620
+ stored.jid.user, # type: ignore
621
621
  *args, # type: ignore
622
622
  **kwargs, # type: ignore
623
623
  )
slidge/contact/roster.py CHANGED
@@ -5,12 +5,12 @@ from typing import TYPE_CHECKING, AsyncIterator, Generic, Iterator, Optional, Ty
5
5
 
6
6
  from slixmpp import JID
7
7
  from slixmpp.exceptions import IqError, IqTimeout, XMPPError
8
- from slixmpp.jid import JID_UNESCAPE_TRANSFORMATIONS, _unescape_node
9
8
 
10
9
  from ..core.mixins.lock import NamedLockMixin
11
10
  from ..db.models import Contact
12
11
  from ..db.store import ContactStore
13
12
  from ..util import SubclassableOnce
13
+ from ..util.jid_escaping import ESCAPE_TABLE, unescape_node
14
14
  from ..util.types import LegacyContactType, LegacyUserIdType
15
15
  from .contact import LegacyContact
16
16
 
@@ -198,7 +198,7 @@ class LegacyRoster(
198
198
  :param jid_username: User part of a JID, ie "user" in "user@example.com"
199
199
  :return: An identifier for the user on the legacy network.
200
200
  """
201
- return _unescape_node(jid_username)
201
+ return unescape_node(jid_username)
202
202
 
203
203
  async def _fill(self):
204
204
  try:
@@ -259,5 +259,4 @@ class LegacyRoster(
259
259
  yield
260
260
 
261
261
 
262
- ESCAPE_TABLE = "".maketrans({v: k for k, v in JID_UNESCAPE_TRANSFORMATIONS.items()})
263
262
  log = logging.getLogger(__name__)
@@ -52,7 +52,6 @@ class SessionDispatcher(
52
52
  if session.user.avatar_hash == hash_:
53
53
  session.log.debug("We already know this avatar hash")
54
54
  return
55
- self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
56
55
 
57
56
  if hash_:
58
57
  try:
@@ -67,6 +66,7 @@ class SessionDispatcher(
67
66
  height = info["height"]
68
67
  width = info["width"]
69
68
  else:
69
+ self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
70
70
  bytes_ = type_ = height = width = hash_ = None
71
71
  try:
72
72
  await session.on_avatar(bytes_, hash_, type_, width, height)
@@ -79,6 +79,11 @@ class SessionDispatcher(
79
79
  session.send_gateway_message(
80
80
  f"Something went wrong trying to set your avatar: {e!r}"
81
81
  )
82
+ else:
83
+ self.xmpp.store.users.set_avatar_hash(session.user_pk, hash_)
84
+ for room in session.bookmarks:
85
+ participant = await room.get_user_participant()
86
+ participant.send_last_presence(force=True, no_cache_online=True)
82
87
 
83
88
 
84
89
  log = logging.getLogger(__name__)
slidge/core/gateway.py CHANGED
@@ -526,6 +526,7 @@ class BaseGateway(
526
526
  "You are not connected to this gateway! "
527
527
  f"Maybe this message will tell you why: {e}"
528
528
  )
529
+ session.logged = False
529
530
  return
530
531
 
531
532
  log.info("Login success for %s", session.user_jid)
@@ -559,8 +560,18 @@ class BaseGateway(
559
560
  self.xmpp.plugin["xep_0084"].stanza.MetaData.namespace,
560
561
  ifrom=self.boundjid.bare,
561
562
  )
562
- except (IqError, IqTimeout):
563
- self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
563
+ except IqTimeout:
564
+ self.log.warning("Iq timeout trying to fetch user avatar")
565
+ return
566
+ except IqError as e:
567
+ self.log.debug("Iq error when trying to fetch user avatar: %s", e)
568
+ if e.condition == "item-not-found":
569
+ try:
570
+ await session.on_avatar(None, None, None, None, None)
571
+ except NotImplementedError:
572
+ pass
573
+ else:
574
+ self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
564
575
  return
565
576
  await self.__dispatcher.on_avatar_metadata_info(
566
577
  session, iq["pubsub"]["items"]["item"]["avatar_metadata"]["info"]
@@ -4,7 +4,7 @@ from datetime import datetime, timezone
4
4
  from typing import TYPE_CHECKING, Iterable, Optional, cast
5
5
  from uuid import uuid4
6
6
 
7
- from slixmpp import Message
7
+ from slixmpp import JID, Message
8
8
  from slixmpp.types import MessageTypes
9
9
 
10
10
  from ...db.models import GatewayUser
@@ -120,14 +120,14 @@ class MessageMaker(BaseSender):
120
120
  DeprecationWarning,
121
121
  )
122
122
  if muc:
123
- jid = copy(muc.jid)
123
+ jid = JID(muc.jid)
124
124
  jid.resource = fallback_nick = muc.user_nick
125
125
  msg["reply"]["to"] = jid
126
126
  else:
127
127
  msg["reply"]["to"] = self.session.user_jid
128
128
  # TODO: here we should use preferably use the PEP nick of the user
129
129
  # (but it doesn't matter much)
130
- fallback_nick = self.session.user_jid.local
130
+ fallback_nick = self.session.user_jid.user
131
131
  else:
132
132
  if muc:
133
133
  if hasattr(entity, "muc"):
slidge/core/session.py CHANGED
@@ -543,10 +543,10 @@ class BaseSession(
543
543
  return f"<Session of {self.user_jid}>"
544
544
 
545
545
  def shutdown(self, logout=True) -> asyncio.Task:
546
- for c in self.contacts:
547
- c.offline()
548
546
  for m in self.bookmarks:
549
547
  m.shutdown()
548
+ for c in self.contacts:
549
+ c.offline()
550
550
  if logout:
551
551
  return self.xmpp.loop.create_task(self.logout())
552
552
  else:
slidge/db/store.py CHANGED
@@ -443,6 +443,7 @@ class ContactStore(UpdatedMixin):
443
443
  break
444
444
  for row_id in to_del:
445
445
  session.execute(delete(ContactSent).where(ContactSent.id == row_id))
446
+ session.commit()
446
447
  return result
447
448
 
448
449
  def set_friend(self, contact_pk: int, is_friend: bool) -> None:
@@ -751,6 +752,8 @@ class MultiStore(EngineMixin):
751
752
  ).scalar()
752
753
  if multi is None:
753
754
  return None
755
+ if multi.legacy_ids_multi is None:
756
+ return None
754
757
  return multi.legacy_ids_multi.legacy_id
755
758
 
756
759
 
slidge/group/archive.py CHANGED
@@ -150,19 +150,27 @@ def archivable(msg: Message):
150
150
  :return:
151
151
  """
152
152
 
153
- if msg.get_plugin("hint", check=True) and msg["hint"] == "no-store":
153
+ if msg.get_plugin("no-store", check=True):
154
154
  return False
155
155
 
156
+ if msg.get_plugin("no-permanent-store", check=True):
157
+ return False
158
+
159
+ if msg.get_plugin("store", check=True):
160
+ return True
161
+
156
162
  if msg["body"]:
157
163
  return True
158
164
 
159
- if msg.get_plugin("apply_to", check=True):
160
- # retractions
165
+ if msg.get_plugin("retract", check=True):
161
166
  return True
162
167
 
163
168
  if msg.get_plugin("reactions", check=True):
164
169
  return True
165
170
 
171
+ if msg.get_plugin("displayed", check=True):
172
+ return True
173
+
166
174
  return False
167
175
 
168
176
 
slidge/group/bookmarks.py CHANGED
@@ -4,12 +4,11 @@ from typing import TYPE_CHECKING, Generic, Iterator, Optional, Type
4
4
 
5
5
  from slixmpp import JID
6
6
  from slixmpp.exceptions import XMPPError
7
- from slixmpp.jid import _unescape_node
8
7
 
9
- from ..contact.roster import ESCAPE_TABLE
10
8
  from ..core.mixins.lock import NamedLockMixin
11
9
  from ..db.models import Room
12
10
  from ..util import SubclassableOnce
11
+ from ..util.jid_escaping import ESCAPE_TABLE, unescape_node
13
12
  from ..util.types import LegacyGroupIdType, LegacyMUCType
14
13
  from .archive import MessageArchive
15
14
  from .room import LegacyMUC
@@ -83,14 +82,14 @@ class LegacyBookmarks(
83
82
  :param username:
84
83
  :return:
85
84
  """
86
- return _unescape_node(username)
85
+ return unescape_node(username)
87
86
 
88
87
  async def by_jid(self, jid: JID) -> LegacyMUCType:
89
88
  if jid.resource:
90
89
  jid = JID(jid.bare)
91
90
  async with self.lock(("bare", jid.bare)):
92
- assert isinstance(jid.local, str)
93
- legacy_id = await self.jid_local_part_to_legacy_id(jid.local)
91
+ assert isinstance(jid.user, str)
92
+ legacy_id = await self.jid_local_part_to_legacy_id(jid.user)
94
93
  if self.get_lock(("legacy_id", legacy_id)):
95
94
  self.log.debug("Not instantiating %s after all", jid)
96
95
  return await self.by_legacy_id(legacy_id)
@@ -1,6 +1,5 @@
1
1
  import logging
2
2
  import string
3
- import stringprep
4
3
  import uuid
5
4
  import warnings
6
5
  from copy import copy
@@ -10,9 +9,7 @@ from typing import TYPE_CHECKING, Optional, Self, Union
10
9
 
11
10
  from slixmpp import JID, InvalidJID, Message, Presence
12
11
  from slixmpp.plugins.xep_0045.stanza import MUCAdminItem
13
- from slixmpp.stringprep import StringprepError, resourceprep
14
12
  from slixmpp.types import MessageTypes, OptJid
15
- from slixmpp.util.stringprep_profiles import StringPrepError, prohibit_output
16
13
 
17
14
  from ..contact import LegacyContact
18
15
  from ..core.mixins import (
@@ -175,39 +172,22 @@ class LegacyParticipant(
175
172
  self.send_last_presence(force=True, no_cache_online=True)
176
173
 
177
174
  def __update_jid(self, unescaped_nickname: Optional[str]):
178
- j: JID = copy(self.muc.jid)
179
-
180
- if self.is_system:
181
- self.jid = j
182
- self._nickname_no_illegal = ""
175
+ if not unescaped_nickname:
176
+ self.jid = JID(self.muc.jid)
177
+ if self.is_system:
178
+ self._nickname_no_illegal = ""
179
+ else:
180
+ warnings.warn(
181
+ "Only the system participant is allowed to not have a nickname"
182
+ )
183
+ nickname = f"unnamed-{uuid.uuid4()}"
184
+ self.jid.resource = self._nickname_no_illegal = nickname
183
185
  return
184
186
 
185
- nickname = unescaped_nickname
186
-
187
- if nickname:
188
- nickname = self._nickname_no_illegal = strip_illegal_chars(nickname)
189
- else:
190
- warnings.warn(
191
- "Only the system participant is allowed to not have a nickname"
192
- )
193
- nickname = f"unnamed-{uuid.uuid4()}"
194
-
195
- assert isinstance(nickname, str)
196
-
197
- try:
198
- # workaround for https://codeberg.org/poezio/slixmpp/issues/3480
199
- prohibit_output(nickname, [stringprep.in_table_a1])
200
- resourceprep(nickname)
201
- except (StringPrepError, StringprepError):
202
- nickname = nickname.encode("punycode").decode()
203
-
204
- # at this point there still might be control chars
205
- try:
206
- j.resource = nickname
207
- except InvalidJID:
208
- j.resource = strip_non_printable(nickname)
209
-
210
- self.jid = j
187
+ self._nickname_no_illegal, self.jid = escape_nickname(
188
+ self.muc.jid,
189
+ unescaped_nickname,
190
+ )
211
191
 
212
192
  def send_configuration_change(self, codes: tuple[int]):
213
193
  if not self.is_system:
@@ -270,7 +250,7 @@ class LegacyParticipant(
270
250
  if user_full_jid:
271
251
  p["muc"]["jid"] = user_full_jid
272
252
  else:
273
- jid = copy(self.user_jid)
253
+ jid = JID(self.user_jid)
274
254
  try:
275
255
  jid.resource = next(
276
256
  iter(self.muc.get_user_resources()) # type:ignore
@@ -539,4 +519,22 @@ class LegacyParticipant(
539
519
  return part
540
520
 
541
521
 
522
+ def escape_nickname(muc_jid: JID, nickname: str) -> tuple[str, JID]:
523
+ nickname = nickname_no_illegal = strip_illegal_chars(nickname)
524
+
525
+ jid = JID(muc_jid)
526
+
527
+ try:
528
+ jid.resource = nickname
529
+ except InvalidJID:
530
+ nickname = nickname.encode("punycode").decode()
531
+ try:
532
+ jid.resource = nickname
533
+ except InvalidJID:
534
+ # at this point there still might be control chars
535
+ jid.resource = strip_non_printable(nickname)
536
+
537
+ return nickname_no_illegal, jid
538
+
539
+
542
540
  log = logging.getLogger(__name__)
slidge/group/room.py CHANGED
@@ -10,11 +10,12 @@ from uuid import uuid4
10
10
 
11
11
  from slixmpp import JID, Iq, Message, Presence
12
12
  from slixmpp.exceptions import IqError, IqTimeout, XMPPError
13
- from slixmpp.jid import _unescape_node
14
13
  from slixmpp.plugins.xep_0004 import Form
15
14
  from slixmpp.plugins.xep_0060.stanza import Item
16
15
  from slixmpp.plugins.xep_0082 import parse as str_to_datetime
17
16
  from slixmpp.plugins.xep_0469.stanza import NS as PINNING_NS
17
+ from slixmpp.plugins.xep_0492.stanza import NS as NOTIFY_NS
18
+ from slixmpp.plugins.xep_0492.stanza import WhenLiteral
18
19
  from slixmpp.xmlstream import ET
19
20
 
20
21
  from ..contact.contact import LegacyContact
@@ -27,9 +28,8 @@ from ..core.mixins.disco import ChatterDiscoMixin
27
28
  from ..core.mixins.lock import NamedLockMixin
28
29
  from ..core.mixins.recipient import ReactionRecipientMixin, ThreadRecipientMixin
29
30
  from ..db.models import Room
30
- from ..slixfix.xep_0492.stanza import NS as NOTIFY_NS
31
- from ..slixfix.xep_0492.stanza import WhenLiteral
32
31
  from ..util import ABCSubclassableOnceAtMost
32
+ from ..util.jid_escaping import unescape_node
33
33
  from ..util.types import (
34
34
  HoleBound,
35
35
  LegacyGroupIdType,
@@ -42,7 +42,7 @@ from ..util.types import (
42
42
  )
43
43
  from ..util.util import deprecated, timeit, with_session
44
44
  from .archive import MessageArchive
45
- from .participant import LegacyParticipant
45
+ from .participant import LegacyParticipant, escape_nickname
46
46
 
47
47
  if TYPE_CHECKING:
48
48
  from ..core.gateway import BaseGateway
@@ -184,7 +184,7 @@ class LegacyMUC(
184
184
  self.log = logging.getLogger(f"{self.user_jid}:muc:{self}")
185
185
 
186
186
  def __repr__(self):
187
- return f"<MUC #{self.pk} '{self.name}' ({self.legacy_id} - {self.jid.local})'>"
187
+ return f"<MUC #{self.pk} '{self.name}' ({self.legacy_id} - {self.jid.user})'>"
188
188
 
189
189
  @property
190
190
  def subject_date(self) -> Optional[datetime]:
@@ -515,8 +515,7 @@ class LegacyMUC(
515
515
  return r
516
516
 
517
517
  def shutdown(self):
518
- user_jid = copy(self.jid)
519
- user_jid.resource = self.user_nick
518
+ _, user_jid = escape_nickname(self.jid, self.user_nick)
520
519
  for user_full_jid in self.user_full_jids():
521
520
  presence = self.xmpp.make_presence(
522
521
  pfrom=user_jid, pto=user_full_jid, ptype="unavailable"
@@ -528,14 +527,13 @@ class LegacyMUC(
528
527
 
529
528
  def user_full_jids(self):
530
529
  for r in self._user_resources:
531
- j = copy(self.user_jid)
530
+ j = JID(self.user_jid)
532
531
  j.resource = r
533
532
  yield j
534
533
 
535
534
  @property
536
535
  def user_muc_jid(self):
537
- user_muc_jid = copy(self.jid)
538
- user_muc_jid.resource = self.user_nick
536
+ _, user_muc_jid = escape_nickname(self.jid, self.user_nick)
539
537
  return user_muc_jid
540
538
 
541
539
  def _legacy_to_xmpp(self, legacy_id: LegacyMessageType):
@@ -782,7 +780,7 @@ class LegacyMUC(
782
780
  self.session, stored, muc=self, contact=c
783
781
  )
784
782
 
785
- nickname = c.name or _unescape_node(c.jid_username)
783
+ nickname = c.name or unescape_node(c.jid_username)
786
784
 
787
785
  if self.pk is None:
788
786
  nick_available = True
@@ -990,7 +988,7 @@ class LegacyMUC(
990
988
 
991
989
  :param r: The resource to kick
992
990
  """
993
- pto = self.user_jid
991
+ pto = JID(self.user_jid)
994
992
  pto.resource = r
995
993
  p = self.xmpp.make_presence(
996
994
  pfrom=(await self.get_user_participant()).jid, pto=pto
@@ -1018,8 +1016,11 @@ class LegacyMUC(
1018
1016
  item = ans["pubsub"]["items"]["item"]
1019
1017
  item["id"] = self.jid
1020
1018
  return item
1021
- except (IqError, IqTimeout) as exc:
1022
- warnings.warn(f"Cannot fetch bookmark: {exc}")
1019
+ except IqTimeout as exc:
1020
+ warnings.warn(f"Cannot fetch bookmark for {self.user_jid}: timeout")
1021
+ return None
1022
+ except IqError as exc:
1023
+ warnings.warn(f"Cannot fetch bookmark for {self.user_jid}: {exc}")
1023
1024
  return None
1024
1025
  except PermissionError:
1025
1026
  warnings.warn(
slidge/main.py CHANGED
@@ -24,8 +24,8 @@ from pathlib import Path
24
24
 
25
25
  import configargparse
26
26
 
27
+ import slidge
27
28
  from slidge import BaseGateway
28
- from slidge.__version__ import __version__
29
29
  from slidge.core import config
30
30
  from slidge.core.pubsub import PepAvatar, PepNick
31
31
  from slidge.db import SlidgeStore
@@ -96,7 +96,7 @@ def get_configurator():
96
96
  p.add_argument(
97
97
  "--version",
98
98
  action="version",
99
- version=f"%(prog)s {__version__}",
99
+ version=f"%(prog)s {slidge.__version__}",
100
100
  )
101
101
  configurator = MainConfig(config, p)
102
102
  return configurator
@@ -128,7 +128,7 @@ def main():
128
128
  signal.signal(signal.SIGTERM, handle_sigterm)
129
129
 
130
130
  unknown_argv = configure()
131
- logging.info("Starting slidge version %s", __version__)
131
+ logging.info("Starting slidge version %s", slidge.__version__)
132
132
 
133
133
  legacy_module = importlib.import_module(config.LEGACY_MODULE)
134
134
  logging.debug("Legacy module: %s", dir(legacy_module))
@@ -3,13 +3,12 @@
3
3
 
4
4
  # ruff: noqa: F401
5
5
 
6
+ import logging
7
+
6
8
  import slixmpp.plugins
7
- from slixmpp import Iq, Message
8
- from slixmpp.exceptions import _DEFAULT_ERROR_TYPES, XMPPError
9
- from slixmpp.plugins.xep_0004.stanza.field import FormField
9
+ import slixmpp.stanza.roster
10
+ from slixmpp import InvalidJID, Message
10
11
  from slixmpp.plugins.xep_0050 import XEP_0050, Command
11
- from slixmpp.plugins.xep_0231 import XEP_0231
12
- from slixmpp.plugins.xep_0425.stanza import Moderate
13
12
  from slixmpp.plugins.xep_0469.stanza import NS as PINNED_NS
14
13
  from slixmpp.plugins.xep_0469.stanza import Pinned
15
14
  from slixmpp.xmlstream import StanzaBase
@@ -20,38 +19,25 @@ from . import (
20
19
  xep_0100,
21
20
  xep_0153,
22
21
  xep_0292,
23
- xep_0492,
24
22
  )
25
23
 
26
- # TODO: remove this when the fix is included in slixmpp
27
- Moderate.interfaces.add("id")
28
-
29
- _DEFAULT_ERROR_TYPES["policy-violation"] = "modify" # type:ignore
30
-
31
24
 
32
- async def _handle_bob_iq(self, iq: Iq):
33
- cid = iq["bob"]["cid"]
25
+ # TODO: remove this when we pin slixmpp > 1.9.0
26
+ def get_items(self):
27
+ items = {}
28
+ for item in self["substanzas"]:
29
+ if isinstance(item, slixmpp.stanza.roster.RosterItem):
30
+ try:
31
+ items[item["jid"]] = item.values
32
+ except InvalidJID:
33
+ logging.warning("Invalid JID in roster: %s", item)
34
+ continue
35
+ del items[item["jid"]]["jid"]
36
+ del items[item["jid"]]["lang"]
37
+ return items
34
38
 
35
- if iq["type"] == "result":
36
- await self.api["set_bob"](iq["from"], None, iq["to"], args=iq["bob"])
37
- self.xmpp.event("bob", iq)
38
- elif iq["type"] == "get":
39
- data = await self.api["get_bob"](iq["to"], None, iq["from"], args=cid)
40
39
 
41
- if data is None:
42
- raise XMPPError(
43
- "item-not-found",
44
- f"Bits of binary '{cid}' is not available.",
45
- )
46
-
47
- if isinstance(data, Iq):
48
- data["id"] = iq["id"]
49
- data.send()
50
- return
51
-
52
- iq = iq.reply()
53
- iq.append(data)
54
- iq.send()
40
+ slixmpp.stanza.roster.Roster.get_items = get_items # type:ignore
55
41
 
56
42
 
57
43
  def set_pinned(self, val: bool):
@@ -65,9 +51,6 @@ def set_pinned(self, val: bool):
65
51
  Pinned.set_pinned = set_pinned
66
52
 
67
53
 
68
- XEP_0231._handle_bob_iq = _handle_bob_iq
69
-
70
-
71
54
  def session_bind(self, jid):
72
55
  self.xmpp["xep_0030"].add_feature(Command.namespace)
73
56
  # awful hack to for the disco items: we need to comment this line
@@ -101,52 +84,9 @@ def reply(self, body=None, clear=True):
101
84
  Message.reply = reply # type: ignore
102
85
 
103
86
 
104
- FormField.set_value_base = FormField.set_value # type:ignore
105
-
106
-
107
- def set_value(self: FormField, value):
108
- if not self._type:
109
- if isinstance(value, bool):
110
- self._type = "boolean"
111
- elif isinstance(value, str):
112
- self._type = "text-single"
113
- elif isinstance(value, (list, tuple)):
114
- self._type = "text-multi"
115
-
116
- FormField.set_value_base(self, value)
117
-
118
-
119
- def get_value(self, convert=True, convert_list=False):
120
- valsXML = self.xml.findall("{%s}value" % self.namespace)
121
- if len(valsXML) == 0:
122
- return None
123
- elif self._type == "boolean":
124
- if convert:
125
- return valsXML[0].text in self.true_values
126
- return valsXML[0].text
127
- elif self._type in self.multi_value_types or len(valsXML) > 1:
128
- values = []
129
- for valXML in valsXML:
130
- if valXML.text is None:
131
- valXML.text = ""
132
- values.append(valXML.text)
133
- if self._type == "text-multi" and convert_list:
134
- values = "\n".join(values)
135
- return values
136
- else:
137
- if valsXML[0].text is None:
138
- return ""
139
- return valsXML[0].text
140
-
141
-
142
- FormField.set_value = set_value # type:ignore
143
- FormField.get_value = get_value # type:ignore
144
-
145
-
146
87
  slixmpp.plugins.PLUGINS.extend(
147
88
  [
148
89
  "link_preview",
149
90
  "xep_0292_provider",
150
- "xep_0492",
151
91
  ]
152
92
  )