+
+
+
\ No newline at end of file
diff --git a/src/api/Server.ts b/src/api/Server.ts
index d371ed9c4..5039b1542 100644
--- a/src/api/Server.ts
+++ b/src/api/Server.ts
@@ -24,6 +24,7 @@ import morgan from "morgan";
import path from "path";
import { red } from "picocolors";
import { initInstance } from "./util/handlers/Instance";
+import fs from "fs/promises";
const ASSETS_FOLDER = path.join(__dirname, "..", "..", "assets");
const PUBLIC_ASSETS_FOLDER = path.join(ASSETS_FOLDER, "public");
@@ -129,6 +130,13 @@ export class SpacebarServer extends Server {
return res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "widget.html"));
});
+ app.get("/invite/:code", async (req, res) => {
+ const { code } = req.params;
+ const content = fs.readFile(path.join(PUBLIC_ASSETS_FOLDER, "invite.html"), "utf-8");
+ res.set("Cache-Control", "public, max-age=21600");
+ return res.send((await content).replace("{code}", code).replace("{serverName}", Config.get().general.serverName));
+ });
+
app.get("/_spacebar/api/schemas.json", (req, res) => {
res.sendFile(path.join(ASSETS_FOLDER, "schemas.json"));
});
diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts
index 0d5daa4cc..baf77af37 100644
--- a/src/api/routes/channels/#channel_id/attachments.ts
+++ b/src/api/routes/channels/#channel_id/attachments.ts
@@ -81,7 +81,7 @@ router.post(
userIsClip: attachment.is_clip,
userOriginalContentType: attachment.original_content_type,
});
- await newAttachment.save();
+ await newAttachment.insert();
return newAttachment;
}),
);
@@ -91,7 +91,7 @@ router.post(
return {
id: a.userAttachmentId,
upload_filename: a.uploadFilename,
- upload_url: `${cdnUrl}/attachments/${a.uploadFilename}`,
+ upload_url: `${cdnUrl}/_spacebar/cdn/cloud-attachments/${a.uploadFilename}`,
original_content_type: a.userOriginalContentType,
};
}),
@@ -119,7 +119,7 @@ router.delete("/:cloud_attachment_url", async (req: Request, res: Response) => {
});
}
- const response = await fetch(`${Config.get().cdn.endpointPrivate}/attachments/${att.uploadFilename}`, {
+ const response = await fetch(`${Config.get().cdn.endpointPrivate}/_spacebar/cdn/cloud-attachments/${att.uploadFilename}`, {
headers: {
signature: Config.get().security.requestSignature,
},
diff --git a/src/api/routes/guilds/#guild_id/widget.png.ts b/src/api/routes/guilds/#guild_id/widget.png.ts
index 3ff95e995..48c8d22c9 100644
--- a/src/api/routes/guilds/#guild_id/widget.png.ts
+++ b/src/api/routes/guilds/#guild_id/widget.png.ts
@@ -24,7 +24,7 @@ import { Request, Response, Router } from "express";
import fs from "fs";
import { HTTPError } from "lambert-server";
import path from "path";
-import { storage } from "../../../../cdn/util/Storage";
+import { storage } from "@spacebar/cdn";
const router: Router = Router({ mergeParams: true });
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 766abd13f..741fe82cb 100644
--- a/src/api/util/handlers/Message.ts
+++ b/src/api/util/handlers/Message.ts
@@ -118,7 +118,7 @@ export async function handleMessage(opts: MessageOptions): Promise