MCPcopy Index your code
hub / github.com/hunvreus/devpush / github_install_callback

Function github_install_callback

app/routers/github.py:308–355  ·  view source on GitHub ↗

Handle GitHub App installation callback

(
    request: Request,
    installation_id: int,
    setup_action: str,
    current_user: User = Depends(get_current_user),
    github_service: GitHubService = Depends(get_github_service),
    db: AsyncSession = Depends(get_db),
)

Source from the content-addressed store, hash-verified

306
307@router.get("/install/callback", name="github_install_callback")
308async def github_install_callback(
309 request: Request,
310 installation_id: int,
311 setup_action: str,
312 current_user: User = Depends(get_current_user),
313 github_service: GitHubService = Depends(get_github_service),
314 db: AsyncSession = Depends(get_db),
315):
316 """Handle GitHub App installation callback"""
317 redirect_url = safe_redirect(
318 request,
319 next_value=request.session.pop("redirect_after_install", "/"),
320 referer=None,
321 )
322
323 if setup_action != "install":
324 flash(request, _("GitHub App installation was not completed."), "warning")
325 return RedirectResponse(redirect_url, status_code=303)
326
327 try:
328 # Make sure installation exists
329 await github_service.get_installation(str(installation_id))
330
331 result = await db.execute(
332 select(GithubInstallation).where(
333 GithubInstallation.installation_id == installation_id
334 )
335 )
336 existing_installation = result.scalar_one_or_none()
337
338 if existing_installation:
339 existing_installation.status = "active"
340 await db.commit()
341 flash(
342 request, _("GitHub App installation updated successfully!"), "success"
343 )
344 else:
345 github_installation = GithubInstallation(
346 installation_id=installation_id, status="active"
347 )
348 db.add(github_installation)
349 await db.commit()
350 flash(request, _("GitHub App installed successfully!"), "success")
351
352 except Exception:
353 flash(request, _("Error processing GitHub App installation."), "error")
354
355 return RedirectResponse(redirect_url, status_code=303)
356
357
358@router.get("/manage/authorization", name="github_manage_authorization")

Callers

nothing calls this directly

Calls 5

safe_redirectFunction · 0.90
flashFunction · 0.90
GithubInstallationClass · 0.90
get_installationMethod · 0.80
_Function · 0.50

Tested by

no test coverage detected