mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-05 18:32:33 +01:00
Delete connections
This commit is contained in:
parent
747ff5d322
commit
2bae842926
@ -1,5 +1,5 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { ConnectedAccount, DiscordApiErrors } from "@fosscord/util";
|
||||
import { ConnectedAccount, DiscordApiErrors, emitEvent } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
@ -44,4 +44,27 @@ router.patch(
|
||||
},
|
||||
);
|
||||
|
||||
router.delete("/", route({}), async (req: Request, res: Response) => {
|
||||
const { connection_name, connection_id } = req.params;
|
||||
|
||||
const account = await ConnectedAccount.findOneOrFail({
|
||||
where: {
|
||||
user_id: req.user_id,
|
||||
external_id: connection_id,
|
||||
type: connection_name,
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
ConnectedAccount.remove(account),
|
||||
emitEvent({
|
||||
event: "USER_CONNECTIONS_UPDATE",
|
||||
data: account,
|
||||
user_id: req.user_id,
|
||||
})
|
||||
]);
|
||||
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
Loading…
Reference in New Issue
Block a user