import os print("🔧 [Patch Backend] Safely patching LinkedIn scopes list...") count = 0 for root, dirs, files in os.walk("/app"): if ".next" in root or "node_modules/.cache" in root: continue for f in files: if f.endswith(".js"): path = os.path.join(root, f) try: with open(path, "r", encoding="utf-8", errors="ignore") as file: content = file.read() modified = False # Remove prompt=none if "prompt=none" in content: content = content.replace("&prompt=none", "").replace("prompt=none&", "").replace("prompt=none", "") modified = True # Safely clean out organization and deprecated scopes from scope lists for scope in [ '"r_basicprofile",', '"rw_organization_admin",', '"w_organization_social",', '"r_organization_social",', ',"r_organization_social"', "'r_basicprofile',", "'rw_organization_admin',", "'w_organization_social',", "'r_organization_social',", ",'r_organization_social'", 'r_basicprofile ', 'rw_organization_admin ', 'w_organization_social ', 'r_organization_social' ]: if scope in content: content = content.replace(scope, "") modified = True if modified: with open(path, "w", encoding="utf-8") as file: file.write(content) count += 1 print(f" ✅ Safely Patched: {path}") except Exception: pass print(f"🔧 [Patch Backend] Successfully patched {count} files.")