Skip to content

Commit 4bfe4e7

Browse files
fix(hosts): empty inbound tag error when changing hosts proiority
1 parent 17dd003 commit 4bfe4e7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/db/crud/host.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sqlalchemy import select
66
from sqlalchemy.ext.asyncio import AsyncSession
77

8-
from app.db.models import ProxyInbound, ProxyHost
8+
from app.db.models import ProxyHost, ProxyInbound
99
from app.models.host import CreateHost
1010

1111

@@ -140,11 +140,16 @@ async def create_host(db: AsyncSession, new_host: CreateHost) -> ProxyHost:
140140

141141

142142
async def modify_host(db: AsyncSession, db_host: ProxyHost, modified_host: CreateHost) -> ProxyHost:
143-
host_data = modified_host.model_dump(exclude={"id"})
143+
host_data = modified_host.model_dump(exclude={"id", "inbound_tag"})
144144

145145
for key, value in host_data.items():
146146
setattr(db_host, key, value)
147147

148+
if not modified_host.inbound_tag:
149+
db_host.inbound = None
150+
else:
151+
db_host.inbound = await get_or_create_inbound(db, modified_host.inbound_tag)
152+
148153
await db.commit()
149154
await db.refresh(db_host)
150155
return db_host

0 commit comments

Comments
 (0)