mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-03-06 09:27:33 +01:00
Refactor seguidores y seguidos
This commit is contained in:
@@ -110,9 +110,9 @@ class UserBuffer(BaseBuffer):
|
|||||||
# If batch profiles lack counts, hydrate with detailed profiles.
|
# If batch profiles lack counts, hydrate with detailed profiles.
|
||||||
if hasattr(self.session, "get_profile"):
|
if hasattr(self.session, "get_profile"):
|
||||||
def counts_missing(profile_obj):
|
def counts_missing(profile_obj):
|
||||||
p1 = g(profile_obj, "followersCount", None)
|
p1 = g(profile_obj, "followersCount") or g(profile_obj, "followers_count")
|
||||||
p2 = g(profile_obj, "followsCount", None)
|
p2 = g(profile_obj, "followsCount") or g(profile_obj, "follows_count")
|
||||||
p3 = g(profile_obj, "postsCount", None)
|
p3 = g(profile_obj, "postsCount") or g(profile_obj, "posts_count")
|
||||||
if p1 is None and p2 is None and p3 is None:
|
if p1 is None and p2 is None and p3 is None:
|
||||||
return True
|
return True
|
||||||
return (p1 or 0) == 0 and (p2 or 0) == 0 and (p3 or 0) == 0
|
return (p1 or 0) == 0 and (p2 or 0) == 0 and (p3 or 0) == 0
|
||||||
@@ -151,12 +151,12 @@ class UserBuffer(BaseBuffer):
|
|||||||
if profile is None:
|
if profile is None:
|
||||||
return False
|
return False
|
||||||
base = resolve_profile(item)
|
base = resolve_profile(item)
|
||||||
f1 = g(base, "followersCount", None)
|
f1 = g(base, "followersCount") or g(base, "followers_count")
|
||||||
f2 = g(base, "followsCount", None)
|
f2 = g(base, "followsCount") or g(base, "follows_count")
|
||||||
f3 = g(base, "postsCount", None)
|
f3 = g(base, "postsCount") or g(base, "posts_count")
|
||||||
p1 = g(profile, "followersCount", None)
|
p1 = g(profile, "followersCount") or g(profile, "followers_count")
|
||||||
p2 = g(profile, "followsCount", None)
|
p2 = g(profile, "followsCount") or g(profile, "follows_count")
|
||||||
p3 = g(profile, "postsCount", None)
|
p3 = g(profile, "postsCount") or g(profile, "posts_count")
|
||||||
if f1 is None and f2 is None and f3 is None:
|
if f1 is None and f2 is None and f3 is None:
|
||||||
return True
|
return True
|
||||||
if (f1 or 0) == 0 and (f2 or 0) == 0 and (f3 or 0) == 0:
|
if (f1 or 0) == 0 and (f2 or 0) == 0 and (f3 or 0) == 0:
|
||||||
|
|||||||
@@ -297,10 +297,10 @@ def compose_user(user, db, settings, relative_times, show_screen_names=False, sa
|
|||||||
profile = resolve_profile(user)
|
profile = resolve_profile(user)
|
||||||
handle = g(profile, "handle", "unknown")
|
handle = g(profile, "handle", "unknown")
|
||||||
display_name = g(profile, "displayName") or g(profile, "display_name") or handle
|
display_name = g(profile, "displayName") or g(profile, "display_name") or handle
|
||||||
followers = g(profile, "followersCount", 0) or 0
|
followers = g(profile, "followersCount") or g(profile, "followers_count") or 0
|
||||||
following = g(profile, "followsCount", 0) or 0
|
following = g(profile, "followsCount") or g(profile, "follows_count") or 0
|
||||||
posts = g(profile, "postsCount", 0) or 0
|
posts = g(profile, "postsCount") or g(profile, "posts_count") or 0
|
||||||
created_at = g(profile, "createdAt", None)
|
created_at = g(profile, "createdAt") or g(profile, "created_at")
|
||||||
|
|
||||||
ts = ""
|
ts = ""
|
||||||
if created_at:
|
if created_at:
|
||||||
|
|||||||
@@ -186,13 +186,24 @@ def render_post(post, template, settings, relative_times=False, offset_hours=0):
|
|||||||
|
|
||||||
|
|
||||||
def render_user(user, template, settings, relative_times=True, offset_hours=0):
|
def render_user(user, template, settings, relative_times=True, offset_hours=0):
|
||||||
display_name = _g(user, "displayName") or _g(user, "display_name") or _g(user, "handle", "")
|
# Resolve nested profile structure (subject, actor, profile, user)
|
||||||
screen_name = _g(user, "handle", "")
|
def resolve_profile(obj):
|
||||||
description = _g(user, "description", "") or ""
|
if _g(obj, "handle") or _g(obj, "did"):
|
||||||
followers = _g(user, "followersCount", 0) or 0
|
return obj
|
||||||
following = _g(user, "followsCount", 0) or 0
|
for key in ("subject", "actor", "profile", "user"):
|
||||||
posts = _g(user, "postsCount", 0) or 0
|
nested = _g(obj, key)
|
||||||
created_at = _g(user, "createdAt")
|
if nested and (_g(nested, "handle") or _g(nested, "did")):
|
||||||
|
return nested
|
||||||
|
return obj
|
||||||
|
|
||||||
|
profile = resolve_profile(user)
|
||||||
|
display_name = _g(profile, "displayName") or _g(profile, "display_name") or _g(profile, "handle", "")
|
||||||
|
screen_name = _g(profile, "handle", "")
|
||||||
|
description = _g(profile, "description", "") or ""
|
||||||
|
followers = _g(profile, "followersCount") or _g(profile, "followers_count") or 0
|
||||||
|
following = _g(profile, "followsCount") or _g(profile, "follows_count") or 0
|
||||||
|
posts = _g(profile, "postsCount") or _g(profile, "posts_count") or 0
|
||||||
|
created_at = _g(profile, "createdAt") or _g(profile, "created_at")
|
||||||
created = ""
|
created = ""
|
||||||
if created_at:
|
if created_at:
|
||||||
created = process_date(created_at, relative_times, offset_hours)
|
created = process_date(created_at, relative_times, offset_hours)
|
||||||
|
|||||||
Reference in New Issue
Block a user