From bb78c61b0801fa6acb1cf444f14824ac18d64c4b Mon Sep 17 00:00:00 2001 From: Mehdi Benadel Date: Mon, 12 May 2025 11:00:35 +0200 Subject: [PATCH] Fix #75: Short uuid handling --- CHANGELOG.md | 1 + client/tsconfig.json.license | 1 + package-lock.json | 72 ++++++++++++++++++++++++++++-------- package-lock.json.license | 1 + package.json | 1 + package.json.license | 1 + server/tsconfig.json | 2 +- shared/lib/config.ts | 21 ++++++++++- 8 files changed, 83 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e0d322..887103ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Fix #547: add button to go to the end of the chat * Fix #503: set custom emojis max height to text height + bigger when posted alone * Fix: Converse bottom panel messages not visible on new Peertube v7 theme (for example for muted users) +* Fix #75: New short video urls makes it difficult to use the settings «Activate chat for these videos». ## 12.0.4 diff --git a/client/tsconfig.json.license b/client/tsconfig.json.license index b253ad42..0549bba9 100644 --- a/client/tsconfig.json.license +++ b/client/tsconfig.json.license @@ -1,3 +1,4 @@ SPDX-FileCopyrightText: 2024 John Livingston +SPDX-FileCopyrightText: 2025 Mehdi Benadel SPDX-License-Identifier: AGPL-3.0-only diff --git a/package-lock.json b/package-lock.json index 9161229f..8ef897d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "http-proxy": "^1.18.1", "log-rotate": "^0.2.8", "openid-client": "^5.7.1", + "short-uuid": "^5.2.0", "validate-color": "^2.2.4", "xmppjs-chat-bot": "^0.5.0" }, @@ -3250,6 +3251,20 @@ "node": "14 || >=16.14" } }, + "node_modules/@peertube/peertube-types/node_modules/short-uuid": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-4.2.2.tgz", + "integrity": "sha512-IE7hDSGV2U/VZoCsjctKX6l5t5ak2jE0+aeGJi3KtvjIUNuZVmHVYUjNBhmo369FIWGDtaieRaO8A83Lvwfpqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-base": "^1.1.0", + "uuid": "^8.3.2" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -5138,8 +5153,7 @@ "node_modules/any-base": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz", - "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==", - "dev": true + "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==" }, "node_modules/anymatch": { "version": "3.1.2", @@ -11637,16 +11651,29 @@ } }, "node_modules/short-uuid": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-4.2.0.tgz", - "integrity": "sha512-r3cxuPPZSuF0QkKsK9bBR7u+7cwuCRzWzgjPh07F5N2iIUNgblnMHepBY16xgj5t1lG9iOP9k/TEafY1qhRzaw==", - "dev": true, + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-5.2.0.tgz", + "integrity": "sha512-296/Nzi4DmANh93iYBwT4NoYRJuHnKEzefrkSagQbTH/A6NTaB68hSPDjm5IlbI5dx9FXdmtqPcj6N5H+CPm6w==", + "license": "MIT", "dependencies": { "any-base": "^1.1.0", - "uuid": "^8.3.2" + "uuid": "^9.0.1" }, "engines": { - "node": ">=8" + "node": ">=14" + } + }, + "node_modules/short-uuid/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" } }, "node_modules/side-channel": { @@ -15504,6 +15531,16 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-9.1.2.tgz", "integrity": "sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==", "dev": true + }, + "short-uuid": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-4.2.2.tgz", + "integrity": "sha512-IE7hDSGV2U/VZoCsjctKX6l5t5ak2jE0+aeGJi3KtvjIUNuZVmHVYUjNBhmo369FIWGDtaieRaO8A83Lvwfpqw==", + "dev": true, + "requires": { + "any-base": "^1.1.0", + "uuid": "^8.3.2" + } } } }, @@ -16987,8 +17024,7 @@ "any-base": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz", - "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==", - "dev": true + "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==" }, "anymatch": { "version": "3.1.2", @@ -21663,13 +21699,19 @@ "dev": true }, "short-uuid": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-4.2.0.tgz", - "integrity": "sha512-r3cxuPPZSuF0QkKsK9bBR7u+7cwuCRzWzgjPh07F5N2iIUNgblnMHepBY16xgj5t1lG9iOP9k/TEafY1qhRzaw==", - "dev": true, + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-5.2.0.tgz", + "integrity": "sha512-296/Nzi4DmANh93iYBwT4NoYRJuHnKEzefrkSagQbTH/A6NTaB68hSPDjm5IlbI5dx9FXdmtqPcj6N5H+CPm6w==", "requires": { "any-base": "^1.1.0", - "uuid": "^8.3.2" + "uuid": "^9.0.1" + }, + "dependencies": { + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + } } }, "side-channel": { diff --git a/package-lock.json.license b/package-lock.json.license index b253ad42..0549bba9 100644 --- a/package-lock.json.license +++ b/package-lock.json.license @@ -1,3 +1,4 @@ SPDX-FileCopyrightText: 2024 John Livingston +SPDX-FileCopyrightText: 2025 Mehdi Benadel SPDX-License-Identifier: AGPL-3.0-only diff --git a/package.json b/package.json index 853c1800..c0abe4ba 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "http-proxy": "^1.18.1", "log-rotate": "^0.2.8", "openid-client": "^5.7.1", + "short-uuid": "^5.2.0", "validate-color": "^2.2.4", "xmppjs-chat-bot": "^0.5.0" }, diff --git a/package.json.license b/package.json.license index b253ad42..0549bba9 100644 --- a/package.json.license +++ b/package.json.license @@ -1,3 +1,4 @@ SPDX-FileCopyrightText: 2024 John Livingston +SPDX-FileCopyrightText: 2025 Mehdi Benadel SPDX-License-Identifier: AGPL-3.0-only diff --git a/server/tsconfig.json b/server/tsconfig.json index 483b0165..d33f1785 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -2,7 +2,7 @@ "extends": "@tsconfig/node16/tsconfig.json", "compilerOptions": { "noImplicitReturns": true, - "noImplicitOverride": true, + "noImplicitOverride": true, "noUnusedLocals": true, "removeComments": true, "sourceMap": true, diff --git a/shared/lib/config.ts b/shared/lib/config.ts index b20f9fbc..87d63c1a 100644 --- a/shared/lib/config.ts +++ b/shared/lib/config.ts @@ -1,16 +1,35 @@ // SPDX-FileCopyrightText: 2024 John Livingston +// SPDX-FileCopyrightText: 2025 Mehdi Benadel // // SPDX-License-Identifier: AGPL-3.0-only +const short = require('short-uuid') + +const translator = short() + +function shortToUUID (shortUUID: string): string { + if (!shortUUID) return shortUUID + + return translator.toUUID(shortUUID) +} + +function isShortUUID (value: string): boolean { + if (!value) return false + + return value.length === translator.maxLength +} + function parseConfigUUIDs (s: string): string[] { if (!s) { return [] } let a = s.split('\n') a = a.map(line => { - return line.replace(/#.*$/, '') + line = line.replace(/#.*$/, '') .replace(/^\s+/, '') .replace(/\s+$/, '') + + return isShortUUID(line) ? shortToUUID(line) : line }) return a.filter(line => line !== '') }