Consistent relations, url property, src channel

This commit is contained in:
TomatoCake
2024-07-18 15:35:10 +02:00
parent 873107f90d
commit adc3474216
7 changed files with 1362 additions and 308 deletions
+13 -6
View File
@@ -1,23 +1,23 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route } from "@spacebar/api";
import { Webhook } from "@spacebar/util";
import { Config, Webhook } from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();
@@ -39,13 +39,20 @@ router.get(
where: { guild_id },
relations: [
"user",
"channel",
"source_channel",
"guild",
"source_guild",
"application" /*"source_channel"*/,
"application",
],
});
return res.json(webhooks);
const instanceUrl =
Config.get().api.endpointPublic || "http://localhost:3001";
return res.json(webhooks.map(webhook => ({
...webhook,
url: instanceUrl + "/webhooks/" + webhook.id + "/" + webhook.token,
})));
},
);