xn-auth 0.2.36__py3-none-any.whl → 0.2.38__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.
x_auth/enums.py CHANGED
@@ -6,6 +6,14 @@ class Lang(IntEnum):
6
6
  en = 2
7
7
 
8
8
 
9
+ class PeerType(IntEnum):
10
+ bot = 1
11
+ channel = 2
12
+ group = 3
13
+ supergroup = 4
14
+ user = 5
15
+
16
+
9
17
  class RoleScope(IntEnum):
10
18
  READ = 4 # read all
11
19
  WRITE = 2 # read and write own
x_auth/models.py CHANGED
@@ -30,7 +30,7 @@ from x_model.models import Model, TsTrait
30
30
  from tortoise import Model as TortModel
31
31
  from x_model.types import BaseUpd
32
32
 
33
- from x_auth.enums import Lang, Role
33
+ from x_auth.enums import Lang, Role, PeerType
34
34
  from x_auth.types import AuthUser
35
35
 
36
36
 
@@ -77,6 +77,12 @@ class User(Model):
77
77
  async def is_blocked(cls, sid: str) -> bool:
78
78
  return (await cls[int(sid)]).blocked
79
79
 
80
+ @classmethod
81
+ async def pyro_upsert(cls, u: TgUser, blocked: bool = None) -> tuple["User", bool]:
82
+ user_in: cls.in_type() = await cls.tg2in(u, blocked)
83
+ prms = user_in.df_unq()
84
+ return await cls.update_or_create(**prms)
85
+
80
86
  # class Meta:
81
87
  # abstract = True
82
88
 
@@ -226,7 +232,7 @@ class Peer(TortModel):
226
232
  username_id: int
227
233
  session: ForeignKeyRelation[Session] = ForeignKeyField("models.Session", "peers")
228
234
  session_id: int
229
- type = CharField(127)
235
+ type: PeerType = IntEnumField(PeerType)
230
236
  phone_number = BigIntField(null=True) # todo: rm (already moved to Username.phone)
231
237
  last_update_on: datetime | None = DatetimeSecField(auto_now=True)
232
238
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-auth
3
- Version: 0.2.36
3
+ Version: 0.2.38
4
4
  Summary: Auth adapter for XN-Api framework
5
5
  Author-email: Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,10 @@
1
+ x_auth/controller.py,sha256=0QhqmqXOqFaWIUTWHlJKITQNmJQ5kXZOkLg7wSUTh60,2240
2
+ x_auth/enums.py,sha256=l4NTYsA-h0gyOp4PUe40Lb8LKoA94zL6EDkCmoGmBL0,732
3
+ x_auth/exceptions.py,sha256=2B4okJxhPyNqTJXlSTfblJUQJ60bLGXdgJIu6ue7S6w,162
4
+ x_auth/middleware.py,sha256=JfssQomDv0J_69GfS2a_2_uyRzs26zSY6IW1Vk7m8K0,2900
5
+ x_auth/models.py,sha256=bTSehdkdsF4YzhGnAmpsPXiLFyq8lG0l30kpgfXA8ZE,8859
6
+ x_auth/types.py,sha256=j3WGcyH24DmFEdTT6U7xzb_fEm1tFcBZsANKMy7bydo,689
7
+ xn_auth-0.2.38.dist-info/METADATA,sha256=zGAfWYjk3Tx7RHJ5mNLxFxWc2-koA7UXYWQVAZrKzo0,799
8
+ xn_auth-0.2.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ xn_auth-0.2.38.dist-info/top_level.txt,sha256=ydMDkzxgQPtW-E_MNDfUAroAFZvWSqU-x_kZSA7NSFo,7
10
+ xn_auth-0.2.38.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- x_auth/controller.py,sha256=0QhqmqXOqFaWIUTWHlJKITQNmJQ5kXZOkLg7wSUTh60,2240
2
- x_auth/enums.py,sha256=kmkX-j1bWNpel6_-fw2YtMEmJSAj9w2iizkG03s3ZSU,631
3
- x_auth/exceptions.py,sha256=2B4okJxhPyNqTJXlSTfblJUQJ60bLGXdgJIu6ue7S6w,162
4
- x_auth/middleware.py,sha256=JfssQomDv0J_69GfS2a_2_uyRzs26zSY6IW1Vk7m8K0,2900
5
- x_auth/models.py,sha256=5ymjpuc7yvSPeh9soRHPkAALxXo7xsPn3qPl0_75TJA,8582
6
- x_auth/types.py,sha256=j3WGcyH24DmFEdTT6U7xzb_fEm1tFcBZsANKMy7bydo,689
7
- xn_auth-0.2.36.dist-info/METADATA,sha256=Zc1IW38a8I8tSPMECpHLSBGx4sNV5kcP6ct4qlZWwHQ,799
8
- xn_auth-0.2.36.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
9
- xn_auth-0.2.36.dist-info/top_level.txt,sha256=ydMDkzxgQPtW-E_MNDfUAroAFZvWSqU-x_kZSA7NSFo,7
10
- xn_auth-0.2.36.dist-info/RECORD,,