refactor(issue-sync): streamline issue closing logic and enhance error handling
This commit is contained in:
parent
1076ca27bb
commit
11d950a13a
|
|
@ -694,7 +694,10 @@ async def close_issue(
|
|||
if auth.user is None:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
||||
|
||||
# Get boards linked to this issue's repository for this organization.
|
||||
# Check board links — used for authorization and activity logging.
|
||||
# If the repository is not linked to any board the user can still close
|
||||
# the issue (org membership is sufficient); we just skip the board-scoped
|
||||
# activity event.
|
||||
links = (
|
||||
await session.exec(
|
||||
select(BoardRepositoryLink).where(
|
||||
|
|
@ -703,12 +706,9 @@ async def close_issue(
|
|||
)
|
||||
)
|
||||
).all()
|
||||
if not links:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Issue repository is not linked to any board",
|
||||
)
|
||||
|
||||
authorized_board_id: object = None
|
||||
if links:
|
||||
allowed_board_ids = set(await list_accessible_board_ids(session, member=ctx.member, write=True))
|
||||
authorized_board_id = next(
|
||||
(link.board_id for link in links if link.board_id in allowed_board_ids),
|
||||
|
|
@ -735,6 +735,7 @@ async def close_issue(
|
|||
raise HTTPException(status_code=status.HTTP_502_BAD_GATEWAY, detail=str(e))
|
||||
|
||||
repository_full_name = str(result.get("repository_full_name") or "unknown/unknown")
|
||||
if authorized_board_id is not None:
|
||||
record_activity(
|
||||
session,
|
||||
event_type="forgejo.issue.closed",
|
||||
|
|
|
|||
Loading…
Reference in New Issue