xn-auth 0.2.50__tar.gz → 0.2.51.dev1__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.50/xn_auth.egg-info → xn_auth-0.2.51.dev1}/PKG-INFO +1 -1
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/models.py +19 -23
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1/xn_auth.egg-info}/PKG-INFO +1 -1
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/.env.dist +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/.gitignore +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/.pre-commit-config.yaml +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/README.md +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/makefile +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/pyproject.toml +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/setup.cfg +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/controller.py +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/enums.py +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/exceptions.py +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/middleware.py +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/x_auth/types.py +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/xn_auth.egg-info/SOURCES.txt +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/xn_auth.egg-info/dependency_links.txt +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/xn_auth.egg-info/requires.txt +0 -0
- {xn_auth-0.2.50 → xn_auth-0.2.51.dev1}/xn_auth.egg-info/top_level.txt +0 -0
|
@@ -27,10 +27,9 @@ from tortoise.fields import (
|
|
|
27
27
|
from tortoise.fields.data import CharEnumFieldInstance
|
|
28
28
|
|
|
29
29
|
from x_auth import types
|
|
30
|
-
from x_model.field import DatetimeSecField, UInt8Field,
|
|
30
|
+
from x_model.field import DatetimeSecField, UInt8Field, UInt1Field, UInt2Field
|
|
31
31
|
from x_model.models import Model, TsTrait
|
|
32
32
|
from tortoise import Model as TortModel
|
|
33
|
-
from x_model.types import BaseUpd
|
|
34
33
|
|
|
35
34
|
from x_auth.enums import Lang, Role, PeerType
|
|
36
35
|
|
|
@@ -54,28 +53,29 @@ class User(Model):
|
|
|
54
53
|
blocked: bool = BooleanField(null=True)
|
|
55
54
|
lang: Lang | None = IntEnumField(Lang, default=Lang.ru, null=True)
|
|
56
55
|
role: Role = IntEnumField(Role, default=Role.READER)
|
|
57
|
-
prv = UniqBinaryField(unique=True, null=True) # len=32
|
|
58
|
-
pub = UniqBinaryField(unique=True, null=True) # len=32
|
|
59
56
|
|
|
60
57
|
app: BackwardOneToOneRelation["App"]
|
|
61
58
|
|
|
62
59
|
@classmethod
|
|
63
|
-
async def tg2in(cls, u: PyroUser | AioUser | WebAppUser, blocked: bool = None) ->
|
|
60
|
+
async def tg2in(cls, u: PyroUser | AioUser | WebAppUser, blocked: bool = None) -> dict:
|
|
64
61
|
un, _ = await cls._meta.fields_map["username"].related_model.update_or_create({"username": u.username}, id=u.id)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
and u.photo_url
|
|
73
|
-
and u.photo_url.replace("https://t.me/i/userpic/320/", "")[:-4],
|
|
74
|
-
}
|
|
62
|
+
pic = hasattr(u, "photo_url") and u.photo_url and u.photo_url.replace("https://t.me/i/userpic/320/", "")[:-4]
|
|
63
|
+
pic = (
|
|
64
|
+
pic
|
|
65
|
+
or isinstance(u, AioUser)
|
|
66
|
+
and (photos := (await u.bot.get_user_profile_photos(u.id)).photos)
|
|
67
|
+
and photos[0][-1].file_id
|
|
68
|
+
or None
|
|
75
69
|
)
|
|
70
|
+
user_dict = {
|
|
71
|
+
"first_name": u.first_name,
|
|
72
|
+
"last_name": u.last_name,
|
|
73
|
+
"lang": u.language_code and Lang[u.language_code],
|
|
74
|
+
"pic": pic,
|
|
75
|
+
}
|
|
76
76
|
if blocked is not None:
|
|
77
|
-
|
|
78
|
-
return
|
|
77
|
+
user_dict["blocked"] = blocked
|
|
78
|
+
return user_dict
|
|
79
79
|
|
|
80
80
|
@classmethod
|
|
81
81
|
async def is_blocked(cls, sid: str) -> bool:
|
|
@@ -83,12 +83,8 @@ class User(Model):
|
|
|
83
83
|
|
|
84
84
|
@classmethod
|
|
85
85
|
async def tg_upsert(cls, u: PyroUser | AioUser, blocked: bool = None) -> tuple["User", bool]:
|
|
86
|
-
user_in:
|
|
87
|
-
|
|
88
|
-
return await cls.update_or_create(**prms)
|
|
89
|
-
|
|
90
|
-
# class Meta:
|
|
91
|
-
# abstract = True
|
|
86
|
+
user_in: dict = await cls.tg2in(u, blocked)
|
|
87
|
+
return await cls.update_or_create(user_in, username_id=u.id)
|
|
92
88
|
|
|
93
89
|
|
|
94
90
|
class Country(Model):
|
|
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
|