CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Implements PLAN.md Phase 9. internal/appservice reads registration files (appservice.config_files), matches namespaces the way Synapse does (anchored at the start), and delivers events to each service as transactions read from the roomserver's event stream at a cursor kept in appservice_state. A transaction in flight is recorded, so after a restart it is resent under the same ID; failures back off from 2s to 5m, and a successful ping cuts the backoff short. In the Client-Server API an as_token acts as the service's sender or, with ?user_id=, as any existing user in its namespace. Services register and log in their users with m.login.application_service; exclusive user and alias namespaces are refused to everybody else with M_EXCLUSIVE. Unknown aliases and users in a namespace are asked of the service first. The ping endpoint reports M_URL_NOT_SET, M_BAD_STATUS, M_CONNECTION_FAILED and M_CONNECTION_TIMEOUT. Services' own requests, and their users' when rate_limited is false, skip the rate limiter. Users can change their password (POST /account/password) and deactivate their account (POST /account/deactivate), both behind the password. Deactivation revokes tokens, deletes devices, optionally erases the profile and leaves every room through a new userapi.AccountObserver. The admin API is complete: user detail, the admin flag, deactivation and reactivation, password resets, devices, media quotas (media.max_user_storage_bytes plus per-user overrides), registration tokens with use limits and expiry (registration.require_token), server notices (internal/servernotices, server_notices.*), an editor for the federation allow/deny lists persisted in server_settings, a delivery view of the application services, and an audit log of every change. Migration 0011 adds the registration token, server notice room, media quota, audit log and appservice cursor tables. Policy lists are now returned sorted. The Complement entrypoint loads the registrations Complement mounts in /complement/appservice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.8 KiB
Go
79 lines
2.8 KiB
Go
package clientapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/dariuszjaniak/warp/server/internal/httputil"
|
|
"github.com/dariuszjaniak/warp/server/internal/matrix/roomversion"
|
|
"github.com/dariuszjaniak/warp/server/internal/userapi"
|
|
)
|
|
|
|
// DefaultRoomVersion is what this server creates rooms at. The room
|
|
// version registry decides which one that is, and why.
|
|
const DefaultRoomVersion = string(roomversion.Default)
|
|
|
|
// availableRoomVersions is the m.room_versions.available map.
|
|
//
|
|
// Every version Warp implements is marked stable, because every version
|
|
// the spec still lists is stable — the "unstable" marking is for versions
|
|
// under development, which we do not implement. Versions 1 and 2 are in
|
|
// the registry but not supported, and so are left out: a client offered a
|
|
// version it cannot be given would get an error on createRoom.
|
|
func availableRoomVersions() map[string]string {
|
|
supported := roomversion.Supported()
|
|
out := make(map[string]string, len(supported))
|
|
for _, v := range supported {
|
|
out[string(v)] = "stable"
|
|
}
|
|
return out
|
|
}
|
|
|
|
// roomVersionsCapability is the m.room_versions capability.
|
|
type roomVersionsCapability struct {
|
|
Default string `json:"default"`
|
|
Available map[string]string `json:"available"`
|
|
}
|
|
|
|
// booleanCapability is the shape of the several capabilities that are only
|
|
// an on/off switch.
|
|
type booleanCapability struct {
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
type capabilitiesResponse struct {
|
|
Capabilities capabilities `json:"capabilities"`
|
|
}
|
|
|
|
type capabilities struct {
|
|
RoomVersions roomVersionsCapability `json:"m.room_versions"`
|
|
ChangePassword booleanCapability `json:"m.change_password"`
|
|
SetDisplayName booleanCapability `json:"m.set_displayname"`
|
|
SetAvatarURL booleanCapability `json:"m.set_avatar_url"`
|
|
ThreePIDChanges booleanCapability `json:"m.3pid_changes"`
|
|
}
|
|
|
|
// handleCapabilities implements GET /_matrix/client/v3/capabilities.
|
|
//
|
|
// The endpoint needs a token: what a server will let you do depends on who
|
|
// you are, and the spec makes it authenticated for that reason.
|
|
//
|
|
// Every flag here is the truth about this build, not an aspiration.
|
|
// Third-party identifiers need an identity server, which Warp does not
|
|
// talk to, so they report false and clients hide the buttons rather than
|
|
// offering something that 404s.
|
|
func (c *ClientAPI) handleCapabilities(w http.ResponseWriter, _ *http.Request, _ userapi.Authenticated) error {
|
|
httputil.WriteJSON(w, http.StatusOK, capabilitiesResponse{
|
|
Capabilities: capabilities{
|
|
RoomVersions: roomVersionsCapability{
|
|
Default: DefaultRoomVersion,
|
|
Available: availableRoomVersions(),
|
|
},
|
|
ChangePassword: booleanCapability{Enabled: true},
|
|
SetDisplayName: booleanCapability{Enabled: true},
|
|
SetAvatarURL: booleanCapability{Enabled: true},
|
|
ThreePIDChanges: booleanCapability{Enabled: false},
|
|
},
|
|
})
|
|
return nil
|
|
}
|