Self-hosted multi-platform broadcast newsroom for activist collectives: publishing pipeline with group approval and DST-proof scheduling, TweetDeck-style column wall with hostile-content-safe rendering, live control room with Auto Director, bridged chat governance with polls and quorum, distributed sandboxed transcode workers, encrypted content-addressed archive, monthly analytics. MIT licensed. See README.md and docs/.
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import type { ConnectorConnection } from "@tactical-media-broadcast-hub/core";
|
|
import { connectorContractTests } from "@tactical-media-broadcast-hub/connector-sdk/testing";
|
|
import { createDiscordConnector } from "./index.js";
|
|
|
|
const connection: ConnectorConnection = {
|
|
id: "conn-discord",
|
|
workspaceId: "ws-1",
|
|
provider: "discord",
|
|
channelId: "120000000000000002",
|
|
credentialId: { kind: "credential-ref", id: "cred-discord" },
|
|
fields: {
|
|
botToken: "discord-test-token",
|
|
guildId: "120000000000000001",
|
|
},
|
|
createdAt: new Date(),
|
|
};
|
|
|
|
const fetchImpl: typeof fetch = async (input, init): Promise<Response> => {
|
|
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
if (url === "https://discord.com/api/v10/users/@me") {
|
|
if (new Headers(init?.headers).get("authorization") !== "Bot discord-test-token") {
|
|
return new Response(JSON.stringify({ message: "401: Unauthorized" }), { status: 401 });
|
|
}
|
|
return new Response(JSON.stringify({
|
|
id: "120000000000000003",
|
|
username: "anarchoposter",
|
|
global_name: "AnarchoPoster",
|
|
avatar: null,
|
|
}));
|
|
}
|
|
return new Response(JSON.stringify({ message: `unexpected request: ${url}` }), { status: 404 });
|
|
};
|
|
|
|
connectorContractTests(createDiscordConnector({ fetchImpl }), { connection });
|