feat(privacy): add private-message permission toggle
This commit is contained in:
@@ -104,6 +104,12 @@ async def create_chat_for_user(db: AsyncSession, *, creator_id: int, payload: Ch
|
||||
detail="Private chat requires exactly one target user.",
|
||||
)
|
||||
if payload.type == ChatType.PRIVATE:
|
||||
target_user = await get_user_by_id(db, member_ids[0])
|
||||
if target_user and not target_user.allow_private_messages:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="User does not accept private messages",
|
||||
)
|
||||
if await has_block_relation_between_users(db, user_a_id=creator_id, user_b_id=member_ids[0]):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
|
||||
Reference in New Issue
Block a user