summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/package-lock.json14
-rw-r--r--api/package.json2
-rw-r--r--api/src/routes/users/@me/settings.ts5
-rw-r--r--api/src/util/Instance.ts5
-rw-r--r--api/tests/routes.test.ts2
5 files changed, 15 insertions, 13 deletions
diff --git a/api/package-lock.json b/api/package-lock.json

index d33c54af..c78d3248 100644 --- a/api/package-lock.json +++ b/api/package-lock.json
@@ -29,7 +29,7 @@ "image-size": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.12", - "missing-native-js-functions": "^1.2.17", + "missing-native-js-functions": "^1.2.18", "morgan": "^1.10.0", "multer": "^1.4.2", "node-fetch": "^2.6.1", @@ -13177,9 +13177,9 @@ } }, "node_modules/missing-native-js-functions": { - "version": "1.2.17", - "resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.17.tgz", - "integrity": "sha512-Ev48VaLqp/7e7zmQ78oMCeMeZEUDeRRQGXITmiHtS62qJEThBLuKFExQjwu0Yzj9UO4MhN7TvljDsITCTu3fqg==" + "version": "1.2.18", + "resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.18.tgz", + "integrity": "sha512-TZr1muzDE4kfu0LHDzg63O7m2qW3Gpyc875ki8+YlSRj+4ibZRv0ySQ0cSB06GoBL9ejeehLmkQnybLpp9jYcg==" }, "node_modules/mkdirp": { "version": "0.5.5", @@ -25914,9 +25914,9 @@ } }, "missing-native-js-functions": { - "version": "1.2.17", - "resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.17.tgz", - "integrity": "sha512-Ev48VaLqp/7e7zmQ78oMCeMeZEUDeRRQGXITmiHtS62qJEThBLuKFExQjwu0Yzj9UO4MhN7TvljDsITCTu3fqg==" + "version": "1.2.18", + "resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.18.tgz", + "integrity": "sha512-TZr1muzDE4kfu0LHDzg63O7m2qW3Gpyc875ki8+YlSRj+4ibZRv0ySQ0cSB06GoBL9ejeehLmkQnybLpp9jYcg==" }, "mkdirp": { "version": "0.5.5", diff --git a/api/package.json b/api/package.json
index af587cb6..1d1386d2 100644 --- a/api/package.json +++ b/api/package.json
@@ -82,7 +82,7 @@ "image-size": "^1.0.0", "jsonwebtoken": "^8.5.1", "lambert-server": "^1.2.12", - "missing-native-js-functions": "^1.2.17", + "missing-native-js-functions": "^1.2.18", "morgan": "^1.10.0", "multer": "^1.4.2", "node-fetch": "^2.6.1", diff --git a/api/src/routes/users/@me/settings.ts b/api/src/routes/users/@me/settings.ts
index 4e014126..b22b72fb 100644 --- a/api/src/routes/users/@me/settings.ts +++ b/api/src/routes/users/@me/settings.ts
@@ -10,8 +10,9 @@ router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, re const body = req.body as UserSettings; if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale - // only users can update user settings - await User.update({ id: req.user_id, bot: false }, { settings: body }); + const user = await User.findOneOrFail({ id: req.user_id, bot: false }); + user.settings = { ...user.settings, ...body }; + await user.save(); res.sendStatus(204); }); diff --git a/api/src/util/Instance.ts b/api/src/util/Instance.ts
index 7dcd126e..6bddfa98 100644 --- a/api/src/util/Instance.ts +++ b/api/src/util/Instance.ts
@@ -1,4 +1,4 @@ -import { Config, Guild } from "@fosscord/util"; +import { Config, Guild, Session } from "@fosscord/util"; export async function initInstance() { // TODO: clean up database and delete tombstone data @@ -15,4 +15,7 @@ export async function initInstance() { await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } }); } } + + // TODO: do no clear sessions for instance cluster + await Session.delete({}); } diff --git a/api/tests/routes.test.ts b/api/tests/routes.test.ts
index 2c265ee3..35d74a94 100644 --- a/api/tests/routes.test.ts +++ b/api/tests/routes.test.ts
@@ -56,9 +56,7 @@ beforeAll(async (done) => { const response = await request("/auth/register", { body: { fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw", - email: "test@example.com", username: "tester", - password: "wtp9gep9gw", invite: null, consent: true, date_of_birth: "2000-01-01",