xn-auth 0.2.34.dev1__py3-none-any.whl → 0.2.36__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/models.py +27 -8
- {xn_auth-0.2.34.dev1.dist-info → xn_auth-0.2.36.dist-info}/METADATA +1 -1
- xn_auth-0.2.36.dist-info/RECORD +10 -0
- xn_auth-0.2.34.dev1.dist-info/RECORD +0 -10
- {xn_auth-0.2.34.dev1.dist-info → xn_auth-0.2.36.dist-info}/WHEEL +0 -0
- {xn_auth-0.2.34.dev1.dist-info → xn_auth-0.2.36.dist-info}/top_level.txt +0 -0
x_auth/models.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
|
|
3
|
-
from aiogram.types import User as TgUser
|
|
4
|
-
from aiogram.utils.web_app import WebAppUser
|
|
5
3
|
from aiohttp import ClientSession
|
|
6
4
|
from msgspec import convert
|
|
7
5
|
from pyrogram.enums.client_platform import ClientPlatform
|
|
6
|
+
from pyrogram.types import User as TgUser
|
|
8
7
|
from tortoise.fields import (
|
|
9
8
|
BigIntField,
|
|
10
9
|
BooleanField,
|
|
@@ -15,6 +14,7 @@ from tortoise.fields import (
|
|
|
15
14
|
IntField,
|
|
16
15
|
BinaryField,
|
|
17
16
|
OneToOneRelation,
|
|
17
|
+
OneToOneNullableRelation,
|
|
18
18
|
OneToOneField,
|
|
19
19
|
SmallIntField,
|
|
20
20
|
BackwardOneToOneRelation,
|
|
@@ -41,7 +41,7 @@ class Username(TortModel):
|
|
|
41
41
|
|
|
42
42
|
user: BackwardOneToOneRelation["User"]
|
|
43
43
|
peers: BackwardFKRelation["Peer"]
|
|
44
|
-
|
|
44
|
+
session: BackwardOneToOneRelation["Session"]
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class User(Model):
|
|
@@ -59,9 +59,15 @@ class User(Model):
|
|
|
59
59
|
return AuthUser.model_validate(self, from_attributes=True)
|
|
60
60
|
|
|
61
61
|
@classmethod
|
|
62
|
-
async def tg2in(cls, u: TgUser
|
|
62
|
+
async def tg2in(cls, u: TgUser, blocked: bool = None) -> BaseUpd:
|
|
63
|
+
un, _ = await cls._meta.fields_map["username"].related_model.update_or_create({"username": u.username}, id=u.id)
|
|
63
64
|
user = cls.validate(
|
|
64
|
-
{
|
|
65
|
+
{
|
|
66
|
+
"first_name": u.first_name,
|
|
67
|
+
"last_name": u.last_name,
|
|
68
|
+
"username_id": un.id,
|
|
69
|
+
"lang": u.language_code and Lang[u.language_code],
|
|
70
|
+
}
|
|
65
71
|
)
|
|
66
72
|
if blocked is not None:
|
|
67
73
|
user.blocked = blocked
|
|
@@ -75,6 +81,13 @@ class User(Model):
|
|
|
75
81
|
# abstract = True
|
|
76
82
|
|
|
77
83
|
|
|
84
|
+
# @pre_save(User)
|
|
85
|
+
# async def username(_meta, user: User, _db, _updated: dict) -> None:
|
|
86
|
+
# if user.username_id:
|
|
87
|
+
# return
|
|
88
|
+
# user.username = await Username.create(name=user.username)
|
|
89
|
+
|
|
90
|
+
|
|
78
91
|
class Country(Model):
|
|
79
92
|
id = SmallIntField(True)
|
|
80
93
|
code: int | None = IntField(null=True)
|
|
@@ -147,6 +160,12 @@ class Proxy(Model, TsTrait):
|
|
|
147
160
|
reps = [convert(r, types.Replacement) for r in lst]
|
|
148
161
|
return reps
|
|
149
162
|
|
|
163
|
+
def dict(self):
|
|
164
|
+
return dict(scheme="socks5", hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
165
|
+
|
|
166
|
+
def str(self):
|
|
167
|
+
return f"http://{self.username}:{self.password}@{self.host}:{self.port}"
|
|
168
|
+
|
|
150
169
|
|
|
151
170
|
class Dc(TortModel):
|
|
152
171
|
id: int = SmallIntField(True)
|
|
@@ -174,13 +193,13 @@ class App(Model):
|
|
|
174
193
|
fcm: ForeignKeyNullableRelation[Fcm] = ForeignKeyField("models.Fcm", "apps", null=True)
|
|
175
194
|
fcm_id: int
|
|
176
195
|
platform: ClientPlatform = CharEnumFieldInstance(ClientPlatform)
|
|
177
|
-
owner:
|
|
196
|
+
owner: OneToOneNullableRelation["User"] = OneToOneField("models.User", "app", null=True)
|
|
178
197
|
|
|
179
198
|
sessions: BackwardFKRelation["Session"]
|
|
180
199
|
|
|
181
200
|
|
|
182
201
|
class Session(TortModel):
|
|
183
|
-
id =
|
|
202
|
+
id = BigIntField(True)
|
|
184
203
|
api: ForeignKeyRelation[App] = ForeignKeyField("models.App", "sessions")
|
|
185
204
|
api_id: int
|
|
186
205
|
dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "sessions", default=2)
|
|
@@ -188,7 +207,7 @@ class Session(TortModel):
|
|
|
188
207
|
test_mode = BooleanField(default=False)
|
|
189
208
|
auth_key = BinaryField(null=True)
|
|
190
209
|
date = IntField(default=0) # todo: refact to datetime?
|
|
191
|
-
user:
|
|
210
|
+
user: OneToOneNullableRelation[Username] = OneToOneField("models.Username", "session", null=True)
|
|
192
211
|
user_id: int
|
|
193
212
|
is_bot = CharField(42, null=True)
|
|
194
213
|
state: dict = JSONField(default={})
|
|
@@ -0,0 +1,10 @@
|
|
|
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,,
|
|
@@ -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=BW3pUn3iAULuoCvYXbdKJfpHWmSGHQzfV663RUs9lrE,7937
|
|
6
|
-
x_auth/types.py,sha256=j3WGcyH24DmFEdTT6U7xzb_fEm1tFcBZsANKMy7bydo,689
|
|
7
|
-
xn_auth-0.2.34.dev1.dist-info/METADATA,sha256=sCKAlmPf7GNqyknSzJfrWinFBADvttccSlG1cmQz9ZA,804
|
|
8
|
-
xn_auth-0.2.34.dev1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
9
|
-
xn_auth-0.2.34.dev1.dist-info/top_level.txt,sha256=ydMDkzxgQPtW-E_MNDfUAroAFZvWSqU-x_kZSA7NSFo,7
|
|
10
|
-
xn_auth-0.2.34.dev1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|