REST API: Create private issue & foundational work #168

Closed
opened 2025-09-08 11:16:11 +00:00 by nilsph · 2 comments
nilsph commented 2025-09-08 11:16:11 +00:00 (Migrated from codeberg.org)

Story

As a user of Forgejo,
I want to create private issues via the REST API,
so I can work on private issues using the web API.

Acceptance Criteria

  • Data structures are adapted for private issues.
  • Internal API is adapted to accommodate both. #329
  • A migration exists which modifies the DB schema appropriately. Tables should be created properly on a new installation, but existing installations should get new columns etc.
  • Functions and methods used for creating public issues are adapted so they can create either.

Background

  • This contains foundational work for everything else, I’ll probably refine AC and maybe will create new tickets as things become clearer.
  • Upstream wants separate tables for public issues (that exist already) and private issues (that don’t).
  • XORM maps one type to one database table XORM can dispatch one type to multiple tables via the Table()/TableName() methods => yet we need two types for public and private issues (the existing Issue is public, the new PrivateIssue will contain private ones), at least for querying via XORM Engine’s Find() method. However, this throws off many internal mechanisms of XORM (which creates variables of the same type internally when e.g. querying tables but gets things wrong when it comes to columns that need to be set one way or the other for the type to make sense).
  • Previously, upstream suggested to add a boolean attribute IsPublic so that it would default to false if unset. However, this throws off so much of the existing code base that I suggested the opposite (IsPrivate) because XORM lets us validate or set things on the "load from or store into DB" boundary through AfterLoad(), BeforeInsert(), BeforeUpdate() methods (and we can easily control this on the boundary where we convert one type into the other). This way we can a) ensure that a private issue is only stored in the DB through the PrivateIssue type (and let Issue refuse to do so for variables which represent a private issue and vice versa) and b) set IsPrivate accordingly when loading so we don’t have to store it in the DB (the fact that an issue is stored in one or the other table is information enough). They asked me to implement unit tests verifying this behavior (to ensure XORM does as it advertises), but I would do that anyway.
# Story As a user of Forgejo, I want to create private issues via the REST API, so I can work on private issues using the web API. # Acceptance Criteria - [x] Data structures are adapted for private issues. - [x] Internal API is adapted to accommodate both. #329 - [x] A migration exists which modifies the DB schema appropriately. Tables should be created properly on a new installation, but existing installations should get new columns etc. - [x] Functions and methods used for creating public issues are adapted so they can create either. # Background - This contains foundational work for everything else, I’ll probably refine AC and maybe will create new tickets as things become clearer. - Upstream wants separate tables for public issues (that exist already) and private issues (that don’t). - ~~XORM maps one type to one database table~~ XORM can dispatch one type to multiple tables via the Table()/TableName() methods => yet we need two types for public and private issues (the existing `Issue` is public, the new `PrivateIssue` will contain private ones), at least for querying via XORM Engine’s Find() method. **However**, this throws off many internal mechanisms of XORM (which creates variables of the same type internally when e.g. querying tables but gets things wrong when it comes to columns that need to be set one way or the other for the type to make sense). - Previously, upstream suggested to add a boolean attribute `IsPublic` so that it would default to `false` if unset. However, this throws off so much of the existing code base that I suggested the opposite (`IsPrivate`) because XORM lets us validate or set things on the "load from or store into DB" boundary through `AfterLoad()`, `BeforeInsert()`, `BeforeUpdate()` methods (and we can easily control this on the boundary where we convert one type into the other). This way we can a) ensure that a private issue is only stored in the DB through the `PrivateIssue` type (and let `Issue` refuse to do so for variables which represent a private issue and vice versa) and b) set `IsPrivate` accordingly when loading so we don’t have to store it in the DB (the fact that an issue is stored in one or the other table is information enough). They asked me to implement unit tests verifying this behavior (to ensure XORM does as it advertises), but I would do that anyway.
ryanlerch added this to the Sprint 12 project 2025-11-03 04:07:04 +00:00
ryanlerch modified the project from Sprint 12 to Backlog 2025-11-03 04:10:21 +00:00
nphilipp modified the project from Backlog to Sprint 12 2025-11-17 10:29:10 +00:00
Member

As discussed, bumping story points because this proved to be more involved than initially estimated.

As discussed, bumping story points because this proved to be more involved than initially estimated.
humaton modified the project from Sprint 12 to Sprint 13 2026-01-26 10:44:00 +00:00
Member

Implemented in my feature branch, in "feat: Private Issues: Foundational changes" and "feat: Private Issues: Allow creating through API".

Implemented in [my feature branch](https://codeberg.org/nilsph/forgejo/src/branch/forgejo--private-issues), in "feat: Private Issues: Foundational changes" and "feat: Private Issues: Allow creating through API".
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
Reference
forge/forge#168
No description provided.