fix(relationship): fix add friends

This commit is contained in:
MingxuanGame
2025-07-28 16:03:33 +00:00
parent 0cba7e9dd2
commit 727943faad

View File

@@ -70,7 +70,8 @@ async def add_relationship(
type=relationship_type, type=relationship_type,
) )
db.add(relationship) db.add(relationship)
if relationship.type == RelationshipType.BLOCK: origin_type = relationship.type
if origin_type == RelationshipType.BLOCK:
target_relationship = ( target_relationship = (
await db.exec( await db.exec(
select(Relationship).where( select(Relationship).where(
@@ -81,13 +82,14 @@ async def add_relationship(
).first() ).first()
if target_relationship and target_relationship.type == RelationshipType.FOLLOW: if target_relationship and target_relationship.type == RelationshipType.FOLLOW:
await db.delete(target_relationship) await db.delete(target_relationship)
current_user_id = current_user.id
await db.commit() await db.commit()
if relationship.type == RelationshipType.FOLLOW: if origin_type == RelationshipType.FOLLOW:
relationship = ( relationship = (
await db.exec( await db.exec(
select(Relationship) select(Relationship)
.where( .where(
Relationship.user_id == current_user.id, Relationship.user_id == current_user_id,
Relationship.target_id == target, Relationship.target_id == target,
) )
.options( .options(