slidge 0.2.7__py3-none-any.whl → 0.2.8__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/__version__.py CHANGED
@@ -2,4 +2,4 @@ from slidge.util.util import get_version # noqa: F401
2
2
 
3
3
  # this is modified before publish, but if someone cloned from the repo,
4
4
  # it can help
5
- __version__ = "v0.2.7"
5
+ __version__ = "v0.2.8"
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
@@ -559,8 +559,18 @@ class BaseGateway(
559
559
  self.xmpp.plugin["xep_0084"].stanza.MetaData.namespace,
560
560
  ifrom=self.boundjid.bare,
561
561
  )
562
- except (IqError, IqTimeout):
563
- self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
562
+ except IqTimeout:
563
+ self.log.warning("Iq timeout trying to fetch user avatar")
564
+ return
565
+ except IqError as e:
566
+ self.log.debug("Iq error when trying to fetch user avatar: %s", e)
567
+ if e.condition == "item-not-found":
568
+ try:
569
+ await session.on_avatar(None, None, None, None, None)
570
+ except NotImplementedError:
571
+ pass
572
+ else:
573
+ self.xmpp.store.users.set_avatar_hash(session.user_pk, None)
564
574
  return
565
575
  await self.__dispatcher.on_avatar_metadata_info(
566
576
  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/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
@@ -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
  )
@@ -0,0 +1,52 @@
1
+ from functools import lru_cache
2
+
3
+ JID_ESCAPE_SEQUENCES = {
4
+ "\\20",
5
+ "\\22",
6
+ "\\26",
7
+ "\\27",
8
+ "\\2f",
9
+ "\\3a",
10
+ "\\3c",
11
+ "\\3e",
12
+ "\\40",
13
+ "\\5c",
14
+ }
15
+
16
+
17
+ JID_UNESCAPE_TRANSFORMATIONS = {
18
+ "\\20": " ",
19
+ "\\22": '"',
20
+ "\\26": "&",
21
+ "\\27": "'",
22
+ "\\2f": "/",
23
+ "\\3a": ":",
24
+ "\\3c": "<",
25
+ "\\3e": ">",
26
+ "\\40": "@",
27
+ "\\5c": "\\",
28
+ }
29
+
30
+
31
+ @lru_cache(1000)
32
+ def unescape_node(node: str):
33
+ """Unescape a local portion of a JID."""
34
+ unescaped = []
35
+ seq = ""
36
+ for i, char in enumerate(node):
37
+ if char == "\\":
38
+ seq = node[i : i + 3]
39
+ if seq not in JID_ESCAPE_SEQUENCES:
40
+ seq = ""
41
+ if seq:
42
+ if len(seq) == 3:
43
+ unescaped.append(JID_UNESCAPE_TRANSFORMATIONS.get(seq, char))
44
+
45
+ # Pop character off the escape sequence, and ignore it
46
+ seq = seq[1:]
47
+ else:
48
+ unescaped.append(char)
49
+ return "".join(unescaped)
50
+
51
+
52
+ ESCAPE_TABLE = "".maketrans({v: k for k, v in JID_UNESCAPE_TRANSFORMATIONS.items()})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: slidge
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: XMPP bridging framework
5
5
  Author-email: Nicolas Cedilnik <nicoco@nicoco.fr>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -683,7 +683,7 @@ Requires-Dist: defusedxml>=0.7.1
683
683
  Requires-Dist: pillow<12,>=11.0.0
684
684
  Requires-Dist: python-magic<0.5,>=0.4.27
685
685
  Requires-Dist: qrcode<9,>=8.0
686
- Requires-Dist: slixmpp<2,>=1.8.6
686
+ Requires-Dist: slixmpp<2,>=1.9.0
687
687
  Requires-Dist: sqlalchemy<3,>=2
688
688
  Requires-Dist: thumbhash>=0.1.2
689
689
 
@@ -1,6 +1,6 @@
1
1
  slidge/__init__.py,sha256=S0tUjqpZlzsr8G4Y_1Xt-KCYB07qaknTB0OwHU8k29U,1587
2
2
  slidge/__main__.py,sha256=ydjUklOoavS4YlGfjRX_8BQN2DaSbaXPMi47RkOgcFI,37
3
- slidge/__version__.py,sha256=4G6eK4xrrezi8g1TxDqa6IID1uzOe-SonV8sT5-MrUs,165
3
+ slidge/__version__.py,sha256=Zirtlo5Bp-7eCiwh-NWenCh2s-v0fenKkV8OFlv_O1Y,165
4
4
  slidge/main.py,sha256=vMJzhvUxbeuIXuHxXXs6lm_ShBjXiS9B5Li5Ge4vWPo,6238
5
5
  slidge/migration.py,sha256=4BJmPIRB56_WIhRTqBFIIBXuvnhhBjjOMl4CE7jY6oc,1541
6
6
  slidge/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -13,11 +13,11 @@ slidge/command/chat_command.py,sha256=z-4qp03rK7kCh3_kEozDViwkDg_hVjHvRCiYYJxedB
13
13
  slidge/command/register.py,sha256=BduDI31Kx8CbWWEdjybimTA5Wcfhn-Jkt8sSPsySCpo,6724
14
14
  slidge/command/user.py,sha256=fLh5d7XTSXicj6g0I80F5n6BFaA20PaYoXFkfDOR4zA,12303
15
15
  slidge/contact/__init__.py,sha256=WMMaHk7UW7YT9EH2LtPdkU0bHQaOp4ikBhbBQskmoc8,191
16
- slidge/contact/contact.py,sha256=ITcjW_3VMdVEHQfqxscpIULnofZBJ841wvnYwOvk1Tc,22934
17
- slidge/contact/roster.py,sha256=x3speGdHbZ-VTLoQLQW4s53rBeBvW87W8ZibCCZSLDA,10300
16
+ slidge/contact/contact.py,sha256=CLWuNLvWuODi1mlT6MFGx9s3y8yGPM8ZEsH-Ih6QEn8,22929
17
+ slidge/contact/roster.py,sha256=19EYyX-usuevMob9AgnQmSt6APdE5MxMroHOYmVYt-w,10205
18
18
  slidge/core/__init__.py,sha256=RG7Jj5JCJERjhqJ31lOLYV-7bH_oblClQD1KF9LsTXo,68
19
19
  slidge/core/config.py,sha256=OjJfpXJaDhMxRB-vYA0cqkSf0fwMt-HMThM8GS1htCg,7964
20
- slidge/core/gateway.py,sha256=qdvLGh5GF823mACVw5j1WLYMzsSmeGpmQFuWvz5Z9AU,37028
20
+ slidge/core/gateway.py,sha256=6qu3Ca5e3Kxtfm343zz43Iqjpw7cxZ1A7LC3bUdkDLo,37457
21
21
  slidge/core/pubsub.py,sha256=BoeYE__ptmRAn4x55Hn_6JWRA4nM-XJgDemG5Cy5kN4,11959
22
22
  slidge/core/session.py,sha256=Y6psOKm_lv4q7yXARiLuijvSebuS64NjqSNF1WARtHM,28439
23
23
  slidge/core/dispatcher/__init__.py,sha256=1EXcjXietUKlxEqdrCWCV3xZ3q_DSsjHoqWrPMbtYao,84
@@ -26,7 +26,7 @@ slidge/core/dispatcher/disco.py,sha256=j56VY9NIFzwPEWFKQQZ7YIqS9GdD-ZaF_K8a2L-Jv
26
26
  slidge/core/dispatcher/presence.py,sha256=X4i-JjQ423gXiveJH7sjdwW_67rJiSYS7jIvkm1XsJg,6421
27
27
  slidge/core/dispatcher/registration.py,sha256=Xmbw9NF3LUppCOa3XzreopdKDitZnwl_5HE-kds74n8,3155
28
28
  slidge/core/dispatcher/search.py,sha256=9cGj0wwvyYlP_Yk440Y12sgo4Y1p-JWUDSJP5Zxch0M,3296
29
- slidge/core/dispatcher/session_dispatcher.py,sha256=vNaOJpHKGTzIyQJX457IvhbooKFN5JR3HA7XW0AArFI,2868
29
+ slidge/core/dispatcher/session_dispatcher.py,sha256=Gzq2IPThhzQ0_mCVKPCNHypIXgL-WnZalTyLMjUX9Hs,3148
30
30
  slidge/core/dispatcher/util.py,sha256=YtXyVxM3orE7aYWs-GbJumtLTI63OpaQY_t4FMTjoZo,5754
31
31
  slidge/core/dispatcher/vcard.py,sha256=Rmx-wCz6Lps0mXCO48HppNQlS3GOgMuzuw9hZYBdlVU,5130
32
32
  slidge/core/dispatcher/message/__init__.py,sha256=vpDGOc_U9XvkUU_ws9n9-5M2NPJ87XGTVpuIxM7Z99k,223
@@ -47,7 +47,7 @@ slidge/core/mixins/db.py,sha256=5Qpegd7D8e5TLXLLINYcf_DuVdN-7wNmsfztUuFYPcU,442
47
47
  slidge/core/mixins/disco.py,sha256=jk3Z1B6zTuisHv8VKNRJodIo0ee5btYHh2ZrlflPj_Q,3670
48
48
  slidge/core/mixins/lock.py,sha256=Vf1rrkbyNbSprr38WGfZiMgTB7AdbqH8ppFHY8N2yXE,975
49
49
  slidge/core/mixins/message.py,sha256=X8Ka8j0nOnBcecYE_YuK8_J7MeO5-R0TIZw4X8c7R3Y,7846
50
- slidge/core/mixins/message_maker.py,sha256=TcCutHi0sIwL6beJNkN7XyR0aDIbA0xZyxd2Gc9ulG4,6022
50
+ slidge/core/mixins/message_maker.py,sha256=_sa0YWyxnvI0DcPgoh6h1CxLbYF73Ezw1LRZN2CNRTM,6025
51
51
  slidge/core/mixins/message_text.py,sha256=pCY4tezEuwB2ZuUyUi72i4v9AJkxp_SWF1jrFsn94Ns,8096
52
52
  slidge/core/mixins/presence.py,sha256=yywo6KAw8C7GaZSMrSMuioNfhW08MrnobHt8XbHd0q8,7891
53
53
  slidge/core/mixins/recipient.py,sha256=b0uFnpym-hOFgYxGjXT1xQcZ4YRbDSBftPcNWLzSwEI,1336
@@ -55,7 +55,7 @@ slidge/db/__init__.py,sha256=EBDH1JSEhgqYcli2Bw11CRC749wJk8AOucgBzmhDSvU,105
55
55
  slidge/db/avatar.py,sha256=z5e72STv8PdN6zkNyKlLqF7NFxHwCa6IjwgFpzu5ghE,8033
56
56
  slidge/db/meta.py,sha256=v1Jf-npZ28QwdGpsLQWLBHEbEP3-jnPrygRg05tJ_Iw,1831
57
57
  slidge/db/models.py,sha256=MSVNW04x05qfxahvjCYRDFjfFP-XXp-lOHnK5IqFCXw,14046
58
- slidge/db/store.py,sha256=ETk6oUUEz8-YUFGCh7nspSJH7dFOj8qeIWLQhX4nOH8,47051
58
+ slidge/db/store.py,sha256=AjbeYAbhd_7KHS094vTEPiuecu_ntIAlpyzsrCIjHHE,47155
59
59
  slidge/db/alembic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  slidge/db/alembic/env.py,sha256=hsBlRNs0zF5diSHGRSa8Fi3qRVQDA2rJdR41AEIdvxc,1642
61
61
  slidge/db/alembic/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
@@ -78,11 +78,11 @@ slidge/db/alembic/versions/b64b1a793483_add_source_and_legacy_id_for_archived_.p
78
78
  slidge/db/alembic/versions/c4a8ec35a0e8_per_room_user_nick.py,sha256=jjQmlRv6nqdm5q6LbwVpSUSkTBj1c76Hiq8e8q77q3g,933
79
79
  slidge/db/alembic/versions/e91195719c2c_store_users_avatars_persistently.py,sha256=8Ga3VFgKrzMs_-B8OPtfP-0rey_MFaDg-QGtSbaft3o,640
80
80
  slidge/group/__init__.py,sha256=yFt7cHqeaKIMN6f9ZyhhspOcJJvBtLedGv-iICG7lto,258
81
- slidge/group/archive.py,sha256=IPqklzo0UN3lPHckfsKW9c4nl3m_9XGY4u0eehrhe8k,5281
82
- slidge/group/bookmarks.py,sha256=AvFL34bEX6n3OP1Np309T5hrLK9GnjkjdyLJ3uiLZyc,6616
83
- slidge/group/participant.py,sha256=cUuyJRGq8AIHrwtubje5cyb5hHY2hGLtGboBju4SI0c,17781
84
- slidge/group/room.py,sha256=IilOT_Z5P-gh0lo5KLFc054z6sOrxJQ6MvjPmLKXiRs,49011
85
- slidge/slixfix/__init__.py,sha256=Og6_EAuWst6paWmDiGqeqQH6Iof6V8Vkr5pyYisgjsw,4282
81
+ slidge/group/archive.py,sha256=AUzVtXlHiCreyY3jp1XMt0G7LDNm-qOU-4CEPQ89ics,5445
82
+ slidge/group/bookmarks.py,sha256=uGw_XtF0nloZ7rhNLdKM0nNZZb5C6SBfTsLyZryxjxY,6592
83
+ slidge/group/participant.py,sha256=h9Cz4liCWzCaysvDk4wr8-zHvLOyIoM3vvQWzHCdpFE,17690
84
+ slidge/group/room.py,sha256=UlmgIwZDjCyxXtAjQGVHo1xZoU9lq2WR7blwC9BAriY,49019
85
+ slidge/slixfix/__init__.py,sha256=opamnCRI89KtCY2jfUrzij423hROgMF_Jw8Rrv1i0pw,2515
86
86
  slidge/slixfix/delivery_receipt.py,sha256=3bWdZH3-X3CZJXmnI_TpjkTUUK-EY4Ktm78lW0-40fc,1366
87
87
  slidge/slixfix/roster.py,sha256=KvDjh9q7pqaZf69H93okfib13cc95uVZUJ6rzpqmDaU,1704
88
88
  slidge/slixfix/link_preview/__init__.py,sha256=TDPTSEH5FQxgGpQpQIde-D72AHg-6YVWG-tOj4KpKmU,290
@@ -98,17 +98,15 @@ slidge/slixfix/xep_0153/__init__.py,sha256=hsEldnLuzvcp0NqSscxPV7FJl-6GFP372vlDg
98
98
  slidge/slixfix/xep_0153/vcard_avatar.py,sha256=py-qzj1jmmzsM4GCTKLRW7cAdAmSVjodp6q0r5B0RqQ,458
99
99
  slidge/slixfix/xep_0292/__init__.py,sha256=_MvS9wGra6ig3P_dPAVlCPDJkiOFvUWGjaRsHj1woUg,98
100
100
  slidge/slixfix/xep_0292/vcard4.py,sha256=jL-TOW3eG2QXLduSLNq03L8HoUNmvy8kTZI5ojvo6GE,358
101
- slidge/slixfix/xep_0492/__init__.py,sha256=kjWVeX3SG_2ohHx0fuMh1gmM2G57Bl6SRo7Mfv6sglA,161
102
- slidge/slixfix/xep_0492/notify.py,sha256=8EPSdU3rTzWkHNm8oFr0tK2PmMJ6hBAIr88GoOmHTuQ,340
103
- slidge/slixfix/xep_0492/stanza.py,sha256=TlwyAHozA6zu32QoBb6M12xqWR-ytT0F9XVFqZkd4d4,2895
104
101
  slidge/util/__init__.py,sha256=BELovoTMPcPPGz3D48esBr8A4BRRHXTvavfgnArBgEc,301
105
102
  slidge/util/archive_msg.py,sha256=xXAR0BI5r3d6KKWjae9594izCOv6iI03z2WLuTecNw8,1724
106
103
  slidge/util/conf.py,sha256=1j2OnOsCBar1tOObErhXR5RC3Vl3faliOZ1U8J3My58,6613
104
+ slidge/util/jid_escaping.py,sha256=pWJTrB6-M923a_rEE-nxPmiDTOx9UCMa8UgE7JbLC0c,1066
107
105
  slidge/util/test.py,sha256=l1VHBsw5Uzk2t7wtkfb9kWvtehcYhw1t_d567JAJFKA,14135
108
106
  slidge/util/types.py,sha256=R_xfS5mRL0XUJIoDpnaAkZlTOoLPerduXBFftaVwIAI,5489
109
107
  slidge/util/util.py,sha256=IfyYLkujW6Pk0kvHpfkpQwejFDHSe5oR4_bczEUnhjs,9678
110
- slidge-0.2.7.dist-info/METADATA,sha256=u5B3zAw9h1inyIcHrGvr23-GNtI7Ba4gHNXLRmTtktc,44841
111
- slidge-0.2.7.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
112
- slidge-0.2.7.dist-info/entry_points.txt,sha256=py3_x834fFJ2TEzPd18Wt2DnysdAfuVqJ5zzBrXbAZs,44
113
- slidge-0.2.7.dist-info/top_level.txt,sha256=2LRjDYHaGZ5ieCMF8xy58JIiabRMzX-MGMbCZwfE17c,7
114
- slidge-0.2.7.dist-info/RECORD,,
108
+ slidge-0.2.8.dist-info/METADATA,sha256=_Ugh-_g55rL-uqTZ16WU-Nfo--8JO74xfLfIh75twEg,44841
109
+ slidge-0.2.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
110
+ slidge-0.2.8.dist-info/entry_points.txt,sha256=py3_x834fFJ2TEzPd18Wt2DnysdAfuVqJ5zzBrXbAZs,44
111
+ slidge-0.2.8.dist-info/top_level.txt,sha256=2LRjDYHaGZ5ieCMF8xy58JIiabRMzX-MGMbCZwfE17c,7
112
+ slidge-0.2.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.1)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- from slixmpp.plugins.base import register_plugin
2
-
3
- from . import stanza
4
- from .notify import XEP_0492
5
-
6
- register_plugin(XEP_0492)
7
-
8
- __all__ = ["stanza", "XEP_0492"]
@@ -1,16 +0,0 @@
1
- from slixmpp.plugins import BasePlugin
2
- from . import stanza
3
-
4
-
5
- class XEP_0492(BasePlugin):
6
- """
7
- XEP-0492: Chat notification settings
8
- """
9
-
10
- name = "xep_0492"
11
- description = "XEP-0492: Chat notification settings"
12
- dependencies = {"xep_0402"}
13
- stanza = stanza
14
-
15
- def plugin_init(self):
16
- stanza.register_plugin()
@@ -1,107 +0,0 @@
1
- from typing import Literal, Optional, cast
2
-
3
- from slixmpp import register_stanza_plugin
4
- from slixmpp.plugins.xep_0402.stanza import Extensions
5
- from slixmpp.xmlstream import ElementBase
6
-
7
- from ...util.types import ClientType
8
-
9
- NS = "urn:xmpp:notification-settings:0"
10
-
11
- WhenLiteral = Literal["never", "always", "on-mention"]
12
-
13
-
14
- class Notify(ElementBase):
15
- """
16
- Chat notification settings element
17
-
18
-
19
- To enable it on a Conference element, use configure() like this:
20
-
21
- .. code-block::python
22
-
23
- # C being a Conference element
24
- C['extensions']["notify"].configure("always", client_type="pc")
25
-
26
- Which will add the <notify> element to the <extensions> element.
27
- """
28
-
29
- namespace = NS
30
- name = "notify"
31
- plugin_attrib = "notify"
32
- interfaces = {"notify"}
33
-
34
- def configure(self, when: WhenLiteral, client_type: Optional[ClientType] = None) -> None:
35
- """
36
- Configure the chat notification settings for this bookmark.
37
-
38
- This method ensures that there are no conflicting settings, e.g.,
39
- both a <never /> and a <always /> element.
40
- """
41
- cls = _CLASS_MAP[when]
42
- element = cls()
43
- if client_type is not None:
44
- element["client-type"] = client_type
45
-
46
- match = client_type if client_type is not None else ""
47
- for child in self:
48
- if isinstance(child, _Base) and child["client-type"] == match:
49
- self.xml.remove(child.xml)
50
-
51
- self.append(element)
52
-
53
- def get_config(
54
- self, client_type: Optional[ClientType] = None
55
- ) -> Optional[WhenLiteral]:
56
- """
57
- Get the chat notification settings for this bookmark.
58
-
59
- :param client_type: Optionally, get the notification for a specific client type.
60
- If unset, returns the global notification setting.
61
-
62
- :return: The chat notification setting as a string, or None if unset.
63
- """
64
- match = client_type if client_type is not None else ""
65
- for child in self:
66
- if isinstance(child, _Base) and child["client-type"] == match:
67
- return cast(WhenLiteral, child.name)
68
- return None
69
-
70
- class _Base(ElementBase):
71
- namespace = NS
72
- interfaces = {"client-type"}
73
-
74
-
75
- class Never(_Base):
76
- name = "never"
77
- plugin_attrib = name
78
-
79
-
80
- class Always(_Base):
81
- name = "always"
82
- plugin_attrib = name
83
-
84
-
85
- class OnMention(_Base):
86
- name = "on-mention"
87
- plugin_attrib = name
88
-
89
-
90
- class Advanced(ElementBase):
91
- namespace = NS
92
- name = plugin_attrib = "advanced"
93
-
94
-
95
- _CLASS_MAP = {
96
- "never": Never,
97
- "always": Always,
98
- "on-mention": OnMention,
99
- }
100
-
101
-
102
- def register_plugin():
103
- register_stanza_plugin(Extensions, Notify)
104
- register_stanza_plugin(Notify, Advanced)
105
- register_stanza_plugin(Notify, Never, iterable=True)
106
- register_stanza_plugin(Notify, Always, iterable=True)
107
- register_stanza_plugin(Notify, OnMention, iterable=True)