slidge 0.3.0b2__py3-none-any.whl → 0.3.0b3__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.
@@ -303,6 +303,10 @@ class AttachmentMixin(TextMessageMixin):
303
303
  )
304
304
  if attachment.name:
305
305
  sfs["file"]["name"] = attachment.name
306
+ if attachment.disposition:
307
+ sfs["disposition"] = attachment.disposition
308
+ else:
309
+ del sfs["disposition"]
306
310
  if thumbnail is not None:
307
311
  sfs["file"].append(thumbnail)
308
312
  stored.sfs = str(sfs)
@@ -19,7 +19,7 @@ class Base:
19
19
  xmpp: "BaseGateway" = NotImplemented
20
20
 
21
21
  jid: JID = NotImplemented
22
- name: str = NotImplemented
22
+ name: str | None = NotImplemented
23
23
 
24
24
  @property
25
25
  def user_jid(self):
@@ -13,7 +13,7 @@ class BaseDiscoMixin(Base):
13
13
  DISCO_NAME: str = NotImplemented
14
14
  DISCO_LANG = None
15
15
 
16
- def _get_disco_name(self):
16
+ def _get_disco_name(self) -> str | None:
17
17
  if self.DISCO_NAME is NotImplemented:
18
18
  return self.xmpp.COMPONENT_NAME
19
19
  return self.DISCO_NAME or self.xmpp.COMPONENT_NAME
slidge/db/store.py CHANGED
@@ -478,7 +478,7 @@ class ParticipantStore:
478
478
 
479
479
  @staticmethod
480
480
  def get_all(
481
- session, room_pk: int, user_included: bool = True
481
+ session: Session, room_pk: int, user_included: bool = True
482
482
  ) -> Iterator[Participant]:
483
483
  query = select(Participant).where(Participant.room_id == room_pk)
484
484
  if not user_included:
slidge/group/bookmarks.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import abc
2
2
  import logging
3
- from typing import TYPE_CHECKING, Generic, Iterator, Optional, Type
3
+ from typing import TYPE_CHECKING, Generic, Iterator, Literal, Optional, Type, overload
4
4
 
5
5
  from slixmpp import JID
6
6
  from slixmpp.exceptions import XMPPError
@@ -119,13 +119,31 @@ class LegacyBookmarks(
119
119
  return self.from_store(stored)
120
120
  return None
121
121
 
122
- async def by_legacy_id(self, legacy_id: LegacyGroupIdType) -> LegacyMUCType:
122
+ @overload
123
+ async def by_legacy_id(self, legacy_id: LegacyGroupIdType) -> "LegacyMUCType": ...
124
+
125
+ @overload
126
+ async def by_legacy_id(
127
+ self, legacy_id: LegacyGroupIdType, create: Literal[False]
128
+ ) -> "LegacyMUCType | None": ...
129
+
130
+ @overload
131
+ async def by_legacy_id(
132
+ self, legacy_id: LegacyGroupIdType, create: Literal[True]
133
+ ) -> "LegacyMUCType": ...
134
+
135
+ async def by_legacy_id(
136
+ self, legacy_id: LegacyGroupIdType, create: bool = False
137
+ ) -> LegacyMUCType | None:
123
138
  async with self.lock(("legacy_id", legacy_id)):
124
139
  local = await self.legacy_id_to_jid_local_part(legacy_id)
125
140
  jid = JID(f"{local}@{self.xmpp.boundjid}")
126
141
  if self.get_lock(("bare", jid.bare)):
127
142
  self.session.log.debug("Already updating %s via by_jid()", jid)
128
- return await self.by_jid(jid)
143
+ if create:
144
+ return await self.by_jid(jid)
145
+ else:
146
+ return self.by_jid_only_if_exists(jid)
129
147
 
130
148
  with self.xmpp.store.session() as orm:
131
149
  stored = (
slidge/group/room.py CHANGED
@@ -7,7 +7,16 @@ from asyncio import Lock
7
7
  from contextlib import asynccontextmanager
8
8
  from copy import copy
9
9
  from datetime import datetime, timedelta, timezone
10
- from typing import TYPE_CHECKING, AsyncIterator, Generic, Optional, Type, Union
10
+ from typing import (
11
+ TYPE_CHECKING,
12
+ AsyncIterator,
13
+ Generic,
14
+ Literal,
15
+ Optional,
16
+ Type,
17
+ Union,
18
+ overload,
19
+ )
11
20
  from uuid import uuid4
12
21
 
13
22
  import sqlalchemy as sa
@@ -325,16 +334,15 @@ class LegacyMUC(
325
334
  self.stored.history_filled = True
326
335
  self.commit(merge=True)
327
336
 
328
- @property
329
- def DISCO_NAME(self) -> str: # type:ignore
330
- return self.name or "unnamed-room"
337
+ def _get_disco_name(self) -> str | None:
338
+ return self.name
331
339
 
332
340
  @property
333
- def name(self) -> str:
334
- return self.stored.name or "unnamed-room"
341
+ def name(self) -> str | None:
342
+ return self.stored.name
335
343
 
336
344
  @name.setter
337
- def name(self, n: str) -> None:
345
+ def name(self, n: str | None) -> None:
338
346
  if self.name == n:
339
347
  return
340
348
  self.stored.name = n
@@ -673,7 +681,7 @@ class LegacyMUC(
673
681
  since=since,
674
682
  )
675
683
  self.__get_subject_setter_participant().set_room_subject(
676
- self.subject if self.HAS_SUBJECT else (self.description or self.name),
684
+ self.subject if self.HAS_SUBJECT else (self.description or self.name or ""),
677
685
  user_full_jid,
678
686
  self.subject_date,
679
687
  )
@@ -764,9 +772,24 @@ class LegacyMUC(
764
772
  """
765
773
  return self._participant_cls(self, Participant(), is_system=True)
766
774
 
775
+ @overload
767
776
  async def get_participant_by_contact(
768
777
  self, c: "LegacyContact"
769
- ) -> "LegacyParticipantType":
778
+ ) -> "LegacyParticipantType": ...
779
+
780
+ @overload
781
+ async def get_participant_by_contact(
782
+ self, c: "LegacyContact", create: Literal[False]
783
+ ) -> "LegacyParticipantType | None": ...
784
+
785
+ @overload
786
+ async def get_participant_by_contact(
787
+ self, c: "LegacyContact", create: Literal[True]
788
+ ) -> "LegacyParticipantType": ...
789
+
790
+ async def get_participant_by_contact(
791
+ self, c: "LegacyContact", create: bool = True
792
+ ) -> "LegacyParticipantType | None":
770
793
  """
771
794
  Get a non-anonymous participant.
772
795
 
@@ -774,6 +797,7 @@ class LegacyMUC(
774
797
  that the Contact jid is associated to this participant
775
798
 
776
799
  :param c: The :class:`.LegacyContact` instance corresponding to this contact
800
+ :param create: Creates the participant if it does not exist.
777
801
  :return:
778
802
  """
779
803
  await self.session.contacts.ready
@@ -785,7 +809,10 @@ class LegacyMUC(
785
809
  .filter_by(contact=c.stored, room=self.stored)
786
810
  .one_or_none()
787
811
  )
788
- if stored is not None:
812
+ if stored is None:
813
+ if not create:
814
+ return None
815
+ else:
789
816
  return self.participant_from_store(stored=stored, contact=c)
790
817
 
791
818
  nickname = c.name or unescape_node(c.jid.node)
slidge/util/types.py CHANGED
@@ -72,6 +72,7 @@ MucRole = Literal["visitor", "participant", "moderator", "none"]
72
72
  ClientType = Literal[
73
73
  "bot", "console", "game", "handheld", "pc", "phone", "sms", "tablet", "web"
74
74
  ]
75
+ AttachmentDisposition = Literal["attachment", "inline"]
75
76
 
76
77
 
77
78
  @dataclass
@@ -115,6 +116,7 @@ class LegacyAttachment:
115
116
  legacy_file_id: Optional[Union[str, int]] = None
116
117
  url: Optional[str] = None
117
118
  caption: Optional[str] = None
119
+ disposition: Optional[AttachmentDisposition] = None
118
120
  """
119
121
  A caption for this specific image. For a global caption for a list of attachments,
120
122
  use the ``body`` parameter of :meth:`.AttachmentMixin.send_files`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: slidge
3
- Version: 0.3.0b2
3
+ Version: 0.3.0b3
4
4
  Summary: XMPP bridging framework
5
5
  Author-email: Nicolas Cedilnik <nicoco@nicoco.fr>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -39,11 +39,11 @@ slidge/core/dispatcher/muc/misc.py,sha256=FYo5FdmzksEuUCfCLLOOm8_8plXtZFQP8IzvzV
39
39
  slidge/core/dispatcher/muc/owner.py,sha256=dDAxpRaA8H_NJQNIyBNixck2oG4GHZeEQqPhKd7MmDQ,3359
40
40
  slidge/core/dispatcher/muc/ping.py,sha256=EgKKS9AvMnW-vINGcoGbtk6NdbN9A7zVaGfT5T7F6YE,1699
41
41
  slidge/core/mixins/__init__.py,sha256=Zea39CCwjJU5XfHwcYPEZ9Sin8z1BZxoV68G2RwC3nE,386
42
- slidge/core/mixins/attachment.py,sha256=f_8SZGyEAK00fzpwUWyIocPzdkSl5awPihR6_GCgdDo,21766
42
+ slidge/core/mixins/attachment.py,sha256=6c1gZNydVZHgHB-_PjBLbT_9ntBSNG0AWqlv9Cgcku8,21906
43
43
  slidge/core/mixins/avatar.py,sha256=0E0mQxdTUcJQrYXlBkYqkNl4bYuga4cIC1s4XA2rED8,5559
44
- slidge/core/mixins/base.py,sha256=MOd-pas38_52VawQVlxWtBtmTKC6My9G0ZaCeQxOJbs,748
44
+ slidge/core/mixins/base.py,sha256=iGu1yPFgivouhXx0ckgbO7HbpFHOnbJnEWEUvwSg8KU,755
45
45
  slidge/core/mixins/db.py,sha256=a6idm-FgHWfDK-MJZWy5AkkBlyY8JmwOB8xAFmm0E9g,1934
46
- slidge/core/mixins/disco.py,sha256=jk3Z1B6zTuisHv8VKNRJodIo0ee5btYHh2ZrlflPj_Q,3670
46
+ slidge/core/mixins/disco.py,sha256=mrYhWO9qpnLMAVtKKqwbDh6CNOH2dPNERpyfmWzZGg8,3684
47
47
  slidge/core/mixins/message.py,sha256=xk4bgiJF9ATe-rgtH4sHU8hUwecBF4KjGIujm90mbXQ,8014
48
48
  slidge/core/mixins/message_maker.py,sha256=d9lMurnWCr7Y-pyyUkLoQYykb6lCCZuBNKFOe2hcY3A,6552
49
49
  slidge/core/mixins/message_text.py,sha256=UUbY-hdsMEUHe3b2h2Rwkaic43iDiaaUoEmuyw6FezY,8564
@@ -53,16 +53,16 @@ slidge/db/__init__.py,sha256=EBDH1JSEhgqYcli2Bw11CRC749wJk8AOucgBzmhDSvU,105
53
53
  slidge/db/avatar.py,sha256=MXFd1oe0eL5CCUYbc5CpsIcbio3cY3xVoKt39RAoj9I,8240
54
54
  slidge/db/meta.py,sha256=NtjGWcqPfG7uPfwR_cC6_23zyo8ftqgKX8CbP9IBq6U,2185
55
55
  slidge/db/models.py,sha256=8z5bbaEINfU1Qx12iyHu4zRD9s3PwC6oUOz-PyBoqYg,12841
56
- slidge/db/store.py,sha256=shgBqGutbAeMD6T3sqH7Qo4IKs9TWwjwfH5-NDpj-kY,19399
56
+ slidge/db/store.py,sha256=ZksmZlFaTia7eWy_trALc_iTEkk2x7CIlEQeYkHW21g,19408
57
57
  slidge/db/alembic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
58
  slidge/db/alembic/env.py,sha256=hsBlRNs0zF5diSHGRSa8Fi3qRVQDA2rJdR41AEIdvxc,1642
59
59
  slidge/db/alembic/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
60
60
  slidge/db/alembic/versions/cef02a8b1451_initial_schema.py,sha256=D1K-flfTM9Vkk0YFzg6HbmoDyEb2u5c751aXk2YzVVg,14881
61
61
  slidge/group/__init__.py,sha256=yFt7cHqeaKIMN6f9ZyhhspOcJJvBtLedGv-iICG7lto,258
62
62
  slidge/group/archive.py,sha256=DKwyde15-Op2rXuQBvdSmFcAKhUyWuorpEFcRSmDHec,5956
63
- slidge/group/bookmarks.py,sha256=UWrUjZMWlDmwKFRuNEqxZSx4cvXFib4AP_l388ApJa8,7086
63
+ slidge/group/bookmarks.py,sha256=qOaopMQNoGUB05Kq4aYRmoE-DOtXmSAAGwfCs1hcWB4,7648
64
64
  slidge/group/participant.py,sha256=eMwUgbEtxGjWMmIqUfS8uSKlaStitZ3D68M_RixQeso,17676
65
- slidge/group/room.py,sha256=_KP0jIh9f9k0yDRWCe7BsZBQesfm1lwbHpN9WYRKuzc,48391
65
+ slidge/group/room.py,sha256=E3uiroLmqwM52Lw6zT4wUQmVjmxx6wkeF3f87bIt3VU,49026
66
66
  slidge/slixfix/__init__.py,sha256=LvaYZQYjr4l_45AYYpod1dB3MUaZye18vKF-4H8Bm20,4758
67
67
  slidge/slixfix/delivery_receipt.py,sha256=JmogxsiXYEbTmCM4fvC5wkQs0jBsaJtKl4j_B_18riE,1415
68
68
  slidge/slixfix/roster.py,sha256=DjjHQqCsKsPChUxV7S0Pm4IAgjfrwgm5tcTdJi3N_gY,1670
@@ -85,11 +85,11 @@ slidge/util/conf.py,sha256=Wv-xr1fQfz6jDCBpj2e5Nm-igMpdIjsYsVfoY8grJoo,7380
85
85
  slidge/util/jid_escaping.py,sha256=QJ2Yj_j1gTmiO9g2r187iVCu7kia_O5ABhRiLAO2TG4,1073
86
86
  slidge/util/lock.py,sha256=ZnUi3LGiz271-YeYKo9JzxovJCoSwlP9P65pNyHIO9o,1029
87
87
  slidge/util/test.py,sha256=_E6er2BtQlpyzTUmp4u8C9KhBYzbLrmTwSVgxGObKHU,13988
88
- slidge/util/types.py,sha256=xJ84ZvaUOU_VVJSjEMysgNSl05k0_O9YKbyW-JUrsMI,5635
88
+ slidge/util/types.py,sha256=nilphTeJU3yb0MSqb86tZeWXis495oDvHSDDBs0hn_4,5747
89
89
  slidge/util/util.py,sha256=4hihLCl4SsB5S14TT3bP8tDPP_Zg9rYbSfLdLB9-G_Q,9332
90
- slidge-0.3.0b2.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
91
- slidge-0.3.0b2.dist-info/METADATA,sha256=_O_tp1b_KiJA94aoQQG0e0Nbg37mt-P7BFJY6Gn0xcg,5056
92
- slidge-0.3.0b2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
- slidge-0.3.0b2.dist-info/entry_points.txt,sha256=py3_x834fFJ2TEzPd18Wt2DnysdAfuVqJ5zzBrXbAZs,44
94
- slidge-0.3.0b2.dist-info/top_level.txt,sha256=2LRjDYHaGZ5ieCMF8xy58JIiabRMzX-MGMbCZwfE17c,7
95
- slidge-0.3.0b2.dist-info/RECORD,,
90
+ slidge-0.3.0b3.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
91
+ slidge-0.3.0b3.dist-info/METADATA,sha256=ZAjh2fLNz60lo8cZygLkm89isXqMPbSYvWnHvCVAPr8,5056
92
+ slidge-0.3.0b3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
+ slidge-0.3.0b3.dist-info/entry_points.txt,sha256=py3_x834fFJ2TEzPd18Wt2DnysdAfuVqJ5zzBrXbAZs,44
94
+ slidge-0.3.0b3.dist-info/top_level.txt,sha256=2LRjDYHaGZ5ieCMF8xy58JIiabRMzX-MGMbCZwfE17c,7
95
+ slidge-0.3.0b3.dist-info/RECORD,,