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
@@ -1,11 +1,8 @@
|
||||
from pyrogram.types import User
|
||||
|
||||
from userbot.modules.avatars import note_avatar
|
||||
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.raw_json import raw_json
|
||||
from userbot.modules.profiles.snapshots import save_user
|
||||
|
||||
|
||||
@register("sync_contacts")
|
||||
@@ -21,26 +18,7 @@ async def sync_contacts(ctx: JobContext) -> None:
|
||||
for user in contacts:
|
||||
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=capture.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,
|
||||
)
|
||||
await save_user(capture, user)
|
||||
processed += 1
|
||||
await capture.contacts.refresh()
|
||||
await ctx.report_progress({"processed": processed, "done": True})
|
||||
Reference in new issue
Block a user