Fix #75: Short uuid handling

This commit is contained in:
Mehdi Benadel 2025-05-12 11:00:35 +02:00 committed by John Livingston
parent 5b8ccdf5ae
commit bb78c61b08
8 changed files with 83 additions and 17 deletions

View File

@ -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

View File

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
SPDX-FileCopyrightText: 2025 Mehdi Benadel <https://mehdibenadel.com>
SPDX-License-Identifier: AGPL-3.0-only

72
package-lock.json generated
View File

@ -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": {

View File

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
SPDX-FileCopyrightText: 2025 Mehdi Benadel <https://mehdibenadel.com>
SPDX-License-Identifier: AGPL-3.0-only

View File

@ -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"
},

View File

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
SPDX-FileCopyrightText: 2025 Mehdi Benadel <https://mehdibenadel.com>
SPDX-License-Identifier: AGPL-3.0-only

View File

@ -2,7 +2,7 @@
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"noImplicitReturns": true,
"noImplicitOverride": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"removeComments": true,
"sourceMap": true,

View File

@ -1,16 +1,35 @@
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
// SPDX-FileCopyrightText: 2025 Mehdi Benadel <https://mehdibenadel.com>
//
// 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 !== '')
}