parent
49cbd2a698
commit
401d4d8385
@ -1,8 +1,27 @@
|
|||||||
def friends_serialize(friends: list) -> list:
|
def friends_serialize(friends: list, external_friends: list) -> dict:
|
||||||
serialized_friends: list = []
|
serialized_friends: dict = {
|
||||||
|
'friends': [],
|
||||||
|
'external_friends': []
|
||||||
|
}
|
||||||
|
|
||||||
for friend in friends:
|
for friend in friends:
|
||||||
serialized_friends.append({
|
status = friend.status if hasattr(friend, 'status') else 'null'
|
||||||
|
|
||||||
|
serialized_friends["friends"].append({
|
||||||
"id": str(friend["_id"]),
|
"id": str(friend["_id"]),
|
||||||
"user_id": friend["user_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
|
return serialized_friends
|
Loading…
Reference in new issue