Move fetchAllUsers parsing into User._from_all_fetch
This commit is contained in:
@@ -694,24 +694,12 @@ class Client(object):
|
|||||||
raise FBchatException("Missing payload while fetching users: {}".format(j))
|
raise FBchatException("Missing payload while fetching users: {}".format(j))
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
|
for data in j["payload"].values():
|
||||||
for key in j["payload"]:
|
if data["type"] in ["user", "friend"]:
|
||||||
k = j["payload"][key]
|
if data["id"] in ["0", 0]:
|
||||||
if k["type"] in ["user", "friend"]:
|
|
||||||
if k["id"] in ["0", 0]:
|
|
||||||
# Skip invalid users
|
# Skip invalid users
|
||||||
pass
|
continue
|
||||||
users.append(
|
users.append(User._from_all_fetch(data))
|
||||||
User(
|
|
||||||
k["id"],
|
|
||||||
first_name=k.get("firstName"),
|
|
||||||
url=k.get("uri"),
|
|
||||||
photo=k.get("thumbSrc"),
|
|
||||||
name=k.get("name"),
|
|
||||||
is_friend=k.get("is_friend"),
|
|
||||||
gender=GENDERS.get(k.get("gender")),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return users
|
return users
|
||||||
|
|
||||||
|
@@ -139,6 +139,18 @@ class User(Thread):
|
|||||||
plan=plan,
|
plan=plan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _from_all_fetch(cls, data):
|
||||||
|
return cls(
|
||||||
|
data["id"],
|
||||||
|
first_name=data.get("firstName"),
|
||||||
|
url=data.get("uri"),
|
||||||
|
photo=data.get("thumbSrc"),
|
||||||
|
name=data.get("name"),
|
||||||
|
is_friend=data.get("is_friend"),
|
||||||
|
gender=_util.GENDERS.get(data.get("gender")),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@attr.s(cmp=False)
|
@attr.s(cmp=False)
|
||||||
class ActiveStatus(object):
|
class ActiveStatus(object):
|
||||||
|
Reference in New Issue
Block a user