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.
21 lines
698 B
21 lines
698 B
from app.models.friend import Friend
|
|
|
|
def friend_serialize(friend: list, is_external: bool) -> Friend:
|
|
status = friend['status'] if 'status' in friend else 'pending'
|
|
|
|
return Friend(**{
|
|
"id": str(friend["_id"]),
|
|
"friend_user_id": friend["user_id"] if is_external else friend["friend_user_id"],
|
|
"status": status
|
|
})
|
|
|
|
def friends_serialize(friends: list, external_friends: list) -> dict:
|
|
serialized_friends: list = []
|
|
|
|
for friend in friends:
|
|
serialized_friends.append(friend_serialize(friend,False))
|
|
|
|
for external_friend in external_friends:
|
|
serialized_friends.append(friend_serialize(external_friend,True))
|
|
|
|
return serialized_friends |