feat(privacy): user blocklist with private chat enforcement
Some checks failed
CI / test (push) Failing after 21s
Some checks failed
CI / test (push) Failing after 21s
- add blocked_users table and migration - add users API: block, unblock, list blocked users - prevent private chat creation and private messaging when block relation exists - add block/unblock action in private chat info panel
This commit is contained in:
@@ -52,3 +52,21 @@ async def update_user_profile(
|
||||
await db.commit()
|
||||
await db.refresh(user)
|
||||
return user
|
||||
|
||||
|
||||
async def block_user(db: AsyncSession, *, user_id: int, blocked_user_id: int) -> None:
|
||||
await repository.block_user(db, user_id=user_id, blocked_user_id=blocked_user_id)
|
||||
await db.commit()
|
||||
|
||||
|
||||
async def unblock_user(db: AsyncSession, *, user_id: int, blocked_user_id: int) -> None:
|
||||
await repository.unblock_user(db, user_id=user_id, blocked_user_id=blocked_user_id)
|
||||
await db.commit()
|
||||
|
||||
|
||||
async def has_block_relation_between_users(db: AsyncSession, *, user_a_id: int, user_b_id: int) -> bool:
|
||||
return await repository.has_block_relation_between_users(db, user_a_id=user_a_id, user_b_id=user_b_id)
|
||||
|
||||
|
||||
async def list_blocked_users(db: AsyncSession, *, user_id: int) -> list[User]:
|
||||
return await repository.list_blocked_users(db, user_id=user_id)
|
||||
|
||||
Reference in New Issue
Block a user