Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion docs/backend/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Community features

# Community features

Badges, milestone notifications and the development feed.
Badges, milestone notifications, organisations and the development feed.

## Badges

Expand Down Expand Up @@ -36,6 +36,29 @@ MistWarp sends one-time notifications at 5, 25, 50, 100, 500, and 1,000 likes or

Project and community reactions check milestones when saved. Profile-post, theme, and follower checks read existing public APIs and keep their state in MistWarp. The client requests a check after a like or follow; opening the inbox also checks the current account's followers. These sampled counts can detect a threshold crossed between visits, but cannot detect a count that rose and fell entirely between checks. Existing counts establish a baseline without sending every earlier milestone. No Rotur or WarpTheme server changes are required.

## Organisations

A Rotur organisation is a Rotur account with `account_type: "org"`. It can own MistWarp projects and spaces directly: the record's `owner` is the organisation's username, `ownerId` its Rotur id, and `ownerType` is `"org"`. Projects and spaces made by a person have an empty `ownerType`.

Members of the organisation whose Rotur permissions include `apps` or `admin` are its publishers. A publisher can create projects and spaces for the organisation (send `org: "<name>"` when creating), move their own content into it (an ownership transfer to the organisation's name), and manage or delete anything it owns, as if they were the owner. Moving the organisation's content out of it, to a person or another organisation, needs an organisation admin; project and space responses say whether the viewer may with `canMoveOut`. Billing-only and plain members cannot do any of this. Site admins always can. A publisher only manages content whose `ownerId` matches the organisation's current Rotur id, so a new organisation that later takes a freed name gets none of the old one's content.

Content an organisation owns uses the organisation's own Rotur plan for its limits and paid features (branding, vanity URLs, analytics history), not the plan of the publisher editing it.

Organisation content is looked up by the organisation's Rotur id, so renaming an organisation keeps its content and publishers. Before asking Rotur about an organisation, MistWarp checks the viewer's own organisation list, so pages with many organisations' spaces cost one Rotur request per viewer, not one per organisation.

MistWarp asks Rotur who is in an organisation with `COMMERCE_SERVICE_KEY`, through `GET /v2/integrations/mistwarp/orgs/:name` (the organisation and every member with their permissions, including members who are not listed publicly) and `GET /v2/integrations/mistwarp/users/:id/orgs` (a person's organisations). On Rotur's side that key is the `mistwarp` entry of its `COMMERCE_SERVICE_KEYS`. Rotur leaves out members who cannot sign in (banned, suspended or age-restricted), so they stop publishing for the organisation. Answers are cached for a minute. When Rotur cannot be reached, creating for an organisation, editing its projects and moving content into or out of it answer 503 `rotur_unavailable` instead of refusing. That includes a move to an account whose Rotur profile says it is an organisation when its members cannot be read. If Rotur says that organisation cannot act (it is banned, suspended or age-restricted), the move is refused with 403 `org_unavailable`. Scoring, voting for or reviewing an organisation's content also answers 503 while MistWarp cannot tell whether the person publishes for it, so publishers cannot rate their own work during an outage. Leaving a challenge after entering an organisation's project, or removing that entry yourself, answers 503 the same way. Because these checks can wait on Rotur, space changes are saved against a fresh copy of the space: an edit answers 409 `space_changed` when the owner changed in the meantime, and scores, votes, joins, leaves and result publishing answer 409 `challenge_changed` when the challenge moved on (a new phase, a removed judge or changed criteria). Reload and try again. Other actions on an organisation's content are refused until Rotur answers again.

Creating for an organisation can be refused with `code`: `org_not_found` (400, the name is not an organisation), `org_forbidden` (403, the person does not publish for it) or `rotur_unavailable` (503).

| Route | What it returns |
| --- | --- |
| `GET /v1/orgs/:name` | `{org, members, projects, spaces, isMember, canManage}`. `projects` and `spaces` hold the 100 most recently edited. `members` lists only publicly listed members unless the viewer is a member or a site admin. Unshared projects and unlisted or private spaces are included only for publishers |
| `GET /v1/me/orgs` | `{orgs: [{username, displayName, perms, canPublish}]}` for the signed-in person |

Notifications about content an organisation owns (loves, comments, remixes, reviews, contributions, sales, challenge entries and moderation) go to each of its publishers, up to 25 of them. The same event about the same content is sent once every ten minutes, so toggling a love does not repeat it. Sales are the exception: every purchase is sent. When a publisher enters an organisation's project in a challenge, the publisher, not the organisation, is recorded as the participant. On a challenge an organisation owns, its publishers are judges as well as anyone invited. `judges` lists the publicly listed ones, and `judgeCount` counts all of them.

The Rotur groups integration (`/v1/groups/:tag` and the `groupTag` field) was removed. Organisations replace it.

## Development feed

`/v1/development/pulls` lists MistWarp's own open and recently merged pull requests, and `/v1/roadmap` resolves the ones linked to each entry.
Expand Down
2 changes: 1 addition & 1 deletion docs/backend/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The server loads `.env` from the directory it runs in. A value is looked up in t
| APP_URL | https://api.mistwarp.org | Public URL of this API |
| ROTUR_BASE | https://api.rotur.dev | The public Rotur API, for sign-in, profiles, plans, notifications and the apps API |
| ROTUR_APP_KEY | mistwarp | The old validator key, for editors that predate validators keyed to the Rotur App |
| COMMERCE_SERVICE_KEY | | Key registered for `mistwarp` in Rotur's `COMMERCE_SERVICE_KEYS`. Only bounty awards and the groups integration still use it |
| COMMERCE_SERVICE_KEY | | Key registered for `mistwarp` in Rotur's `COMMERCE_SERVICE_KEYS`. Bounty awards and the organisation lookups (`/v2/integrations/mistwarp/...`) use it |
| ROTUR_CLIENT_ID | | The MistWarp Rotur App's client ID (`app_1938b6a87799f862`). With the secret, mistwarp-api calls the apps API as MistWarp |
| ROTUR_CLIENT_SECRET | | One of the MistWarp Rotur App's secrets, made with **New secret** on rotur.dev/me/developer |
| MISTWARP_ROTUR_USER | | Rotur account that gets MistWarp's share of game product sales. Without it, the MistWarp Rotur App's owner gets it |
Expand Down
2 changes: 1 addition & 1 deletion docs/backend/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The API needs OSL 3.0. `opal.json` lists the usual commands:
| `git` | Git inspection, pull requests and Rotur Git |
| `games` | Game saves, inventories and marketplace products |
| `realtime` | The multiplayer and site WebSockets |
| `community` | Spaces, roadmap, comments, bounties, profiles, news, notifications, milestones, standing, reports, groups |
| `community` | Spaces, roadmap, comments, bounties, profiles, news, notifications, milestones, standing, reports, organisations |
| `admin` | Admin tools, bans and shadow bans, moderation, error reports, funnel events |
| `classroom` | MistWarp Classroom |
| `rotur` | The Rotur App, plans and perks, payments, signals, badges and webhooks |
Expand Down
4 changes: 2 additions & 2 deletions docs/backend/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Upload callers hold the project's save lock (`project-history-<id>`). History pr

A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=<index>&pullTarget=<id>` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=<index>` also requires a signed-in editor of the target project or the owner of the remix.

`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats the source-visibility check, both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`.
`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats the source-visibility check, both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and organisation publishers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`.

`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, targetProjectId, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from <original title>`, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with:
`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and organisation publishers who can edit it) and see inside both projects may call it. It answers `{merge, targetProjectId, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from <original title>`, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with:

- 404 when the project is not a remix, or its original no longer exists.
- 403 for anyone else, or once the original's source is no longer visible to the caller.
Expand Down
Loading