Merge branch 'master' of github.com:fosscord/fosscord-server

This commit is contained in:
Madeline 2023-03-19 22:08:28 +11:00
commit 1fd01fa000
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
19 changed files with 46 additions and 30 deletions

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,15 +0,0 @@
# Fosscord env vars:
| Name | Value | Description |
| ---------------- | -------------- | --------------------------------------------------------------- |
| THREADS | number | Number of threads to run Fosscord on when using bundle. |
| PORT | number | Port to listen on |
| DATABASE | string | Database connection string. Defaults to SQlite3 at project root |
| CONFIG_PATH | string | File path for JSON config, if not using `config` db table |
| WS_LOGEVENTS | boolean | If set, log websocket events from gateway |
| CDN | string | Lowest priority value for public CDN annoucements |
| GATEWAY | string | Lowest priority value for public gateway annoucements |
| STORAGE_LOCATION | string | CDN storage location. File path or S3 bucktet |
| STORAGE_PROVIDER | "s3" or "file" | CDN storage provider |
| STORAGE_BUCKET | string | S3 bucket name |
| STORAGE_REGION | string | S3 storage region |

15
package-lock.json generated
View File

@ -46,6 +46,7 @@
"probe-image-size": "^7.2.3", "probe-image-size": "^7.2.3",
"proxy-agent": "^5.0.0", "proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.5",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tslib": "^2.4.1", "tslib": "^2.4.1",
"typeorm": "^0.3.10", "typeorm": "^0.3.10",
@ -84,7 +85,7 @@
"nodemailer-mailgun-transport": "^2.1.5", "nodemailer-mailgun-transport": "^2.1.5",
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport", "nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport", "nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
"sqlite3": "^5.1.4" "sqlite3": "^5.1.5"
} }
}, },
"node_modules/@acuminous/bitsyntax": { "node_modules/@acuminous/bitsyntax": {
@ -7077,9 +7078,9 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
}, },
"node_modules/sqlite3": { "node_modules/sqlite3": {
"version": "5.1.4", "version": "5.1.5",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.4.tgz", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.5.tgz",
"integrity": "sha512-i0UlWAzPlzX3B5XP2cYuhWQJsTtlMD6obOa1PgeEQ4DHEXUuyJkgv50I3isqZAP5oFc2T8OFvakmDh2W6I+YpA==", "integrity": "sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==",
"hasInstallScript": true, "hasInstallScript": true,
"optional": true, "optional": true,
"dependencies": { "dependencies": {
@ -13560,9 +13561,9 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
}, },
"sqlite3": { "sqlite3": {
"version": "5.1.4", "version": "5.1.5",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.4.tgz", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.5.tgz",
"integrity": "sha512-i0UlWAzPlzX3B5XP2cYuhWQJsTtlMD6obOa1PgeEQ4DHEXUuyJkgv50I3isqZAP5oFc2T8OFvakmDh2W6I+YpA==", "integrity": "sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==",
"optional": true, "optional": true,
"requires": { "requires": {
"@mapbox/node-pre-gyp": "^1.0.0", "@mapbox/node-pre-gyp": "^1.0.0",

View File

@ -118,6 +118,6 @@
"nodemailer-mailgun-transport": "^2.1.5", "nodemailer-mailgun-transport": "^2.1.5",
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport", "nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport", "nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
"sqlite3": "^5.1.4" "sqlite3": "^5.1.5"
} }
} }

View File

@ -135,7 +135,9 @@ export class FosscordServer extends Server {
app.use("/api/v9", api); app.use("/api/v9", api);
app.use("/api", api); // allow unversioned requests app.use("/api", api); // allow unversioned requests
app.get("/", express.static(PUBLIC_ASSETS_FOLDER)); app.get("/", (req, res) =>
res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")),
);
this.app.use(ErrorHandler); this.app.use(ErrorHandler);

View File

@ -23,12 +23,23 @@ import { HTTPError } from "lambert-server";
import { join } from "path"; import { join } from "path";
const defaultAvatarHashMap = new Map([ const defaultAvatarHashMap = new Map([
["0", "1f0bfc0865d324c2587920a7d80c609b"], ["0", "823a3de61c4dc2415cc4dbc38fca4299"],
["1", "c09a43a372ba81e3018c3151d4ed4773"], ["1", "e56a89224be0b2b1f7c04eca975be468"],
["2", "7c8f476123d28d103efe381543274c25"], ["2", "0c8138dcc0dfe2689cdd73f7952c2475"],
["3", "6f26ddd1bf59740c536d2274bb834a05"], ["3", "5ac2728593bb455250d11b848a0c36c6"],
["4", "3c6ccb83716d1e4fb91d3082f6b21d77"], ["4", "addd2f3268df46459e1d6012ad8e75bd"],
["5", "4c1b599b1ef5b9f1874fdb9933f3e03b"], ["5", "c4e0c8300fa491d94acfd2a1fb26cea8"],
]);
const defaultGroupDMAvatarHashMap = new Map([
["0", "3b70bb66089c60f8be5e214bf8574c9d"],
["1", "9581acd31832465bdeaa5385b0e919a3"],
["2", "a8a4727cf2dc2939bd3c657fad4463fa"],
["3", "2e46fe14586f8e95471c0917f56726b5"],
["4", "fac7e78de9753d4a37083bba74c1d9ef"],
["5", "4ab900144b0865430dc9be825c838faa"],
["6", "1276374a404452756f3c9cc2601508a5"],
["7", "904bf9f1b61f53ef4a3b7a893afeabe3"],
]); ]);
const router = Router(); const router = Router();
@ -64,4 +75,21 @@ router.get("/avatars/:id", async (req: Request, res: Response) => {
return res.send(file); return res.send(file);
}); });
router.get("/group-avatars/:id", async (req: Request, res: Response) => {
let { id } = req.params;
id = id.split(".")[0]; // remove .file extension
const hash = defaultGroupDMAvatarHashMap.get(id);
if (!hash) throw new HTTPError("not found", 404);
const path = join(process.cwd(), "assets", "public", `${hash}.png`);
const file = await getFile(path);
if (!file) throw new HTTPError("not found", 404);
const type = await FileType.fromBuffer(file);
res.set("Content-Type", type?.mime);
res.set("Cache-Control", "public, max-age=31536000");
return res.send(file);
});
export default router; export default router;