Consistent relations, url property, src channel
This commit is contained in:
parent
873107f90d
commit
adc3474216
@ -2582,6 +2582,12 @@
|
|||||||
"source_guild": {
|
"source_guild": {
|
||||||
"$ref": "#/components/schemas/Guild"
|
"$ref": "#/components/schemas/Guild"
|
||||||
},
|
},
|
||||||
|
"source_channel_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"source_channel": {
|
||||||
|
"$ref": "#/components/schemas/Channel"
|
||||||
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -2597,9 +2603,10 @@
|
|||||||
"channel_id",
|
"channel_id",
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
"source_guild",
|
"source_channel",
|
||||||
"source_guild_id",
|
"source_channel_id",
|
||||||
"type",
|
"type",
|
||||||
|
"url",
|
||||||
"user",
|
"user",
|
||||||
"user_id"
|
"user_id"
|
||||||
]
|
]
|
||||||
@ -8741,7 +8748,7 @@
|
|||||||
"bearer": []
|
"bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Returns a webhook object for the given id.",
|
"description": "Returns a webhook object for the given id. Requires the MANAGE_WEBHOOKS permission or to be the owner of the webhook.",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "",
|
"description": "",
|
||||||
|
1584
assets/schemas.json
1584
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
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
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -53,13 +53,20 @@ router.get(
|
|||||||
where: { channel_id },
|
where: { channel_id },
|
||||||
relations: [
|
relations: [
|
||||||
"user",
|
"user",
|
||||||
|
"channel",
|
||||||
|
"source_channel",
|
||||||
"guild",
|
"guild",
|
||||||
"source_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,
|
||||||
|
})));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
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
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { route } from "@spacebar/api";
|
import { route } from "@spacebar/api";
|
||||||
import { Webhook } from "@spacebar/util";
|
import { Config, Webhook } from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@ -39,13 +39,20 @@ router.get(
|
|||||||
where: { guild_id },
|
where: { guild_id },
|
||||||
relations: [
|
relations: [
|
||||||
"user",
|
"user",
|
||||||
|
"channel",
|
||||||
|
"source_channel",
|
||||||
"guild",
|
"guild",
|
||||||
"source_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,
|
||||||
|
})));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,7 +34,14 @@ router.get(
|
|||||||
where: {
|
where: {
|
||||||
id: webhook_id,
|
id: webhook_id,
|
||||||
},
|
},
|
||||||
relations: ["channel", "guild", "application"],
|
relations: [
|
||||||
|
"user",
|
||||||
|
"channel",
|
||||||
|
"source_channel",
|
||||||
|
"guild",
|
||||||
|
"source_guild",
|
||||||
|
"application",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!webhook) {
|
if (!webhook) {
|
||||||
@ -65,6 +72,7 @@ const messageUpload = multer({
|
|||||||
}); // max upload 50 mb
|
}); // max upload 50 mb
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/webhook#execute-webhook
|
// https://discord.com/developers/docs/resources/webhook#execute-webhook
|
||||||
|
// TODO: GitHub/Slack compatible hooks
|
||||||
router.post(
|
router.post(
|
||||||
"/",
|
"/",
|
||||||
messageUpload.any(),
|
messageUpload.any(),
|
||||||
|
@ -11,7 +11,7 @@ const router = Router();
|
|||||||
router.get(
|
router.get(
|
||||||
"/",
|
"/",
|
||||||
route({
|
route({
|
||||||
description: "Returns a webhook object for the given id.",
|
description: "Returns a webhook object for the given id. Requires the MANAGE_WEBHOOKS permission or to be the owner of the webhook.",
|
||||||
responses: {
|
responses: {
|
||||||
200: {
|
200: {
|
||||||
body: "APIWebhook",
|
body: "APIWebhook",
|
||||||
@ -23,7 +23,14 @@ router.get(
|
|||||||
const { webhook_id } = req.params;
|
const { webhook_id } = req.params;
|
||||||
const webhook = await Webhook.findOneOrFail({
|
const webhook = await Webhook.findOneOrFail({
|
||||||
where: { id: webhook_id },
|
where: { id: webhook_id },
|
||||||
relations: ["channel", "guild", "application", "user"],
|
relations: [
|
||||||
|
"user",
|
||||||
|
"channel",
|
||||||
|
"source_channel",
|
||||||
|
"guild",
|
||||||
|
"source_guild",
|
||||||
|
"application",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (webhook.guild_id) {
|
if (webhook.guild_id) {
|
||||||
|
@ -85,13 +85,23 @@ export class Webhook extends BaseClass {
|
|||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((webhook: Webhook) => webhook.guild)
|
@RelationId((webhook: Webhook) => webhook.guild)
|
||||||
source_guild_id: string;
|
source_guild_id?: string;
|
||||||
|
|
||||||
@JoinColumn({ name: "source_guild_id" })
|
@JoinColumn({ name: "source_guild_id" })
|
||||||
@ManyToOne(() => Guild, {
|
@ManyToOne(() => Guild, {
|
||||||
onDelete: "CASCADE",
|
onDelete: "CASCADE",
|
||||||
})
|
})
|
||||||
source_guild: Guild;
|
source_guild?: Guild;
|
||||||
|
|
||||||
url?: string;
|
@Column({ nullable: true })
|
||||||
|
@RelationId((webhook: Webhook) => webhook.channel)
|
||||||
|
source_channel_id: string;
|
||||||
|
|
||||||
|
@JoinColumn({ name: "source_channel_id" })
|
||||||
|
@ManyToOne(() => Channel, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
})
|
||||||
|
source_channel: Channel;
|
||||||
|
|
||||||
|
url: string;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user