xn-auth 0.2.34.dev1__tar.gz → 0.2.35__tar.gz
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.
- {xn_auth-0.2.34.dev1/xn_auth.egg-info → xn_auth-0.2.35}/PKG-INFO +1 -1
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/models.py +24 -8
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35/xn_auth.egg-info}/PKG-INFO +1 -1
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/.env.dist +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/.gitignore +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/.pre-commit-config.yaml +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/README.md +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/makefile +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/pyproject.toml +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/setup.cfg +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/controller.py +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/enums.py +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/exceptions.py +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/middleware.py +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/x_auth/types.py +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/xn_auth.egg-info/SOURCES.txt +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/xn_auth.egg-info/dependency_links.txt +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/xn_auth.egg-info/requires.txt +0 -0
- {xn_auth-0.2.34.dev1 → xn_auth-0.2.35}/xn_auth.egg-info/top_level.txt +0 -0
|
@@ -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,9 @@ 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
|
+
|
|
150
166
|
|
|
151
167
|
class Dc(TortModel):
|
|
152
168
|
id: int = SmallIntField(True)
|
|
@@ -174,13 +190,13 @@ class App(Model):
|
|
|
174
190
|
fcm: ForeignKeyNullableRelation[Fcm] = ForeignKeyField("models.Fcm", "apps", null=True)
|
|
175
191
|
fcm_id: int
|
|
176
192
|
platform: ClientPlatform = CharEnumFieldInstance(ClientPlatform)
|
|
177
|
-
owner:
|
|
193
|
+
owner: OneToOneNullableRelation["User"] = OneToOneField("models.User", "app", null=True)
|
|
178
194
|
|
|
179
195
|
sessions: BackwardFKRelation["Session"]
|
|
180
196
|
|
|
181
197
|
|
|
182
198
|
class Session(TortModel):
|
|
183
|
-
id =
|
|
199
|
+
id = BigIntField(True)
|
|
184
200
|
api: ForeignKeyRelation[App] = ForeignKeyField("models.App", "sessions")
|
|
185
201
|
api_id: int
|
|
186
202
|
dc: ForeignKeyRelation[Dc] = ForeignKeyField("models.Dc", "sessions", default=2)
|
|
@@ -188,7 +204,7 @@ class Session(TortModel):
|
|
|
188
204
|
test_mode = BooleanField(default=False)
|
|
189
205
|
auth_key = BinaryField(null=True)
|
|
190
206
|
date = IntField(default=0) # todo: refact to datetime?
|
|
191
|
-
user:
|
|
207
|
+
user: OneToOneNullableRelation[Username] = OneToOneField("models.Username", "session", null=True)
|
|
192
208
|
user_id: int
|
|
193
209
|
is_bot = CharField(42, null=True)
|
|
194
210
|
state: dict = JSONField(default={})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|