chore: snapshot before performance optimization
This commit is contained in:
25
keep-notes/fix_api_labels.py
Normal file
25
keep-notes/fix_api_labels.py
Normal file
@@ -0,0 +1,25 @@
|
||||
with open('app/api/labels/[id]/route.ts', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Fix targetUserId logic
|
||||
content = content.replace(
|
||||
'if (name && name.trim() !== currentLabel.name && currentLabel.userId) {',
|
||||
'const targetUserIdPut = currentLabel.userId || currentLabel.notebook?.userId || session.user.id;\n if (name && name.trim() !== currentLabel.name && targetUserIdPut) {'
|
||||
)
|
||||
content = content.replace(
|
||||
'userId: currentLabel.userId,',
|
||||
'userId: targetUserIdPut,'
|
||||
)
|
||||
|
||||
content = content.replace(
|
||||
'if (label.userId) {',
|
||||
'const targetUserIdDel = label.userId || label.notebook?.userId || session.user.id;\n if (targetUserIdDel) {'
|
||||
)
|
||||
content = content.replace(
|
||||
'userId: label.userId,',
|
||||
'userId: targetUserIdDel,'
|
||||
)
|
||||
|
||||
with open('app/api/labels/[id]/route.ts', 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
Reference in New Issue
Block a user