feat(child): auto create parent-child conversations
This commit is contained in:
@@ -217,6 +217,28 @@ def create_parent_child_message(
|
||||
)
|
||||
|
||||
|
||||
def ensure_parent_child_conversation(
|
||||
db: Session,
|
||||
*,
|
||||
parent_user_id: int,
|
||||
child_id: int,
|
||||
) -> int:
|
||||
child_row = assert_parent_child_access(db, user_id=parent_user_id, child_id=child_id)
|
||||
parent_row = _get_parent_row(db, parent_user_id)
|
||||
if not parent_row:
|
||||
raise HTTPException(status_code=404, detail="parent not found")
|
||||
|
||||
return _get_or_create_conversation(
|
||||
db=db,
|
||||
conversation_type=PARENT_CHILD_CONVERSATION_TYPE,
|
||||
participant_a_type=CHILD_PARTICIPANT_TYPE,
|
||||
participant_a_id=str(child_id),
|
||||
participant_b_type=PARENT_PARTICIPANT_TYPE,
|
||||
participant_b_id=str(parent_user_id),
|
||||
pair_key=f"{child_id}:{parent_user_id}",
|
||||
)
|
||||
|
||||
|
||||
def create_device_message(
|
||||
db: Session,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user