You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
901 B
27 lines
901 B
def friends_serialize(friends: list, external_friends: list) -> dict:
|
|
serialized_friends: dict = {
|
|
'friends': [],
|
|
'external_friends': []
|
|
}
|
|
|
|
for friend in friends:
|
|
status = friend.status if hasattr(friend, 'status') else 'null'
|
|
|
|
serialized_friends["friends"].append({
|
|
"id": str(friend["_id"]),
|
|
"user_id": friend["user_id"],
|
|
"friend_user_id": friend["friend_user_id"],
|
|
"status": status
|
|
})
|
|
|
|
for external_friend in external_friends:
|
|
status = external_friend.status if external_friend.status else 'null'
|
|
|
|
serialized_friends["external_friends"].append({
|
|
"id": str(external_friend["_id"]),
|
|
"user_id": external_friend["user_id"],
|
|
"friend_user_id": external_friend["friend_user_id"],
|
|
"status": status
|
|
})
|
|
|
|
return serialized_friends |