diff --git a/docs/api.md b/docs/api.md deleted file mode 100644 index 98a6d1f..0000000 --- a/docs/api.md +++ /dev/null @@ -1,52 +0,0 @@ -# API - -There is a web API for getting information about things that are bridged with Out Of Your Element. - -The base URL is the URL of the particular OOYE instance, for example, https://bridge.cadence.moe. - -No authentication is required. - -I'm happy to add more endpoints, just ask for them. - -## Endpoint: GET /api/message - -|Query parameter|Type|Description| -|---------------|----|-----------| -|`message_id`|regexp `/^[0-9]+$/`|Discord message ID to look up information for| - -Response: - -```typescript -{ - source: "matrix" | "discord" // Which platform the message originated on - matrix_author?: { // Only for Matrix messages; should be up-to-date rather than historical data - displayname: string, // Matrix user's current display name - avatar_url: string, // Absolute HTTP(S) URL to download the Matrix user's current avatar - mxid: string // Matrix user ID, can never change - }, - events: [ // Data about each individual event - { - metadata: { // Data from OOYE's database about how bridging was performed - sender: string, // Same as matrix user ID - event_id: string, // Unique ID of the event on Matrix, can never change - event_type: "m.room.message" | "m.sticker" | string, // Event type - event_subtype: "m.text" | "m.image" | "m.audio" | "m.video" | "m.file" | string | null, // For m.room.message events, this is the msgtype property - part: 0 | 1, // 0 if this is the first "part" of the message (e.g. this would be the text of a text message with an attachment) - reaction_part: 0 | 1, // 0 if this is the last "part" of the message (e.g. this would be the attachment of a text message with an attachment) - room_id: string, // Room ID that the event was sent in, linked to the Discord channel - source: number - }, - raw: { // Raw historical event data from the Matrix API. Contains at least these properties, but highly depends on what the client sent - content: any, // The only non-metadata property, entirely client-generated - type: string, - room_id: string, - sender: string, - origin_server_ts: number, - unsigned?: any, - event_id: string, - user_id: string - } - } - ] -} -``` diff --git a/src/web/routes/info.js b/src/web/routes/info.js index 0ccdeca..b70ef84 100644 --- a/src/web/routes/info.js +++ b/src/web/routes/info.js @@ -4,9 +4,6 @@ const {z} = require("zod") const {defineEventHandler, getValidatedQuery, H3Event} = require("h3") const {as, from, sync, select} = require("../../passthrough") -/** @type {import("../../m2d/converters/utils")} */ -const mUtils = sync.require("../../m2d/converters/utils") - /** * @param {H3Event} event * @returns {import("../../matrix/api")} @@ -56,8 +53,7 @@ as.router.get("/api/message", defineEventHandler(async event => { } } if (!matrix_author.displayname) matrix_author.displayname = mxid - if (matrix_author.avatar_url) matrix_author.avatar_url = mUtils.getPublicUrlForMxc(matrix_author.avatar_url) - else matrix_author.avatar_url = null + if (!matrix_author.avatar_url) matrix_author.avatar_url = null matrix_author["mxid"] = mxid }