@@ -352,31 +352,33 @@ async def delete_user_group(
352352#
353353
354354
355- _GROUP_MEMBER_COLS = (
356- users .c .id ,
357- users .c .name ,
358- sa .case (
359- (users .c .privacy_hide_email .is_ (True ), None ),
360- else_ = users .c .email ,
361- ).label ("email" ),
362- sa .case (
363- (users .c .privacy_hide_fullname .is_ (True ), None ),
364- else_ = users .c .first_name ,
365- ).label ("first_name" ),
366- sa .case (
367- (users .c .privacy_hide_fullname .is_ (True ), None ),
368- else_ = users .c .last_name ,
369- ).label ("last_name" ),
370- users .c .primary_gid ,
371- )
355+ def _group_user_cols (user_id : int ):
356+ return (
357+ users .c .id ,
358+ users .c .name ,
359+ # privacy settings
360+ sa .case (
361+ (users .c .privacy_hide_email .is_ (True ) and users .c .id != user_id , None ),
362+ else_ = users .c .email ,
363+ ).label ("email" ),
364+ sa .case (
365+ (users .c .privacy_hide_fullname .is_ (True ) and users .c .id != user_id , None ),
366+ else_ = users .c .first_name ,
367+ ).label ("first_name" ),
368+ sa .case (
369+ (users .c .privacy_hide_fullname .is_ (True ) and users .c .id != user_id , None ),
370+ else_ = users .c .last_name ,
371+ ).label ("last_name" ),
372+ users .c .primary_gid ,
373+ )
372374
373375
374376async def _get_user_in_group_permissions (
375377 conn : AsyncConnection , * , gid : GroupID , user_id : int
376378) -> Row :
377379 # now get the user
378380 result = await conn .stream (
379- sa .select (* _GROUP_MEMBER_COLS , user_to_groups .c .access_rights )
381+ sa .select (* _group_user_cols ( user_id ) , user_to_groups .c .access_rights )
380382 .select_from (
381383 users .join (user_to_groups , users .c .id == user_to_groups .c .uid ),
382384 )
@@ -405,7 +407,7 @@ async def list_users_in_group(
405407 # now get the list
406408 query = (
407409 sa .select (
408- * _GROUP_MEMBER_COLS ,
410+ * _group_user_cols ( user_id ) ,
409411 user_to_groups .c .access_rights ,
410412 )
411413 .select_from (users .join (user_to_groups ))
@@ -444,8 +446,8 @@ async def update_user_in_group(
444446 * ,
445447 user_id : UserID ,
446448 gid : GroupID ,
447- the_user_id_in_group : int ,
448- access_rights : dict ,
449+ the_user_id_in_group : UserID ,
450+ access_rights : AccessRightsDict ,
449451) -> GroupMember :
450452 if not access_rights :
451453 msg = f"Cannot update empty { access_rights } "
@@ -482,13 +484,13 @@ async def update_user_in_group(
482484 return GroupMember .model_validate (user )
483485
484486
485- async def delete_user_in_group (
487+ async def delete_user_from_group (
486488 app : web .Application ,
487489 connection : AsyncConnection | None = None ,
488490 * ,
489491 user_id : UserID ,
490492 gid : GroupID ,
491- the_user_id_in_group : int ,
493+ the_user_id_in_group : UserID ,
492494) -> None :
493495 async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
494496 # first check if the group exists
0 commit comments