fix(backend): group title changes found by enrichment are recorded, enrichment and syncs skip unchanged profiles
This commit is contained in:
1 parent
efc431c969
commit
aa41bbbc74
6 files changed
+77
-110
No files matched your search
@@ -2,14 +2,10 @@ from pyrogram import Client
|
||||
from pyrogram.errors import BadRequest, Forbidden
|
||||
from pyrogram.types import User
|
||||
|
||||
from userbot.modules.avatars import note_avatar
|
||||
from userbot.modules.capture.context import CaptureContext
|
||||
from userbot.modules.jobs.context import JobContext
|
||||
from userbot.modules.jobs.registry import register
|
||||
from userbot.modules.profiles.parse import snapshot_from_high_level
|
||||
from userbot.modules.profiles.repository import write_profile
|
||||
from userbot.modules.profiles.snapshots import save_group, save_private
|
||||
from userbot.modules.raw_json import raw_json
|
||||
from userbot.modules.profiles.snapshots import save_group, save_private, save_user
|
||||
from utils.logging import logger
|
||||
|
||||
SAVE_EVERY = 100
|
||||
@@ -30,28 +26,8 @@ async def _enrich_users(client: Client, ctx: CaptureContext, ids: list[int]) ->
|
||||
continue
|
||||
users = result if isinstance(result, list) else [result]
|
||||
for user in users:
|
||||
if not isinstance(user, User):
|
||||
continue
|
||||
fields, photo_file_id, photo_unique_id = snapshot_from_high_level(user)
|
||||
await write_profile(
|
||||
ctx.pool,
|
||||
ctx.account_id,
|
||||
user.id,
|
||||
fields,
|
||||
raw_json(user),
|
||||
history=ctx.resolve_peer(
|
||||
user.id, is_bot=bool(user.is_bot)
|
||||
).profile_history,
|
||||
)
|
||||
if photo_file_id and photo_unique_id:
|
||||
await note_avatar(
|
||||
ctx.pool,
|
||||
ctx.account_id,
|
||||
user.id,
|
||||
"peer",
|
||||
photo_unique_id,
|
||||
photo_file_id,
|
||||
)
|
||||
if isinstance(user, User):
|
||||
await save_user(ctx, user)
|
||||
|
||||
|
||||
@register("sync_dialogs")
|
||||
|
||||
Reference in new issue
Block a user