Skip to content

Commit 17dd015

Browse files
Feat/user following status (#632)
* fix:add pagination to get project follower endpoint * feat: add is_following flag to indicate if current user follows listed users
1 parent a8446ce commit 17dd015

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/controllers/socials.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ def get_users_data(current_user, search=None, filter_type=None, page=1, per_page
130130
user_schema = UserSchema(many=True)
131131
schema_result = user_schema.dump(users)
132132
users_data = SocialService._handle_schema_result(schema_result)
133+
if current_user:
134+
for user_data, user_obj in zip(users_data, users):
135+
user_data['is_following'] = current_user.is_following(user_obj)
136+
else:
137+
for user_data in users_data:
138+
user_data['is_following'] = False
133139

134140
return {
135141
'users': users_data,
@@ -149,6 +155,13 @@ def get_users_data(current_user, search=None, filter_type=None, page=1, per_page
149155
user_schema = UserSchema(many=True)
150156
schema_result = user_schema.dump(users)
151157
users_data = SocialService._handle_schema_result(schema_result)
158+
159+
if current_user:
160+
for user_data, user_obj in zip(users_data, users):
161+
user_data['is_following'] = current_user.is_following(user_obj)
162+
else:
163+
for user_data in users_data:
164+
user_data['is_following'] = False
152165

153166
return users_data
154167

0 commit comments

Comments
 (0)