feat: Add discovery endpoints for bots and servers

Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
This commit is contained in:
Jacob Schlecht
2026-08-25 22:09:18 -06:00
parent a59560aaa8
commit 9fba9ca7d2
2 changed files with 58 additions and 1 deletions
+28 -1
View File
@@ -1,4 +1,4 @@
import type { DataEditBot } from "stoat-api";
import type { DataEditBot, DiscoverRequest } from "stoat-api";
import { decodeTime } from "ulid";
import type { BotCollection } from "../collections/BotCollection.js";
@@ -158,4 +158,31 @@ export class Bot {
await this.#collection.client.api.delete(`/bots/${this.id as ""}`);
this.#collection.delete(this.id);
}
/**
* Add bot to the discover request queue
*/
async requestDiscover(): Promise<void> {
await this.#collection.client.api.put(`/bots/${this.id as ""}/discover`);
}
/**
* Get the status of the discover request for this bot
* @returns The discovery request for this bot if one exists
*/
async discoverRequestStatus(): Promise<DiscoverRequest> {
return await this.#collection.client.api.get(
`/bots/${this.id as ""}/discover`,
);
}
/**
* Cancel the discover request for this bot
*
* This cannot be used to remove bots from discover that have already been accepted
* and should only be called on bots that have an outstanding discover request.
*/
async cancelDiscoverRequest() {
await this.#collection.client.api.delete(`/bots/${this.id as ""}/discover`);
}
}
+30
View File
@@ -14,6 +14,7 @@ import type {
DataCreateServerChannel,
DataEditRole,
DataEditServer,
DiscoverRequest,
Override,
Role,
} from "stoat-api";
@@ -852,4 +853,33 @@ export class Server {
return highest;
}
/**
* Add server to the discover request queue
*/
async requestDiscover(): Promise<void> {
await this.#collection.client.api.put(`/servers/${this.id as ""}/discover`);
}
/**
* Get the status of the discover request for this server
* @returns The discovery request for this server if one exists
*/
async discoverRequestStatus(): Promise<DiscoverRequest> {
return await this.#collection.client.api.get(
`/servers/${this.id as ""}/discover`,
);
}
/**
* Cancel the discover request for this server
*
* This cannot be used to remove servers from discover that have already been accepted
* and should only be called on servers that have an outstanding discover request.
*/
async cancelDiscoverRequest() {
await this.#collection.client.api.delete(
`/servers/${this.id as ""}/discover`,
);
}
}